/offlineban help
#4

PHP код:
CMD:offlineban(playeridparams[], help)
{
    if(
help)
    {
        
SendClientMessage(playeridCOLOR_WHITE"{AFAFAF}Command /offlineban: {FFFFFF}Bans a player who is offline.");
    }
    else
    {
        if(
pInfo[playerid][pLogged] == 0) return 0;
        if(
pInfo[playerid][pAdminLevel] >= 4)
        {
            new 
string[158], reason[120], targetname[MAX_PLAYER_NAME], filestring[79], sendername[MAX_PLAYER_NAME]; // sendername needed to be declared
            
if(sscanf(params"s[24]s[120]"targetnamereason)) return SendClientMessage(playeridCOLOR_WHITE"{AFAFAF}Syntax: {FFFFFF}/offlineban [fullname] [reason]");
            
GetPlayerName(playeridsendernamesizeof(sendername)); // Here in this line is where I throw the error.
            
format(filestringsizeof(filestring), "/ZMA/Users/%s.ini"targetname);
            if(!
fexist(filestring)) return SendClientMessage(playeridCOLOR_WHITE"{AFAFAF}Error: {FFFFFF}Player doesn't exist.");
            else
            {
                new 
INI:File INI_Open(filestring));
                
INI_SetTag(File"data");
                
INI_RemoveEntry(File"Banned");
                
INI_WriteInt(File"Banned"1);
                
INI_Close(File);
                
format(stringsizeof(string),"{FF6347}Admin %s banned the offline player %s, reason: %s"sendernametargetnamereason);
                
SendClientMessageToAll(COLOR_WHITEstring);
            }
        } else return 
SendClientMessage(playeridCOLOR_WHITEMinimumAdmin1); // {} + return SendClientMessage
    
}
    return 
1;

You did not declared "sendername". Also, prefer to put MAX_PLAYER_NAME instead of 24.
{} can be avoided if you have only one line after the condition. You can return SendClientMessage because SendClientMessage return 1 if the player is connected and when you type a command, you are connected to the server so it will return 1.
Reply


Messages In This Thread
/offlineban help - by TFG - 08.08.2017, 17:43
Re: /offlineban help - by RedGun2015 - 08.08.2017, 17:50
Re: /offlineban help - by TFG - 08.08.2017, 17:52
Re: /offlineban help - by Dayrion - 08.08.2017, 18:14
Re: /offlineban help - by TFG - 08.08.2017, 18:22

Forum Jump:


Users browsing this thread: 1 Guest(s)