27.06.2011, 01:09
PHP код:
new Aviso[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
Aviso[playerid] = 0;
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(strcmp(cmd, "/aviso", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /aviso [ID] [MOTIVO]");
new id;
id = ReturnUser(tmp);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)) return SendClientMessage(playerid, -1, "USO: /aviso [ID] [MOTIVO]");
if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "ID INVALIDO");
new string[256], n[24], n2[24];
GetPlayerName(id, n, 24);
GetPlayerName(playerid, n2, 24);
format(string, 128, "Vocк advertiu o jogador %s [ID: %d] | Motivo: %s.", n, id, result);
SendClientMessage(playerid, -1, string);
format(string, 128, "Vocк foi advertido pelo administrador %s [ID %d] | Motivo: %s.", n2, playerid, result);
SendClientMessage(id, -1, string);
format(string, 128, "O ADMIN %s advertiu no jogador %s | Motivo: %s.", n2, n, result);
SendClientMessageToAll(-1, string);
Aviso[id]++;
if(Aviso[id] == 3)
{
format(string, 128, "O jogador %s [ID: %d] foi kickado.| Motivo: 3 ADVERTENCIAS", n, id);
SendClientMessageToAll(-1, string);
Kick(id);
}
return 1;
}
if(strcmp(cmd, "/tiraraviso", true) == 0)
{
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, -1, "USO: /tiraraviso [ID] [MOTIVO]");
new id;
id = ReturnUser(tmp);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[64];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result)) return SendClientMessage(playerid, -1, "USO: /tiraraviso [ID] [MOTIVO]");
if(!IsPlayerConnected(id) || id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "ID INVALIDO");
new string[256], n[24], n2[24];
GetPlayerName(id, n, 24);
GetPlayerName(playerid, n2, 24);
format(string, 128, "Vocк retirou um aviso do jogador %s [ID: %d] | Motivo: %s.", n, id, result);
SendClientMessage(playerid, -1, string);
format(string, 128, "O ADMIN %s retirou um aviso do jogador %s | Motivo: %s.", n2, n, result);
SendClientMessageToAll(-1, string);
if(Aviso[id] > 0) { Aviso[id]--; }
return 1;
}
return 0;
}