06.05.2011, 21:14
Hello, I got a problem with my /ban cmd. When i do /ban, And dont write a name/id and a reason.
It says: 65923(Some Random Number) Is not a active player.
This is my /ban cmd!
How can i fix this?
Regards, Alex
EDIT: This is what happends:
It says: 65923(Some Random Number) Is not a active player.
This is my /ban cmd!
pawn Код:
CMD:ban(playerid,params[])
{
new string[128];
new sendername[MAX_PLAYER_NAME];
new tmp[256];
new idx;
new giveplayerid;
new giveplayer[MAX_PLAYER_NAME];
if(IsPlayerConnected(playerid))
{
tmp = strtok(params, idx);
if(!strlen(tmp))
{
SendClientMessage(playerid, RED, "[LOST:RP] /ban [ID] [REASON]");
return 1;
}
giveplayerid = ReturnUser(tmp);
if(IsPlayerNPC(giveplayerid)) return 1;
if(PlayerInfo[playerid][pAdmin] >= 2)
{
if(IsPlayerConnected(giveplayerid))
{
if(giveplayerid != INVALID_PLAYER_ID)
{
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
new length = strlen(params);
while ((idx < length) && (params[idx] <= ' '))
{
idx++;
}
new offset = idx;
new result[96];
while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
{
result[idx - offset] = params[idx];
idx++;
}
result[idx - offset] = EOS;
if(!strlen(result))
{
SendClientMessage(playerid, RED, "[LOST:RP] /ban [ID] [REASON]");
return 1;
}
format(string, 128, "[LOST:RP] [ADMIN]: %s has banned %s! Reason: %s", sendername, giveplayer, (result));
SendClientMessageToAll(RED, string);
Ban(giveplayerid);
new Hour, Minute, Second;
gettime(Hour, Minute, Second);
format(string,sizeof(string),"[%02d:%02d:%02d]%s has banned %s! Reason:%s",Hour,Minute,Second,sendername,giveplayer, (result));
SaveIn("BanLog.txt",string);
}
}
else
{
format(string, sizeof(string), "[LOST:RP] %d is not a active player", giveplayerid);
SendClientMessage(playerid, RED, string);
}
}
else
{
SendClientMessage(playerid, RED, "[LOST:RP] You are not a admin, Or you are a to low one");
}
}
return 1;
}
Regards, Alex
EDIT: This is what happends: