18.06.2016, 20:03
Alright so Im facing a problem with this.
Basically it will detect if the weapon is given by the server or spawned in by player but seems that Im doing something wrong
13 represents the slots
Now with a simple command, it wont work.
It will detect every weapon as suspicious no matter if it was server or player spawned
EDIT: for some reason it will give 2 weapons inside of 1 on spawn.
and /check results are
Basically it will detect if the weapon is given by the server or spawned in by player but seems that Im doing something wrong
PHP код:
enum P_WEAPONS {
P_WeaponID,
P_Ammo
};
new PlayerWeapon[MAX_PLAYERS][13][P_WEAPONS];
PHP код:
stock GivePlayerWeaponEx(playerid, weaponid, ammo) {
new slot = GetWeaponSlot(weaponid);
PlayerWeapon[playerid][slot][P_WeaponID] = weaponid;
PlayerWeapon[playerid][slot][P_Ammo] = ammo;
GivePlayerWeapon(playerid, weaponid, ammo);
}
stock GetWeaponSlot(weaponid)
{
new slot;
switch(weaponid){
case 0, 1: slot = 0; // No weapon
case 2 .. 9: slot = 1; // Melee
case 22 .. 24: slot = 2; // Handguns
case 25 .. 27: slot = 3; // Shotguns
case 28, 29, 32: slot = 4; // Sub-Machineguns
case 30, 31: slot = 5; // Machineguns
case 33, 34: slot = 6; // Rifles
case 35 .. 38: slot = 7; // Heavy Weapons
case 16, 18, 39: slot = 8; // Projectiles
case 42, 43: slot = 9; // Special 1
case 14: slot = 10; // Gifts
case 44 .. 46: slot = 11; // Special 2
case 40: slot = 12; // Detonators
default: slot = -1; // No slot
}
return slot;
}
PHP код:
YCMD:check(playerid,params[],help) {
new weapons[13][2];
for (new i = 0; i <= 12; i++) {
GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
if(weapons[i][0] != PlayerWeapon[playerid][i][P_WeaponID] || weapons[i][1] != PlayerWeapon[playerid][i][P_Ammo]) {
SCM(playerid,COLOR_RED,"Suspicious weapon: %i %i",weapons[i][0], weapons[i][1]);
}
}
return true;
}
EDIT: for some reason it will give 2 weapons inside of 1 on spawn.
PHP код:
[22:13:55] Weapon ID: 24 || Ammo: 10 || Slot: 2
[22:13:55] Weapon ID: 24 || Ammo: 10 || Slot: 2
PHP код:
[22:14:04] Weapon ID: 0 || Ammo: 154 || Slot: 0
[22:14:04] Weapon ID: 24 || Ammo: 20 || Slot: 2