/offlineban help
#1

Hello, I need help, I create a command to ban offline, but it gives me an error maybe they could help me.

Код:
CMD:offlineban(playerid, params[], help)
{
	if(help)
	{
	    SendClientMessage(playerid, COLOR_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[24], filestring[79];
	        if(sscanf(params, "s[24]s[120]", targetname, reason)) return SendClientMessage(playerid, COLOR_WHITE, "{AFAFAF}Syntax: {FFFFFF}/offlineban [fullname] [reason]");
			GetPlayerName(playerid, sendername, sizeof(sendername)); // Here in this line is where I throw the error.
			format(filestring, sizeof(filestring), "/ZMA/Users/%s.ini", targetname);
		    if(!fexist(filestring)) return SendClientMessage(playerid, COLOR_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(string, sizeof(string),"{FF6347}Admin %s banned the offline player %s, reason: %s", sendername, targetname, reason);
		        SendClientMessageToAll(COLOR_WHITE, string);
			}
		} else { SendClientMessage(playerid, COLOR_WHITE, ""MinimumAdmin1""); return 1; }
	}
	return 1;
}


The error

Код:
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3427) : error 017: undefined symbol "sendername"
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3427) : error 017: undefined symbol "sendername"
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3427) : error 029: invalid expression, assumed zero
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3427) : fatal error 107: too many error messages on one line
Reply
#2

Код HTML:
new sendername[MAX_PLAYER_NAME];
Reply
#3

Quote:
Originally Posted by RedGun2015
Посмотреть сообщение
Код HTML:
new sendername[MAX_PLAYER_NAME];
Above what I put?
Reply
#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
#5

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
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.
Error compiling

Error
Код:
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3440) : error 001: expected token: "-string end-", but found "-identifier-"
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3440) : error 017: undefined symbol "MinimumAdmin1"
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3440) : warning 215: expression has no effect
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3440) : error 001: expected token: ";", but found ")"
D:\Program Files\PROYECTO GM ZOMBIE PROXIMAMENTE - ASISTENTES JANSELK THORO DEAD MAU SREMMURD\Zombie Nightmare\gamemodes\zmazombie.pwn(3440) : fatal error 107: too many error messages on one line
Line
Код:
Line 3432: new INI:File = INI_Open(filestring));

Line 3440:  } else return SendClientMessage(playerid, COLOR_WHITE, ""MinimumAdmin1""); return 1; } // {} + return SendClientMessage
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)