PDA

View Full Version : ammopack



malyczolg
29th March 2013, 10:41
why script dont work ?

trigger not work.


sq_ammopack()
{
precachemodel("xmodel/prop_mortar_crate2");
self.prop = spawn("script_model", self.origin );
self.prop.angles = (0,0,0);
self.prop setmodel("xmodel/prop_mortar_crate2");
self.prop_trigger = spawn("trigger_radius", self.origin, 30, 30, 30 );
self.prop_trigger enablelinkto();
self.prop_trigger linkto(self.prop);

time = 0;
for( time = 0; time < 800; time++ )
{
wait 0.05;
self.prop_trigger waittill("trigger", player);
if(player usebuttonpressed())
{
player getweaponslotammo("primary");
player getweaponslotammo("primaryb");
player setweaponslotammo("primary", 1000);
player setweaponslotammo("primaryb", 1000);
}
}
self.prop delete();
self.prop_trigger unlink();
self.prop_trigger delete();
}

kung foo man
29th March 2013, 11:21
Hey, please use
next time, than the code is colored. ^^

To the problem:

Can you add:



if(player usebuttonpressed())
{
iprintlnbold("Did I got called?!?!?!");
player getweaponslotammo("primary");
player getweaponslotammo("primaryb");
player setweaponslotammo("primary", 1000);
player setweaponslotammo("primaryb", 1000);
}


(So you see if its even called)


Also, the loop runs only for 40secs.

malyczolg
29th March 2013, 11:51
Kung Foo Man
you do not understand, when I put ammo is no trigger
I do not have to click f

kung foo man
29th March 2013, 12:36
So it would often print the iprintlnbold()?

malyczolg
29th March 2013, 12:45
i dont have trigger , i cant press f
i add iprintlnbold

kung foo man
29th March 2013, 12:51
What does this do?



iprintlnbold("Trigger?!?!?!");
if(player usebuttonpressed())
{
player getweaponslotammo("primary");
player getweaponslotammo("primaryb");
player setweaponslotammo("primary", 1000);
player setweaponslotammo("primaryb", 1000);
}


Does it print:
Trigger?!?!?!
Trigger?!?!?!
Trigger?!?!?!
Trigger?!?!?!

When you go to it?

malyczolg
29th March 2013, 14:03
no ;)
i dont have message .

kung foo man
29th March 2013, 14:09
Try:


self.prop_trigger = spawn("trigger_radius", self.origin, 0, 30, 30 );

The third argument is "spawn flags", which should be 0.

malyczolg
29th March 2013, 16:30
THX WORK , how can add : PREES F to get ammo

kung foo man
29th March 2013, 16:45
setHintString() doesnt work on spawned entities. So you need to do it manual:



displayHintString(hintstring, entity)
{
player = self;

if ( ! isDefined(player))
return;

if ( ! isDefined(hintstring))
return;

if (isdefined(player.hintstring))
return;

player.hintstring = newClientHudElem(player);
player.hintstring.horzAlign = "fullscreen";
player.hintstring.vertAlign = "fullscreen";
player.hintstring.alignX = "center";
player.hintstring.alignY = "middle";
player.hintstring.x = 320; // 640
player.hintstring.y = 300; // 480
player.hintstring.fontScale = 1.6; // 1.1
player.hintstring.alpha = 1; // zero to one
player.hintstring setText(hintstring);

player thread deleteHintString(entity);
}

deleteHintString(entity)
{
player = self;

while (isdefined(player) && isdefined(player.hintstring))
{
if (player isTouching(entity.trigger))
{
wait 0.10;
continue;
}

player.hintstring destroy();
}
}

malyczolg
29th March 2013, 16:47
kung fu i test script with friend , if i plant ammopack and he use f , This ammo comes to me and not him