Yeeeeeeeeeah.
When using this code, when someone purchase Ammo, it doesnt take away 200 points, it takes away.. pretty much alot more since its foreach player.
Is there any fix to make it only take the points away from the guy purchasing? This has really been annoying me >.<
Code:
AmmOMatic(pos, angle)
{
block = spawn("script_model", pos );
block setModel("com_plasticcase_friendly");
block.angles = angle;
block Solid();
block CloneBrushmodelToScriptmodel( level.airDropCrateCollision );
self thread AmmoThink(pos);
wait 0.01;
}
AmmoThink(pos)
{
self endon("disconnect");
for(;;)
{
foreach(player in level.players)
{
if(distance(pos, player.origin) <75 && player.cash >= 200)
Player SetLowerMessage(1, "Press ^3[{+activate}] ^7to purchase Ammo", undefined, 25);
else if(distance(pos, player.origin) <75 && player.cash < 200)
Player SetLowerMessage(1, "You do not have enough ^1Cash!", undefined, 50);
if(distance(pos, player.origin) <75 && player.cash >= 200 && Player UseButtonPressed())
{
player thread refillAmmo();
}
if(distance(pos, player.origin) >75) Player ClearLowerMessage(1);
}
wait 0.05;
}
}
refillAmmo()
{
weaponList = self GetWeaponsListAll();
foreach ( weaponName in weaponList )
{
if ( isSubStr( weaponName, "grenade" ) )
{
if ( self getAmmoCount( weaponName ) >= 1 )
continue;
}
self.cash -= 200;
self giveMaxAmmo( weaponName );
}
}