PHP код:
new timer[MAX_PLAYERS] = -1;
new ID[MAX_PLAYERS];
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/slap", true) == 0)
{
new s[256], Float:P[5], int, id;
s = strtok(cmdtext, idx);
if(!strlen(s)) return SendClientMessage(playerid, -1, "USO: /slap [ID]");
id = strval(s);
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000FF, "Jogador OFFLINE.");
if(timer[id] != -1) return SendClientMessage(playerid, 0xFF0000FF, "Este jogador jб estб sendo testado.");
GetPlayerPos(id, P[0], P[1], P[2]);
int = GetPlayerInterior(playerid);
GetPlayerHealth(id, P[3]);
GetPlayerFacingAngle(id, P[4]);
SetPlayerPos(playerid, 1678.967, 1447.949, 150);
CreateExplosion(1678.967, 1447.949, 145, 10, 2000);
SetPlayerInterior(playerid, 0);
ID[id] = playerid;
timer[playerid] = SetTimerEx("Check", 10000, false, "ddfffffd", playerid, id, P[0], P[1], P[2], P[3], P[4], int);
SendClientMessage(playerid, 0xFFFF00FF, "Aguarde 10 segundos para checar se este jogador estб usando cheat.");
printf("DEBUG 1 - [id %d]: %f", id, P[3]);
return 1;
}
return 0;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(timer[playerid] != -1)
{
KillTimer(timer[playerid]);
timer[playerid] = -1;
SendClientMessage(ID[playerid], 0xFFFF00FF, "O jogador nгo estб usando cheat.");
ID[playerid] = -1;
}
return 1;
}
forward Check(playerid, pID, Float:X, Float:Y, Float:Z, Float:Angle, Float:Health, interior);
public Check(playerid, pID, Float:X, Float:Y, Float:Z, Float:Angle, Float:Health, interior)
{
new str[128];
if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xFF0000FF, "O jogador desconectou.");
new Float:P;
GetPlayerHealth(pID, P);
printf("DEBUG 2 - [id %d]: %f", pID, P);
if(floatcmp(P, Health) != 0) { SendClientMessage(playerid, 0xFFFF00FF, "O jogador nгo estб usando cheat."); }
else
{
GetPlayerName(pID, str, 24);
format(str, sizeof str, "O jogador %s [ID %d] pode estar usando cheat !", str, pID);
for(new i = 0; i < GetMaxPlayers(); i++)
{
if(!IsPlayerAdmin(i)) continue;
SendClientMessage(i, 0xDE0AFFFF, str);
}
}
SetPlayerHealth(pID, Health);
SetPlayerPos(pID, X, Y, Z);
SetPlayerInterior(pID, interior);
SetPlayerFacingAngle(pID, Angle);
SetCameraBehindPlayer(pID);
ID[playerid] = -1;
timer[playerid] = -1;
return 1;
}
// CASO NГO TENHA, ADICIONE AO SEU GM:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}