GivePlayerCash(playerid, money)
{
dailyEarning[playerid] += money;
playerCash[playerid] += money;
GivePlayerMoney(playerid, money);
}
TakePlayerCash(playerid, money)
{
GivePlayerMoney(playerid, 0 - money);
playerCash[playerid] -= money;
}
ResetPlayerCash(playerid)
{
new money = GetPlayerCash(playerid);
dailyEarning[playerid] -= money;
playerCash[playerid] -= money;
ResetPlayerMoney(playerid);
}
ResetPWeapons(playerid)
{
ResetPlayerWeapons(playerid);
for (new i = 0; i < 13; i++) {
playerWeapon[playerid][i] = 0;
}
}
GivePWeapon(playerid, weapon, ammo)
{
switch (weapon)
{
case 0,1: playerWeapon[playerid][0] = weapon;
case 2,3,4,5,6,7,8,9: playerWeapon[playerid][1] = weapon;
case 10,11,12,13,14,15: playerWeapon[playerid][10] = weapon;
case 16,17,18: playerWeapon[playerid][8] = weapon;
case 22,23,24: playerWeapon[playerid][2] = weapon;
case 25,26,27: playerWeapon[playerid][3] = weapon;
case 28,29,32: playerWeapon[playerid][4] = weapon;
case 30,31: playerWeapon[playerid][5] = weapon;
case 33,34: playerWeapon[playerid][6] = weapon;
case 35,36,37,38: playerWeapon[playerid][7] = weapon;
case 39: playerWeapon[playerid][8] = weapon;
case 40: playerWeapon[playerid][12] = weapon;
case 41,42,43: playerWeapon[playerid][9] = weapon;
case 44,45,46: playerWeapon[playerid][11] = weapon;
}
GivePlayerWeapon(playerid, weapon, ammo);
}
if (GetPlayerMoney(i) > playerCash[i])
{
cashHackWarn[i]++;
format(string, sizeof(string), "Cash hack warn! %d %d", GetPlayerMoney(i), playerCash[i]);
SendClientMessage(i, COLOUR_ERROR, string);
//if (cashHackWarn[i] == 2) BanPlayer(i, "AUTO", "Anti-Cheat", "Cheat ID 0 was detected!");
if (cashHackWarn[i] >= 4) {
KickPlayer(i, "AUTO", "Cheat ID 0 Detected!");
}
}
else if (GetPlayerMoney(i) < playerCash[i])
{
cashHackWarn[i]++;
format(string, sizeof(string), "Money shortage warn! %d %d", GetPlayerMoney(i), playerCash[i]);
SendClientMessage(i, COLOUR_ERROR, string);
if (cashHackWarn[i] >= 3) playerCash[i] = GetPlayerMoney(i);
}
else
{
if (cashHackWarn[i] > 0) SendClientMessage(i, COLOUR_ERROR, "Cash false alarm!");
cashHackWarn[i] = 0; // False alarm! Reset cash warning!
}
}
// Weapon anti-cheat
new weapon;
new ammo;
for (new x = 0; x < 13; x++)
{
if (tazerDrawn[i]) weaponHackWarn[i][x] = 0;
else
{
if (timeoutCount[i] < 2)
{
GetPlayerWeaponData(i, x, weapon, ammo);
if (weapon != 0)
{
playerAmmo[i][x] = ammo;
if (playerWeapon[i][x] != weapon) {
weaponHackWarn[i][x]++;
format(string, sizeof(string), "Weapon hack warn! %d %d", weapon, playerWeapon[i][x]);
printf("%s Weapon hack warn! %d %d", ReturnPlayerName(i), weapon, playerWeapon[i][x]);
SendClientMessage(i, COLOUR_ERROR, string);
if (weaponHackWarn[i][x] >= 4) {
KickPlayer(i, "AUTO", "Cheat ID 1 Detected!");
}
}
else { weaponHackWarn[i][x] = 0; }
}
else
{
if (playerWeapon[i][x] > 0)
{
weaponHackWarn[i][x]++;
format(string, sizeof(string), "Weapon loss warn! %d %d", weapon, playerWeapon[i][x]);
SendClientMessage(i, COLOUR_ERROR, string);
printf("%s Weapon loss warn! %d %d", ReturnPlayerName(i), weapon, playerWeapon[i][x]);
if (weaponHackWarn[i][x] >= 4) {
printf("%s Weapons were removed %d %d", ReturnPlayerName(i), weapon, playerWeapon[i][x]);
playerWeapon[i][x] = 0;
playerAmmo[i][x] =0;
}
}
else { weaponHackWarn[i][x] = 0; }
}
}
}
}
Sync System
A thing I've been keeping a secret for a while is a sync system to check that a player is syncing right, it takes the method of the health checking system and applies it to armour, ammo and position ect. here's an example of how it works with armour. variables: 1. what their armour should be (armourShouldBe) 2. what their last updated armour was (lastArmourChecked) 3. is the player's armour synced (armourSynced) 4. the armour on the check (currentArmour) every time you set a players armour, set armourShouldBe to the new value and set armourSynced to 0 (false) then every x you check the player's armour, if the armourSynced is set to 0 then check if currentArmour is the same as armourShouldBe, if it is then set armourSynced to 1. if armourSynced is set to 1 then check currentArmour to lastArmourChecked, if currentArmour is larger than lastArmourChecked they used a non scripted way to get armour, if its less set lastArmourChecked to currentArmour. Break down into steps: 1. SetPlayerArmour sets armourShouldBe to the new value, sets armourSynced to 0 2. Your AC check goes off and stores their current armour as currentArmour 3a. If armourSynced is 0 check if currentArmour is the same as armourShouldBe, if it is then set armourSynced to 1 3b. If armourSynced is set to 1 then check currentArmour against lastArmourChecked, if currentArmour is less than lastArmourChecked then set lastArmourChecked to currentArmour. If currentArmour is larger than lastArmourChecked then flag the player for a possible cheater script: I've changed variable names and inserted a lot of comments to make it more clearer, so sorry if I've made a mistake pawn Код:
pawn Код:
Checking if a player is AFK or not can also help http://forum.sa-mp.com/showpost.php?...8&postcount=43 For an example implementation http://forum.sa-mp.com/showpost.php?...6&postcount=46 |