SA-MP Forums Archive
Another help with undefine symbol - 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: Another help with undefine symbol (/showthread.php?tid=429734)



Another help with undefine symbol - RiChArD_A - 11.04.2013

here are the errors:
Код:
.pwn(1591) : error 017: undefined symbol "Playername"
.pwn(1598) : error 017: undefined symbol "Playername"
.pwn(1605) : error 017: undefined symbol "Playername"
.pwn(1612) : error 017: undefined symbol "Playername"
.pwn(1620) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

4 Errors.
Here is the CMD
pawn Код:
CMD:admins(playerid, params[])
{
        new admins[128];
        if(IsPlayerConnected(playerid))
        {
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    if(PlayerInfo[i][AdminLevel] == 1)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{0000A0}Moderator: {FFFFFF}%s\n", Playername(i));
                        strcat(admins, adminstring);
                    }

                    else if(PlayerInfo[i][AdminLevel] == 2)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{0000A0}Administrator: {FFFFFF}%s\n", Playername(i));
                        strcat(admins, adminstring);
                    }

                    else if(PlayerInfo[i][AdminLevel] == 3)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{0000A0}Management: {FFFFFF}%s\n", Playername(i));
                        strcat(admins, adminstring);
                    }

                    else if(PlayerInfo[i][AdminLevel] == 4)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{FF0000}Owner: {FFFFFF}%s\n", Playername(i));
                        strcat(admins, adminstring);
                    }
                }
            }
            ShowPlayerDialog(playerid,1359,DIALOG_STYLE_MSGBOX,"{FF3300}Admins Online",admins,"Ok","");
        }
        else return SendClientMessage(playerid,-1,"No admins online.");
    return 1;
}



Re: Another help with undefine symbol - stabker - 11.04.2013

The simplest solution

pawn Код:
CMD:admins(playerid, params[])
{
        new admins[128], _name[MAX_PLAYER_NAME];
        if(IsPlayerConnected(playerid))
        {
            for (new i = 0; i < MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    GetPlayerName(i, _name, sizeof _name);
                    if(PlayerInfo[i][AdminLevel] == 1)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{0000A0}Moderator: {FFFFFF}%s\n", _name);
                        strcat(admins, adminstring);
                    }

                    else if(PlayerInfo[i][AdminLevel] == 2)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{0000A0}Administrator: {FFFFFF}%s\n", _name);
                        strcat(admins, adminstring);
                    }

                    else if(PlayerInfo[i][AdminLevel] == 3)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{0000A0}Management: {FFFFFF}%s\n", _name);
                        strcat(admins, adminstring);
                    }

                    else if(PlayerInfo[i][AdminLevel] == 4)
                    {
                        new adminstring[256];
                        format(adminstring, sizeof(adminstring),"{FF0000}Owner: {FFFFFF}%s\n", _name);
                        strcat(admins, adminstring);
                    }
                }
            }
            ShowPlayerDialog(playerid,1359,DIALOG_STYLE_MSGBOX,"{FF3300}Admins Online",admins,"Ok","");
        }
        else return SendClientMessage(playerid,-1,"No admins online.");
    return 1;
}



Re: Another help with undefine symbol - Pottus - 11.04.2013

His Playername function is probably actually PlayerName()


Re: Another help with undefine symbol - FunnyBear - 11.04.2013

Add this to your script:

pawn Код:
stock Playername(playerid)
{
    new Name[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME + 1);
    return Name;
}
Hope I helped


Re: Another help with undefine symbol - RiChArD_A - 11.04.2013

Quote:
Originally Posted by FunnyBear
Посмотреть сообщение
Add this to your script:

pawn Код:
stock Playername(playerid)
{
    new Name[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, Name, MAX_PLAYER_NAME + 1);
    return Name;
}
Hope I helped
Thanks!

Thank you everyone.


Re: Another help with undefine symbol - RiChArD_A - 11.04.2013

[BACK]
No, it isn't showing the names. Help.


Re: Another help with undefine symbol - RiChArD_A - 12.04.2013

Please someone


Re: Another help with undefine symbol - MP2 - 12.04.2013

Quote:
Originally Posted by ******
Посмотреть сообщение
You don't need "+ 1" the point of "MAX_PLAYER_NAME" is that it is the maximum (that being the meaning of "MAX") that the variable needs to be. You are explicitly declaring a variable as bigger than it ever needs to be.
What about the null-terminator?


Re: Another help with undefine symbol - MP2 - 12.04.2013

I just tested this as I didn't believe you, but you're right. I can't see how this is possible though? If there's a 24 character name, and 24 cells, each with a character, where is the null-terminator going?

EDIT: Oh wait, is it because the string is size 24, it doesn't need a null-terminator to know when the string ends?


Re: Another help with undefine symbol - MP2 - 12.04.2013

Yes you can:

pawn Код:
public OnPlayerConnect(playerid)
{
    new set_name[] = "123456789012345678901234";
    SetPlayerName(playerid, set_name);
   
    printf("Setting name length: %i", strlen(set_name));
   
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
   
    printf("GetPlayerName: %s (%i)", name, strlen(name));
    return 1;
}
Output:

[14:06:40] [nick] Mike nick changed to 123456789012345678901234
[14:06:40] Setting name length: 24
[14:06:40] GetPlayerName: 123456789012345678901234 (24)




But oddly, if I do this:

pawn Код:
new set_name[] = "123456789012345678901234";
   
printf("Len: %i", sizeof(set_name));
It's 25 cells..

And
pawn Код:
new set_name[24] = "123456789012345678901234";
Throws an error: initialization data exceeds declared size.

Very odd.



EDIT2: Tried format()..

pawn Код:
new set_name[24];
format(set_name, sizeof(set_name), "123456789012345678901234");
print(set_name);
Cuts off the final character ('4'). I find it odd how GetPlayerName doesn't need a null-terminator.