I found Killindyls code on ammo boxes but when I put it into my _Rank.gsc it gives me an error. What am I missing?
Code:
CreateAmmoBox(pos, angle, team)
{
block = spawn("script_model", pos, 1 );
block setModel(level.crateModelBoobyTrapped);
block Solid();
block.angles = angle;
block SetOwner( level );
block thread AmmoBoxThink(team);
wait 0.01;
}
Code:
AmmoBoxThink(team)
{
while(1)
{
for(i = 0; i < level.players.size; i++)
{
if(team != "all" && level.players[i].team != team){
continue;
}
if(DistanceSquared(self.origin, level.players[i].origin) <= Power(50, 2)){
level.players[i].hint = "Press ^3[{+activate}] ^7to Refill your ammo";
if(level.players[i] UseButtonPressed()){
level.players[i] DisableWeapons();
level.players[i].weaponlist = level.players[i] GetWeaponsList();
for( idx = 0; idx < level.players[i].weaponlist.size; idx++ )
{
weapon = level.players[i].weaponlist[idx];
switch( weapon )
{
case "frag_grenade_mp":
case "sticky_grenade_mp":
case "hatchet_mp":
case "flash_grenade_mp":
case "concussion_grenade_mp":
case "tabun_gas_mp":
case "nightingale_mp":
case "willy_pete_mp":
level.players[i] SetWeaponAmmoStock( weapon, 999 );
break;
default:
level.players[i] GiveMaxAmmo( weapon );
break;
}
}
level.players[i] playLocalSound( "ammo_crate_use" );
wait 1.5;
level.players[i] EnableWeapons();
}
}
}
wait .045;
}
}