15.05.2014, 21:36
pawn Код:
#include <a_samp>
new LastWeaponPlayer[MAX_PLAYERS];
new MoneyPlayer[MAX_PLAYERS];
new WeaponPlayer[MAX_PLAYERS][13];
#define GivePlayerWeapon@(%1,%2,%3) WeaponPlayer[%1][GetWeaponSlot(%2)] = %2, GivePlayerWeapon(%1, %2, %3)
#define GivePlayerMoney@(%1,%2) MoneyPlayer[%1] = (GetPlayerMoney(%1)+%2), GivePlayerMoney(%1, %2)
public OnPlayerUpdate(playerid)
{
if(GetPlayerWeapon(playerid) != LastWeaponPlayer[playerid])
{
CallLocalFunction("OnPlayerChangeWeapon", "dii", playerid, GetPlayerWeapon(playerid), LastWeaponPlayer[playerid]);
LastWeaponPlayer[playerid] = GetPlayerWeapon(playerid);
}
if(GetPlayerMoney(playerid) > MoneyPlayer[playerid]) CallLocalFunction("OnPlayerMoneyHack", "dii", playerid, GetPlayerMoney(playerid), MoneyPlayer[playerid]);
return 1;
}
forward OnPlayerChangeWeapon(playerid, newweapon, oldweapon);
public OnPlayerChangeWeapon(playerid, newweapon, oldweapon)
{
static data[2];
GetPlayerWeaponData(playerid, GetWeaponSlot(newweapon), data[0], data[1]);
if(data[0] != WeaponPlayer[playerid][GetWeaponSlot(newweapon)])
{
CallLocalFunction("OnPlayerWeaponHack", "dii", playerid, data[0], WeaponPlayer[playerid][GetWeaponSlot(newweapon)]);
}
return 1;
}
stock GetWeaponSlot(weaponid)
{
switch(weaponid)
{
case 0, 1: return 0;
case 2 .. 9: return 1;
case 22 .. 24: return 2;
case 25 .. 27: return 3;
case 28, 29, 32: return 4;
case 30, 31: return 5;
case 33, 34: return 6;
case 35 .. 38: return 7;
case 16 .. 19, 39: return 8;
case 41 .. 43: return 9;
case 10 .. 15: return 10;
case 44 .. 46: return 11;
case 40: return 12;
default: return -1;
}
return -1;
}
forward OnPlayerMoneyHack(playerid, hackmoney, oldmoney);
forward OnPlayerWeaponHack(playerid, hackweapon, realweapon);
- Notes:
- To avoid problems, you must use this:
pawn Код:public OnPlayerSpawn(playerid)
{
// Here if you assign weapon...
LastWeaponPlayer[playerid] = lastweapon; // 'lastweapon' Would refer to the last one ID of weapon that we assign in this callback.
return 1;
}- In the parts where it assigns weapon or money to the player, you must replace this function and add a '@' at the end of the name of the function.
- Only use 'GivePlayerMoney@' if it wants to increase the money of the player.