i put a command and a stock
i show the script
THE STOCK
pawn Код:
stock strrest(const str[], &index)
{
new length = strlen(str);
while ((index < length) && (str[index] <= ' '))
{
index++;
}
new offset = index;
new result[128];
while ((index < length) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = str[index];
index++;
}
result[index - offset] = EOS;
return result;
}
THE COMMAND
pawn Код:
if (strcmp("/playerban", cmdtext, true, 10) == 0)//Solo per admin//if(IsPlayerAdmin(playerid) == 1)
{
if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, 0xEB000FFF, "ERRORE: Devi essere loggato per usare questo comando");
if(level[playerid] >= 5)
{
new playername[MAX_PLAYER_NAME];
new name[MAX_PLAYER_NAME];
//new pip[MAX_PLAYER_NAME];
new pid;
tmp = strtok(cmdtext,idx);
if(!strlen(tmp))
{
SendClientMessage(playerid,0xFF8A00AA,"Utilizzo: /playerban [playerid][motivo]");
return 1;
}
gMessage = strrest(cmdtext,idx);
if(!strlen(gMessage)) {
SendClientMessage(playerid,COLOR_ROSSO,"Non hai messo un motivo (Obbligatorio)");
return 1;
}
pid = strval(tmp);
if(!IsPlayerConnected(pid))
{
SendClientMessage(playerid,0xEB000FFF,"Questo giocatore non e' connesso");
PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
return 1;
}
if(IsPlayerAdmin(pid) == 1)
{
SendClientMessage(playerid,0xEB000FFF,"Non puoi bannare questo admin perche e di livello superiore");
PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
return 1;
}
new string[256];
GetPlayerName(pid,playername,sizeof(playername));
GetPlayerName(playerid,name, sizeof(name));
//GetPlayerIp(pid, pip, sizeof(pip));
format(string,sizeof(string),"SERVER: %s has been banned from the server by administrator %s .(Motivo: %s )",playername,name,gMessage);
SendClientMessageToAll(0xFFFF00AA,string);
SendClientMessage(pid,0xEB000FFF,"Sei stato bannato dal server!!");
//printf("[BAN] %s has been banned by %s (IP:%s)",playername, name, pip);
Ban(pid);
return 1;
} else return SendClientMessage(playerid,0xEB000FFF,"ERRORE:Devi essere un admin liv 5 per usare questo comando"),PlayerPlaySound(playerid,1085,0.0,0.0,0.0);
}