im pretty new to this whole scripting thing but know how to program and ive run into some problems as im sure most new scripters do...especially without ea releasing proper documentation for mohaa

. here is my code for a server side mod im making that will allow an admin to dynamically limit the number of grenades each player has ingame. it works to some degree but after testing it with some of my clanmembers we found that the grenade ammo will not be subtracted from the players after the map changes and they spawn and after they change teams(ie they will have 6 nades as opposed to the number specified by the cvar) . the reason for finding what weapon the player has in their hands is simply to find out if they have actually spawned and then take away their ammo after that(thx to jv for telling me how to do that:P) but if there is a better way to do this id appreciate anyone telling me how

. here is the grenade section of my code for the server mod im making:
//Weapon Ammo Allowance module
grenadelimit:
level waittill spawn
for(local.a = 1; local.a <= $player.size; local.a++)
{
level.weaponammocheck[local.a] = 0
}
while(true)
{
local.numgrenades = int(getcvar(gi_numgrenades))
local.nades = 6-local.numgrenades
for(local.i = 1; local.i <= $player.size; local.i++)
{
local.person = $player[local.i]
local.numb = randomint 1000
$player[local.i] weaponcommand dual targetname local.numb
if(isalive(local.person) && (local.person.health > 0) && (local.person.dmteam != "spectator") && local.person != "NULL")
{
if($(local.numb).model != NIL)
{
if(level.weaponammocheck[local.i] == 0)
{
local.person ammo grenade -local.nades
level.weaponammocheck[local.i] = 1
}
}
}
else
{
level.weaponammocheck[local.i] = 0
}
}
wait 0.1
}
end
im sure the problem with this script is that when changing teams or maps...at no point are any of these conditions false:
if(isalive(local.person) && (local.person.health > 0) && (local.person.dmteam != "spectator") && local.person != "NULL")
which will therefore not reset the level.weaponammocheck[local.i] back to zero until they die again and will therefore not subtract ammo from them. i did try assigning the team of each player in an array at the beginning of the map then adding a condition to check if this was the same as when they started the map and if not deducting their ammo and assigning their current team to that array element...but i dont think i did this correctly

. i tried a similar thing with the mapname but with no success. help appreciated
