18.03.2012, 18:33
pawn Код:
CMD:makeadmin(playerid, params[])
{
new cmd[256];
new index;
cmd = strtok(cmdtext, index);
if(!strcmp(cmd, "/makeadmin", true))
{
if(IsPlayerAdmin(playerid) || aLevel[playerid] == 2) // You must be RCon logged or aLevel 2 to make someone an admin
{
new param1[256];
param1 = strtok(cmdtext, index);
new param2[256];
param2 = strtok(cmdtext, index);
new player = strval(param1);
new level = strval(param2);
if(!IsPlayerConnected(player)) return 0;
if(level < 0 || level > 2) return 0;
aLevel[player] = level;
SendClientMessage(playerid, 0x00FF00FF, "You have made this player an admin.");
SendClientMessage(player, 0x00FF00FF, "You are now an admin.");
}
}
return 1;
}
stock 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;
}