12.07.2011, 20:11
Command fixed:
And put this at the bottom of you GM:
PHP код:
if(strcmp(cmd, "/report", true) == 0)
{
new str[256], idx, n[24], n2[24];
str = strtok(cmdtext, idx);
new length = strlen(cmdtext);
while ((idx < length) && (cmdtext[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[96];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = cmdtext[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result) || !strlen(str)) return SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /report [id] [reason]");
if(!IsPlayerConnected(strval(str)) || strval(str) == INVALID_PLAYER_ID) return SendClientMessage(plaeyrid, 0xFF0000FF, "INVALID ID.");
GetPlayerName(playerid, n, 24);
GetPlayerName(strval(str), n2, 24);
format(str, sizeof str, "%s [%d] was reported by %s [%d] | Reason: %s", n2, strval(str), str, playerid, result);
for(new i = 0; i < MAX_PLAYERS; i ++) { if(IsPlayerAdmin(i)) SendClientMessage(i, 0xFFFF00FF, str); }
SendClientMessage(playerid, 0xFFFF00FF, "Your report message was sent to online administrators, thank you.");
return 1;
}
PHP код:
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;
}