forward MoneyUpdate(); // Ele atualiza o dinheiro do player e checa se o dinheiro esta diferente. As funзхes estгo dentro de um loop while e tem um timer nele desde o Init do GM e й executado a cada 5 seg.
forward MoneyUpdateForPlayer(playerid); // Ele apenas atualiza o dinheiro pro player.
forward MoneyCheckForPlayer(playerid, checkedid); // Checa se o dinheiro tб diferente do server. Se maior, alerta o admin se for menor, executa O MoneyUpdateForPlayer
forward SetPlayerServerMoney(playerid, ammount); // Seta a grana server side e atualiza ele
forward GivePlayerServerMoney(playerid, ammount); // mesma coisa, sу que dб a grana
forward ResetPlayerServerMoney(playerid); // e aqui ele reseta
#include <a_samp>
new Money[MAX_PLAYERS];
new UpdateTimer;
forward MoneyUpdate();
forward MoneyUpdateForPlayer(playerid);
forward MoneyCheckForPlayer(playerid, checkedid);
forward SetPlayerServerMoney(playerid, ammount);
forward GivePlayerServerMoney(playerid, ammount);
forward ResetPlayerServerMoney(playerid);
public MoneyUpdate()
{
new i;
while(i < MAX_PLAYERS)
{
if(GetPlayerMoney(i) > Money[i])
{
new ii;
while(ii < MAX_PLAYERS)
{
if(IsPlayerAdmin(ii))
{
new str[80], str2[50], pName[21];
GetPlayerName(i, pName, 21);
format(str, 80, " -- O Player %s pode estar usando Cheat de Grana", pName);
format(str2, 50, " -- Client Side Money: %d | Server Side Money", GetPlayerMoney(i), Money[i]);
SendClientMessage(ii, 0xFFFFAAAA, str);
SendClientMessage(ii, 0xFFFFAAAA, str2);
}
}
}
ResetPlayerMoney(i);
GivePlayerMoney(i, Money[i]);
}
}
public MoneyUpdateForPlayer(playerid)
{
ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, Money[playerid]);
}
public SetPlayerServerMoney(playerid, ammount)
{
Money[playerid] = ammount;
MoneyUpdateForPlayer(playerid);
}
public GivePlayerServerMoney(playerid, ammount)
{
Money[playerid] += ammount;
MoneyUpdateForPlayer(playerid);
}
public ResetPlayerServerMoney(playerid)
{
Money[playerid] = 0;
MoneyUpdateForPlayer(playerid);
}
public MoneyCheckForPlayer(playerid, checkedid)
{
new CMoney, SMoney, pName[21];
GetPlayerName(checkedid, pName, 21);
CMoney = GetPlayerMoney(checkedid);
SMoney = Money[checkedid];
// Aqui, eu criei variaveis locais pra nгo fazer consultas Get repetidamente
if(CMoney > SMoney)
{
new str[80];
format(str, 80, "[!] - %s. [Client-Side: %d | Server-Side: %d]", pName, CMoney, SMoney);
SendClientMessage(playerid, 0xFFFFAAAA, str);
}
else MoneyUpdateForPlayer(checkedid);
}
public OnGameModeInit()
{
print("========================================");
print("| ServerSide Money Carregado |");
print("========================================");
print("= por: [iPs] Miki ======================");
UpdateTimer = SetTimer("MoneyUpdate", 5000, true);
return 1;
}
public OnGameModeExit()
{
KillTimer(UpdateTimer);
return 1;
}
Jб Tem Vбrios assim. Nгo Achei Necessбrio Na Minha Opiniгo
|