#1

PHP код:
CMD:a(playeridparams[]) {
    new 
string[128], Msg[128], pName[24];
    
GetPlayerName(playeridpNamesizeof(pName));
    if(
PlayerInfo[playerid][Level] >= 1)
    {
        if(
isnull(params)) return SendClientMessage(playeridred"USAGE: /a <Text>");
        if(
PlayerInfo[playerid][Level] == 1)
        {
            
format(string128"[Basic Moderator] {00FC00}%s: %s"pName(playerid), params); <<<<<<======== Error Line (2244)
            
MessageToAdmins(newblue1string);
            
format(Msg128"7[Basic Moderator] 9%s: %s"pName(playerid), params);
        }
        else if(
PlayerInfo[playerid][Level] == 2)
        {
            
format(string128"[Moderator] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_GREENstring);
            
format(Msg128"7[Moderator] 9%s: %s"pName(playerid), params);
         }
        else if(
PlayerInfo[playerid][Level] == 3)
        {
            
format(string128"[Master Moderator] {00FF00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_YELLOWstring);
            
format(Msg128"11[Master Moderator] 9%s: %s"pName(playerid), params);
              }
        else if(
PlayerInfo[playerid][Level] == 4)
        {
            
format(string128"[Administrator] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_ORANGEstring);
            
format(Msg128"11[Administrator] 9%s: %s"pName(playerid), params);
             }
        else if(
PlayerInfo[playerid][Level] == 5)
        {
            
format(string128"[Senior Admin] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(blue1string);
            
format(Msg128"12[Senior Admin] 9%s: %s"pName(playerid), params);
             }
        else if(
PlayerInfo[playerid][Level] == 6)
        {
            
format(string128"[Elite Admin] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_Silverstring);
            
format(Msg128"12[Elite Admin] 9%s: %s"pName(playerid), params);
             }
        else if(
PlayerInfo[playerid][Level] == 7)
        {
            
format(string128"[General] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(redstring);
            
format(Msg128"4[General] 9%s: %s"pName(playerid), params);
             }
        else if(
PlayerInfo[playerid][Level] == 8)
        {
            
format(string128"[Director] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(Color_Major_Elite1string);
            
format(Msg128"69[Director] 9%s: %s"pName(playerid), params);
        }
    } else return 
SendClientMessage(playeridred"ERROR: You need to be administrator to use this command");
    return 
1;

Код:
D:\Data\GTA\NZTDM\Gamemodes\NZTDM-1.pwn(2237) : warning 219: local variable "pName" shadows a variable at a preceding level
D:\Data\GTA\NZTDM\Gamemodes\NZTDM-1.pwn(2244) : error 012: invalid function call, not a valid address
D:\Data\GTA\NZTDM\Gamemodes\NZTDM-1.pwn(2244) : warning 215: expression has no effect
D:\Data\GTA\NZTDM\Gamemodes\NZTDM-1.pwn(2244) : error 001: expected token: ";", but found ")"
D:\Data\GTA\NZTDM\Gamemodes\NZTDM-1.pwn(2244) : error 029: invalid expression, assumed zero
D:\Data\GTA\NZTDM\Gamemodes\NZTDM-1.pwn(2244) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

Show or highlight those lines in the code.
Reply
#3

Try this:
PHP код:
stock pName(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnameMAX_PLAYER_NAME);
    return 
name;
}
CMD:a(playeridparams[])
{
    new 
string[128], Msg[128];
    if(
PlayerInfo[playerid][Level] >= 1)
    {
        if(
isnull(params)) return SendClientMessage(playeridred"USAGE: /a <Text>");
        if(
PlayerInfo[playerid][Level] == 1)
        {
            
format(string128"[Basic Moderator] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(newblue1string);
            
format(Msg128"7[Basic Moderator] 9%s: %s"pName(playerid), params);
        }
        else if(
PlayerInfo[playerid][Level] == 2)
        {
            
format(string128"[Moderator] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_GREENstring);
            
format(Msg128"7[Moderator] 9%s: %s"pName(playerid), params);
        }
        else if(
PlayerInfo[playerid][Level] == 3)
        {
            
format(string128"[Master Moderator] {00FF00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_YELLOWstring);
            
format(Msg128"11[Master Moderator] 9%s: %s"pName(playerid), params);
              }
        else if(
PlayerInfo[playerid][Level] == 4)
        {
            
format(string128"[Administrator] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_ORANGEstring);
            
format(Msg128"11[Administrator] 9%s: %s"pName(playerid), params);
             }
        else if(
PlayerInfo[playerid][Level] == 5)
        {
            
format(string128"[Senior Admin] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(blue1string);
            
format(Msg128"12[Senior Admin] 9%s: %s"pName(playerid), params);
        }
        else if(
PlayerInfo[playerid][Level] == 6)
        {
            
format(string128"[Elite Admin] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(COLOR_Silverstring);
            
format(Msg128"12[Elite Admin] 9%s: %s"pName(playerid), params);
        }
        else if(
PlayerInfo[playerid][Level] == 7)
        {
            
format(string128"[General] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(redstring);
            
format(Msg128"4[General] 9%s: %s"pName(playerid), params);
        }
        else if(
PlayerInfo[playerid][Level] == 8)
        {
            
format(string128"[Director] {00FC00}%s: %s"pName(playerid), params);
            
MessageToAdmins(Color_Major_Elite1string);
            
format(Msg128"69[Director] 9%s: %s"pName(playerid), params);
        }
    } else return 
SendClientMessage(playeridred"ERROR: You need to be administrator to use this command");
    return 
1;

Reply
#4

pName is shadowing a local variable, which means this is used globally in your script elsewhere.
The error message explains this literally: local variable "pName" shadows a variable at a preceding level.
Change pName to something else.

for example: GetName(playerid);

PHP код:
stock GetName(playerid)
{
    new 
name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    return 
name;

Reply
#5

PHP код:
CMD:a(playeridparams[]) { 
    new 
string[128], Msg[128]; 
    
GetPlayerName(playeridpNamesizeof(pName)); 
    if(
PlayerInfo[playerid][Level] >= 1
    { 
        if(
isnull(params)) return SendClientMessage(playeridred"USAGE: /a <Text>"); 
        if(
PlayerInfo[playerid][Level] == 1
        { 
            
format(string128"[Basic Moderator] {00FC00}%s: %s"pNameparams); <<<<<<======== Error Line (2244
            
MessageToAdmins(newblue1string); 
            
format(Msg128"7[Basic Moderator] 9%s: %s"pNameparams); 
        } 
        else if(
PlayerInfo[playerid][Level] == 2
        { 
            
format(string128"[Moderator] {00FC00}%s: %s"pNameparams); 
            
MessageToAdmins(COLOR_GREENstring); 
            
format(Msg128"7[Moderator] 9%s: %s"pNameparams); 
         } 
        else if(
PlayerInfo[playerid][Level] == 3
        { 
            
format(string128"[Master Moderator] {00FF00}%s: %s"pNameparams); 
            
MessageToAdmins(COLOR_YELLOWstring); 
            
format(Msg128"11[Master Moderator] 9%s: %s"pNameparams); 
              } 
        else if(
PlayerInfo[playerid][Level] == 4
        { 
            
format(string128"[Administrator] {00FC00}%s: %s"pNameparams); 
            
MessageToAdmins(COLOR_ORANGEstring); 
            
format(Msg128"11[Administrator] 9%s: %s"pNameparams); 
             } 
        else if(
PlayerInfo[playerid][Level] == 5
        { 
            
format(string128"[Senior Admin] {00FC00}%s: %s"pNameparams); 
            
MessageToAdmins(blue1string); 
            
format(Msg128"12[Senior Admin] 9%s: %s"pNameparams); 
             } 
        else if(
PlayerInfo[playerid][Level] == 6
        { 
            
format(string128"[Elite Admin] {00FC00}%s: %s"pNameparams); 
            
MessageToAdmins(COLOR_Silverstring); 
            
format(Msg128"12[Elite Admin] 9%s: %s"pNameparams); 
             } 
        else if(
PlayerInfo[playerid][Level] == 7
        { 
            
format(string128"[General] {00FC00}%s: %s"pNameparams); 
            
MessageToAdmins(redstring); 
            
format(Msg128"4[General] 9%s: %s"pNameparams); 
             } 
        else if(
PlayerInfo[playerid][Level] == 8
        { 
            
format(string128"[Director] {00FC00}%s: %s"pNameparams); 
            
MessageToAdmins(Color_Major_Elite1string); 
            
format(Msg128"69[Director] 9%s: %s"pNameparams); 
        } 
    } else return 
SendClientMessage(playeridred"ERROR: You need to be administrator to use this command"); 
    return 
1

Reply
#6

Use this.

Код:
CMD:a(playerid, params[]) { 
    new string[128], Msg[128], stringName[24]; 
    GetPlayerName(playerid, stringName, sizeof(stringName)); 
    if(PlayerInfo[playerid][Level] >= 1) 
    { 
        if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /a <Text>"); 
        if(PlayerInfo[playerid][Level] == 1) 
        { 
            format(string, 128, "[Basic Moderator] {00FC00}%s: %s", stringName, params); <<<<<<======== Error Line (2244) 
            MessageToAdmins(newblue1, string); 
            format(Msg, 128, "7[Basic Moderator] 9%s: %s", stringName, params); 
        } 
        else if(PlayerInfo[playerid][Level] == 2) 
        { 
            format(string, 128, "[Moderator] {00FC00}%s: %s", stringName, params); 
            MessageToAdmins(COLOR_GREEN, string); 
            format(Msg, 128, "7[Moderator] 9%s: %s", stringName, params); 
         } 
        else if(PlayerInfo[playerid][Level] == 3) 
        { 
            format(string, 128, "[Master Moderator] {00FF00}%s: %s", stringName, params); 
            MessageToAdmins(COLOR_YELLOW, string); 
            format(Msg, 128, "11[Master Moderator] 9%s: %s", stringName, params); 
              } 
        else if(PlayerInfo[playerid][Level] == 4) 
        { 
            format(string, 128, "[Administrator] {00FC00}%s: %s", stringName, params); 
            MessageToAdmins(COLOR_ORANGE, string); 
            format(Msg, 128, "11[Administrator] 9%s: %s", stringName, params); 
             } 
        else if(PlayerInfo[playerid][Level] == 5) 
        { 
            format(string, 128, "[Senior Admin] {00FC00}%s: %s", stringName, params); 
            MessageToAdmins(blue1, string); 
            format(Msg, 128, "12[Senior Admin] 9%s: %s", stringName, params); 
             } 
        else if(PlayerInfo[playerid][Level] == 6) 
        { 
            format(string, 128, "[Elite Admin] {00FC00}%s: %s", stringName, params); 
            MessageToAdmins(COLOR_Silver, string); 
            format(Msg, 128, "12[Elite Admin] 9%s: %s", stringName, params); 
             } 
        else if(PlayerInfo[playerid][Level] == 7) 
        { 
            format(string, 128, "[General] {00FC00}%s: %s", stringName, params); 
            MessageToAdmins(red, string); 
            format(Msg, 128, "4[General] 9%s: %s", stringName, params); 
             } 
        else if(PlayerInfo[playerid][Level] == 8) 
        { 
            format(string, 128, "[Director] {00FC00}%s: %s", stringName, params); 
            MessageToAdmins(Color_Major_Elite1, string); 
            format(Msg, 128, "69[Director] 9%s: %s", stringName, params); 
        } 
    } else return SendClientMessage(playerid, red, "ERROR: You need to be administrator to use this command"); 
    return 1; 
}
You need to decide. Or u use
Код:
new stringName[24]; 
GetPlayerName(playerid, stringName, sizeof(stringName));
on every local script, or u can create a pName stock in global
Код:
stock pName(playerid) // pName or whatever u want to call your stock to use it.
{
     new stringName[24]; 
     GetPlayerName(playerid, stringName, sizeof(stringName)); 
     return stringName;
}
then u can use it everywhere.

But u can't use both methods with same names function-string!

I hope u undestood.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)