09.04.2015, 16:51
Hey there, i need a little help when ever i type /ban playername it says invalid id but it should ban the offline player instead its showing invalid id., here is the code:
Код:
CMD:ban(playerid,params[]) { if(IsMuted(playerid))return 1; new string[128],ID,reason[128]; if(AdminLevel[playerid] >=2) { if(!sscanf(params,"us[128]",ID,reason)) { if(!IsPlayerConnectedEx(ID)||ID==playerid)return SendClientMessage(playerid,GREY,"Invalid player ID"); if(strlen(reason) >128) return SendClientMessage(playerid,GREY,"Reason can't be longer than 100 characters"); if(AdminLevel[playerid]<AdminLevel[ID])return SendClientMessage(playerid,GREY,"You can't perform this command on your seniors"); format(string,sizeof(string),"~%s has been banned from the server for '%s'",PlayerName(ID),reason); SetCameraBehindPlayer(ID); INI_IntSet(Acc(ID),"Banned",1); INI_Set(Acc(ID),"Reason",reason); TogglePlayerControllable(ID,false); SendClientMessageToAll(RED,string); INI_Set(Acc(ID),"Banner",PlayerName(playerid)); Kicked[ID]=1; } else if(!sscanf(params,"u",ID)) { if(!IsPlayerConnectedEx(ID)||ID==playerid)return SendClientMessage(playerid,GREY,"Invalid player ID"); if(AdminLevel[playerid]<AdminLevel[ID])return SendClientMessage(playerid,GREY,"You can't perform this command on your seniors"); format(string,sizeof(string),"~%s has been banned from the server",PlayerName(ID)); SetCameraBehindPlayer(ID); INI_IntSet(Acc(ID),"Banned",1); INI_Set(Acc(ID),"Reason","N/A"); TogglePlayerControllable(ID,false); SendClientMessageToAll(RED,string); INI_Set(Acc(ID),"Banner",PlayerName(playerid)); Kicked[ID]=1; } else if(!sscanf(params,"s[50]",reason)) { new PlayerFile[50]; if(AdminLevel[playerid]<3)return 0; format(PlayerFile,sizeof(PlayerFile),"Accounts/%s.ini",reason); if(!fexist(PlayerFile)) return SendClientMessage(playerid,GREY,"No such player found in the database"); if(fexist(PlayerFile)) { if(INI_Int(PlayerFile,"Banned")==1)return SendClientMessage(playerid,GREY,"That player is already banned"); INI_IntSet(PlayerFile,"Banned",1); SendClientMessage(playerid,-1,"Account Banned"); INI_Set(PlayerFile,"Banner",PlayerName(playerid)); } }else return SendClientMessage(playerid,GREY,"USAGE: /ban [playerid] [reason]")&& SendClientMessage(playerid,-1,"USAGE: /ban [PlayerName] [For Offline Ban]"); }else return 0; return 1; }