SA-MP Forums Archive
Error - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Error (/showthread.php?tid=654018)



Error - Filbert - 19.05.2018

PHP код:
new alabel[MAX_PLAYERS];
CMD:adminlabel(playeridparams[]) {
    if(
alabel[playerid] == 0)
    {
        if(
PlayerInfo[playerid][Level] == 1)
        {
            
Label[playerid] = Create3DTextLabel("Basic Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 2)
        {
            
Label[playerid] = Create3DTextLabel("Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 3)
        {
            
Label[playerid] = Create3DTextLabel("Master Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 4)
        {
            
Label[playerid] = Create3DTextLabel("Administrator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 5)
        {
            
Label[playerid] = Create3DTextLabel("Master Admin"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 6)
        {
            
Label[playerid] = Create3DTextLabel("Elite Admin"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 7)
        {
            
Label[playerid] = Create3DTextLabel("General"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 8)
        {
            
Label[playerid] = Create3DTextLabel("Director"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
IsPlayerAdmin(playerid))
        {
            
Label[playerid] = Create3DTextLabel("RCON Admin"0xFF0000FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
    }
    else
    {
        if(
alabel[playerid] == 1)
        {
            
Delete3DTextLabel(Text3D:Label[playerid]);
            
SendClientMessage(playeridred"Admin Label disabled!");
            
alabel[playerid] = 0;
        }
    } else return 
SendClientMessage(playeridred"ERROR: You need to be admin to use this command");
    return 
1;

Код:
D:\SA-MP Servers\NZTDM\Gamemodes\NZTDM-1.pwn(36305) : error 029: invalid expression, assumed zero
D:\SA-MP Servers\TestServer\Gamemodes\TestServer.pwn(36305) : warning 215: expression has no effect
D:\SA-MP Servers\TestServer\Gamemodes\TestServer.pwn(36305) : error 001: expected token: ";", but found "return"
D:\SA-MP Servers\TestServer\Gamemodes\TestServer.pwn(36306) : warning 225: unreachable code
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.



Re: Error - JasonRiggs - 19.05.2018

This line doesn't make sense..

Quote:

} else return SendClientMessage(playerid, red, "ERROR: You need to be admin to use this command");
return 1;

You didn't even add the case of is player an admin to add its "else", Also why did you put "else" just beside "}"


Re: Error - Filbert - 19.05.2018

can you give me the codes?


Re: Error - JasonRiggs - 19.05.2018

PHP код:
new alabel[MAX_PLAYERS];

CMD:adminlabel(playeridparams[]) {
    if(
alabel[playerid] == 0)
    {
        if(!
PlayerInfo[playerid][Level]) return SendClientMessage(playeridred"ERROR: You need to be admin to use this command");
        if(
PlayerInfo[playerid][Level] == 1)
        {
            
Label[playerid] = Create3DTextLabel("Basic Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 2)
        {
            
Label[playerid] = Create3DTextLabel("Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 3)
        {
            
Label[playerid] = Create3DTextLabel("Master Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 4)
        {
            
Label[playerid] = Create3DTextLabel("Administrator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 5)
        {
            
Label[playerid] = Create3DTextLabel("Master Admin"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 6)
        {
            
Label[playerid] = Create3DTextLabel("Elite Admin"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 7)
        {
            
Label[playerid] = Create3DTextLabel("General"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 8)
        {
            
Label[playerid] = Create3DTextLabel("Director"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
IsPlayerAdmin(playerid))
        {
            
Label[playerid] = Create3DTextLabel("RCON Admin"0xFF0000FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
    }
    else
    {
        if(
alabel[playerid] == 1)
        {
            
Delete3DTextLabel(Text3D:Label[playerid]);
            
SendClientMessage(playeridred"Admin Label disabled!");
            
alabel[playerid] = 0;
        }
    } 
    return 
1;

there you go


Re: Error - GTLS - 19.05.2018

Quote:
Originally Posted by JasonRiggs
Посмотреть сообщение
PHP код:
new alabel[MAX_PLAYERS];
CMD:adminlabel(playeridparams[]) {
    if(
alabel[playerid] == 0)
    {
        if(!
PlayerInfo[playerid][Level]) return SendClientMessage(playeridred"ERROR: You need to be admin to use this command");
        if(
PlayerInfo[playerid][Level] == 1)
        {
            
Label[playerid] = Create3DTextLabel("Basic Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 2)
        {
            
Label[playerid] = Create3DTextLabel("Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 3)
        {
            
Label[playerid] = Create3DTextLabel("Master Moderator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 4)
        {
            
Label[playerid] = Create3DTextLabel("Administrator"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 5)
        {
            
Label[playerid] = Create3DTextLabel("Master Admin"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 6)
        {
            
Label[playerid] = Create3DTextLabel("Elite Admin"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 7)
        {
            
Label[playerid] = Create3DTextLabel("General"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
PlayerInfo[playerid][Level] == 8)
        {
            
Label[playerid] = Create3DTextLabel("Director"0x00FF00FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
        else if(
IsPlayerAdmin(playerid))
        {
            
Label[playerid] = Create3DTextLabel("RCON Admin"0xFF0000FF0.00.00.040.00);
            
Attach3DTextLabelToPlayer(Label[playerid], playerid0.00.00.3);
            
SendClientMessage(playeridblue"Admin Label enabled!");
            
CMDMessageToAdmins(playerid"ADMINLABEL");
            
alabel[playerid] = 1;
        }
    }
    else
    {
        if(
alabel[playerid] == 1)
        {
            
Delete3DTextLabel(Text3D:Label[playerid]);
            
SendClientMessage(playeridred"Admin Label disabled!");
            
alabel[playerid] = 0;
        }
    } 
    return 
1;

there you go
You code should work.

Although, writing else along with '}' is not the cause of error. the error came because he had no added if(PlayerInfo[playerid][Level]) condition at the top.