Give a suggestion for this logical error

Started by GangstaRas, May 17, 2015, 03:01 PM

Previous topic - Next topic

GangstaRas

I wrote this code to fix a bug I found in server.conf where after a certain value input for ammo for each spawnwep per respective skin, it didn't represent it well (like putting in 500 for ammo amount gives back 244 ammo in the game, 9999 gave back 100 and something if I remember correctly).

function onPlayerSpawn (player)
{
        //Ammo Correction for President's Skin; working but bugged
if (skin == 56)
{
player.GiveWeapon(18,9999);
}

//Ammo Correction for Vice's Skin; working but bugged
if (skin == 52)
{
player.GiveWeapon(17,9999);
}

//Ammo Correction for Security Skins; working but bugged
if (skin == 102 || 104 || 130 || 21 || 67)
{
player.GiveWeapon(21,9999);
player.GiveWeapon(25,9999);
player.GiveWeapon(26,9999);
}

//Ammo Correction for Police Skins; working but bugged
if (skin == 1 || 2 || 3 || 68)
{
player.GiveWeapon(18,9999);
player.GiveWeapon(24,9999);
player.GiveWeapon(26,9999);
}

//Ammo Correction for Terrorist's Skins; working but bugged
if (skin == 11 || 48 || 51 || 87 || 90 || 95 || 96 || 146 || 147 || 153)
{
player.GiveWeapon(20,9999);
player.GiveWeapon(22,9999);
player.GiveWeapon(32,9999);
}
}

This code I have works in that the weapons are given and the correct ammo is too but the bug I found was that the Python, Tec9, M4 and M60 is being distributed to every skin. Irrespective of whatever spawnwep I have set whether in the script or in server.conf, the respective weapon slots are overwritten (so like for President's skin which is to be only the Golf Club and Python, it is now Golf Club (stays as no weapon clashes this), Python, Tec9, M4 and M60)

So any suggestions to fix this up? I'm thinking its maybe too many OR operators but I don't want to go the lengthy route if there's something easier that could be done here.

Gulk


GangstaRas

Heh it was hell writing all those skin IDs but thanks, worked well