PDA

View Full Version : Individual weapon slots


ajwar
20/03/2014, 11:38 AM
Hi, i was working on weapon system that would have ammo per weapon and not ammo per slot.


stock GivePlayerWeaponEx(playerid,weaponid,ammo)
{
if(!IsPlayerConnected(playerid)) return 0;

new weapon, oldammo;
GetPlayerWeaponData(playerid, weapon_slot[weaponid], weapon, oldammo);

GivePlayerWeapon(playerid, weaponid, ammo);
if(weapon != weaponid && weapon != 0)
{
PlayerAmmo[playerid][weaponid] = ammo;
SetPlayerAmmo(playerid, weaponid, ammo);
}
else
{
PlayerAmmo[playerid][weaponid] = oldammo+ammo;
SetPlayerAmmo(playerid, weaponid, oldammo+ammo);
}
return 1;
}



new const weapon_slot[] = {
0,
0,
1,
1,
1,
1,
1,
1,
1,
1,
10, // 10
10,
10,
10,
10,
10,
8,
8,
8,
0,
0, // 20
0,
2,
2,
2,
3,
3,
3,
4,
4,
5, // 30
5,
4,
6,
6,
7,
7,
7,
7,
8,
12, // 40
9,
9,
9,
11,
11,
11
};



So everything looked good until i created an anticheat script:


new pWeapon[13],pAmmo[13];
for(new wid = 0; wid < 13; wid++)
{
GetPlayerWeaponData(playerid, wid, pWeapon[wid], pAmmo[wid]);
if(pAmmo[wid] > PlayerAmmo[playerid][pWeapon[wid]])
{
// cheat
}

}


I do reset PlayerAmmo variable on OnPlayerDeath, but the problem is that i get some false cheat messages. Any suggestions on what is wrong with this code?

ajwar
20/03/2014, 02:14 PM
bump