Ammo box / Equpment Box

Posts 1–15 of 22 · Page 1 of 2
Ammo box / Equpment Box
I got this ammo box from the AIZombies mod, but I'm trying to make it give ammo when you press F.
Code:
giveAmmo()
{
level endon("disconnect");

for(;;)
{
	foreach( player in level.players )
	{
		if(!isDefined(player.ammoing))
		player.ammoing = false;

		if(distancesquared(self.origin, player.origin) <= 9732 && !player.ammoing)
		{
		if(player.sessionstate != "playing")
		continue;

		player thread ammoWaitThread();
		
		player playlocalsound("weap_pickup");

		player giveMaxAmmo(player getCurrentWeapon());
            
            player giveMaxAmmo(player getCurrentOffhand());
		}
	}

wait 0.05;
}
}

ammoWaitThread()
{
self endon("death");
self endon("disconnect");

self.ammoing = true;
wait 1;
self.ammoing = false;
}
I've tried quite alot, but when I seem to do it it SPAMS me with ammo when I havent even clicked F.
So either a solution for that, or a code that would spawn a box that gives ammo at <coordinates>. Though I'd like it to be a thread that I can do into a create block, like i did here:
Code:
CreateAmmoBlock(pos, angle)
{
	block = spawn("script_model", pos );
	block setModel("com_bomb_objective");
	block.angles = angle;
	block Solid();
      block thread giveAmmo();
	block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
	wait 0.01;
}
Second one is a box that gives a semtex/frag/c4/stun or whatever. I havent gotten this already, and I'd either like a thread for <coordinates> or something I could add into a block as stated above.

EDIT: Oh yeah, and make the ammo sign over the ammo box would be pwnage (:
Tried to copypaste that too from the AIZombies but it kind of went.. bad

Thanks (:
Because the use function is not here...
Search for something like "actionslot1"
EDIT: ammoWaitThread();
Heres what I tried shitloads of, but as I wrote it just spams me with ammo instead when I havent pressed F

Code:
ammoWaitThread()
{
self endon("death");
self endon("disconnect");

self notifyOnPlayerCommand( "F", "+activate" );

self waittill("F"); 
self.ammoing = true;
wait 3;
self.ammoing = false;
}
Quote Originally Posted by Arasonic View Post
Heres what I tried shitloads of, but as I wrote it just spams me with ammo instead when I havent pressed F

Code:
ammoWaitThread()
{
self endon("death");
self endon("disconnect");

self notifyOnPlayerCommand( "F", "+activate" );

self waittill("F"); 
self.ammoing = true;
wait 3;
self.ammoing = false;
}
Um...If i were u i will not use that code

EDIT: Because it spams u with ammo in AIZombies too
Quote Originally Posted by alistair4322 View Post
Um...If i were u i will not use that code

EDIT: Because it spams u with ammo in AIZombies too
x)
All I want basicly is either a solution for that or a whole new code >.<
& Still looking for a box with semtex etc
Quote Originally Posted by Arasonic View Post
x)
All I want basicly is either a solution for that or a whole new code >.<
& Still looking for a box with semtex etc
I am nearly done...And for semtex...just some simple code is ok...
It is diffcult...Still can't get it right

Quote Originally Posted by Arasonic View Post
x)
All I want basicly is either a solution for that or a whole new code >.<
& Still looking for a box with semtex etc
May be this will help

Code:
giveAmmo()
{
level endon("disconnect");

for(;;)
{
	foreach( player in level.players )
	{
		if(!isDefined(player.ammoing))
		player.ammoing = false;

		if(distancesquared(self.origin, player.origin) <= 9732 && !player.ammoing) //CHANGE 9732 TO 50
		{
		if(player.sessionstate != "playing")
		continue;

		player thread ammoWaitThread();
		
		player playlocalsound("weap_pickup");

		player giveMaxAmmo(player getCurrentWeapon());
            
            player giveMaxAmmo(player getCurrentOffhand());
		}
	}

wait 0.05;
}
}

ammoWaitThread()
{
self endon("death");
self endon("disconnect");

self.ammoing = true;
wait 1;
self.ammoing = false;
}
Uhm, what did you do?
Code:
giveAmmo()
{
level endon("disconnect");

for(;;)
{
    foreach( player in level.players )
    {
        if(!isDefined(player.ammoing))
        player.ammoing = false;

        if(distancesquared(self.origin, player.origin) <= 9732 && !player.ammoing)
        {
        if(player.sessionstate != "playing")
        continue;

        player thread ammoWaitThread();
        
        player playlocalsound("weap_pickup");

        player giveMaxAmmo(player getCurrentWeapon());
            
            player giveMaxAmmo(player getCurrentOffhand());
        }
    }

wait 0.05;
}
}

ammoWaitThread()
{
self endon("death");
self endon("disconnect");

for(;;)
{
   if(player UseButtonPressed())
   {
        self.ammoing = true;
   }
    wait 1;
    self.ammoing = false;
}
That just gets me a bad syntax 0o
Quote Originally Posted by Arasonic View Post
That just gets me a bad syntax 0o
He miss a } at last
Ehhhhhh... It worked fine before I changed it again and added another }, but now when I added it, I got uninitialised variable 'player'
Quote Originally Posted by Arasonic View Post
Ehhhhhh... It worked fine before I changed it again and added another }, but now when I added it, I got uninitialised variable 'player'
Me too...The code is not working again...
Another thing, this:
Code:
SpawnWeapon(weapName, coords, angles)
{
point = spawn("script_origin", coords);
weap = SpawnWeap(weapName, point.origin);

if(isDefined(angles))
weap.angles = angles;

weap linkto( point );

return point;
}
Is there any way I could make it come with text as the last one, 'Press F to swap for <weapon>'?
Quote Originally Posted by Arasonic View Post
Another thing, this:
Code:
SpawnWeapon(weapName, coords, angles)
{
point = spawn("script_origin", coords);
weap = SpawnWeap(weapName, point.origin);

if(isDefined(angles))
weap.angles = angles;

weap linkto( point );

return point;
}
Is there any way I could make it come with text as the last one, 'Press F to swap for <weapon>'?
Your original code make that already, don't u?
Posts 1–15 of 22 · Page 1 of 2
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us