Scripting: Model won't delete itself.. but trigger deletes just fine??

broken avatar :(
Created 36 days ago
by Nanikos
0 Members and 1 Guest are viewing this topic.
74 views
broken avatar :(
×
broken avatar :(
Location: auYeppoon, QLD
Date Registered: 6 March 2019
Last active: 32 days ago
Posts
1
Respect
Forum Rank
Fresh Corpse
Primary Group
Member
×
Nanikos's Groups
Nanikos's Contact & Social Links
I have a model of a gas mask which has targetname item_pickup1 and then I've got a trigger over the top which is targetname item_pickup_trig1...
So I go in game and the script run's fine and comes up with my hintstring, I interact and I get my line prints in top left as it should, and the trigger deletes fine. But I can't delete the model at all??! Help!

Code: cpp
item_pickup()
{
item_model = GetEnt("item_pickup1", "targetname");
item_pickup_trig = GetEnt("item_pickup_trig1", "targetname");

item_pickup_trig sethintstring("Press and hold &&1 to pick up mask");

item_pickup_trig waittill("trigger", player);

item_model delete();
item_pickup_trig delete();

iPrintLn("Picked up Gas Mask");
}
Test height=100
Test2 height=100
broken avatar :(
×
broken avatar :(
Location: aldurres
Date Registered: 6 June 2017
Last active: 9 hours ago
Posts
94
Respect
Forum Rank
Rotting Walker
Primary Group
Member
My Contact & Social Links
More
Signature
i am the issue
×
klevi's Groups
klevi's Contact & Social LinksKlevi Alushik3nt89.aldontknow743k3ntklevi
i am nab at scripting, you can try this 
item_pickup_trig waittill("trigger");  But what i was really wondering is that, in your map in radiant is it misc_model or script_model, it should be script_model as far as i know. That's what can i suggest right now, hope you solve it.
broken avatar :(
×
broken avatar :(
Location: fi
Date Registered: 2 January 2015
Last active: 2 days ago
Posts
119
Respect
Forum Rank
Pack-a-Puncher
Primary Group
Member
My Contact & Social Links
More
Signature
Beginner mapper trying to make something for the community to enjoy
×
ihmiskeho's Groups
ihmiskeho's Contact & Social Linksihmiskeho
Try this and check if it prints the error message. If it does, you have mispelled the kvp or haven´t set the model as script_model
item_pickup()
{
item_model = GetEnt("item_pickup1", "targetname");
item_pickup_trig = GetEnt("item_pickup_trig1", "targetname");

item_pickup_trig sethintstring("Press and hold &&1 to pick up mask");

item_pickup_trig waittill("trigger", player);
        if(!isdefined(item_model) || item_model.size <= 0)
        {
             IPrintLnBold("Item model is missing!");
             return;
        }

item_model delete();
item_pickup_trig delete();

iPrintLn("Picked up Gas Mask");
}
broken avatar :(
×
broken avatar :(
Location: tr
Date Registered: 1 March 2013
Last active: 1 day ago
Posts
804
Respect
Forum Rank
The Decider
Primary Group
2015 Contest Winner
My Groups
More
My Contact & Social Links
More
Personal Quote
it all goes tumbling down
Signature
from now on, i'll post a random recipe for every stupid post as a response
×
johndoe's Groups
Donator ♥ Benevolent Soul who has our eternal gratitude and exclusive access to betas and the donator section of the forum.
Community Mapper Has released one or more maps to the UGX-Mods community which have been added to the UGX Map Manager.
2015 Contest Winner
johndoe's Contact & Social Linksmyc153-johndoe
Are you sure the model is a script_model? You might have accidentally added a misc_model and those ones aren't able to be manupilated with scripts.

 

Login

or login with an authentication provider below
Twitter
Discord
Steam
Twitch
Google
Loading ...