UGX-Mods

Call of Duty 5: World at War => Help Desk => Scripting => Topic started by: Nanikos on March 14, 2019, 04:51:00 pm

Title: Scripting: Model won't delete itself.. but trigger deletes just fine??
Post by: Nanikos on March 14, 2019, 04:51:00 pm
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");
}
(https://imgur.com/qDFnhsc)(https://imgur.com/qDFnhsc)
(https://imgur.com/SeV4FEp)
Title: Re: Scripting: Model won't delete itself.. but trigger deletes just fine??
Post by: klevi on March 26, 2019, 11:49:34 am
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.
Title: Re: Scripting: Model won't delete itself.. but trigger deletes just fine??
Post by: ihmiskeho on March 26, 2019, 02:55:21 pm
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");
}
Title: Re: Scripting: Model won't delete itself.. but trigger deletes just fine??
Post by: johndoe on March 26, 2019, 03:15:19 pm
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.