SA-MP Forums Archive
Why am i getting this 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Why am i getting this error! (/showthread.php?tid=258877)



Why am i getting this error! - cloudysky - 01.06.2011

pawn Код:
error 017: undefined symbol "playerid"

pawn Код:
TextDrawShowForPlayer(playerid, BlackTD); // Error line



Re: Why am i getting this error! - shitbird - 01.06.2011

I'm going to take a wild guess, once again:
You're placing it under OnGameModeInit(), which is wrong.
You have to place it on a callback that contains the playerid parameter.. such as: OnPlayerSpawn/Connect/RequestSpawn(playerid).


Re: Why am i getting this error! - cloudysky - 01.06.2011

Thanks for the reply no here is where it is:

pawn Код:
public scavengetimer()
{
    TextDrawShowForPlayer(playerid, BlackTD);
    return 1;
}



Re: Why am i getting this error! - shitbird - 01.06.2011

Exactly, you're missing the playerid parameter.
Can you show me where you're calling this function? do you execute it with a timer?


Re: Why am i getting this error! - Hashski - 01.06.2011

pawn Код:
public scavengetimer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
       TextDrawShowForPlayer(i, BlackTD);
       return 1;
    }
}
Try that


Re: Why am i getting this error! - cloudysky - 01.06.2011

Quote:
Originally Posted by shitbird
Посмотреть сообщение
Exactly, you're missing the playerid parameter.
Can you show me where you're calling this function? do you execute it with a timer?
Yes it is in my scavenge command here:

pawn Код:
command(scavenge, playerid, params[])
{
    if(PlayerInfo[playerid][Srt] >= 1)
    {
        SendClientMessage(playerid, COLOUR_ORANGE, "Hint: You need to wait 10 minutes!" );
    }
    else
    {
        if(IsPlayerInRangeOfPoint(playerid, 100,637.3656, 838.5986, -42.9609))
        {
            {
                new string[ 128 ];

                format( string, sizeof( string ), "* %s has started to scavenge.", GetName( playerid ) );
                NearByMessage( playerid, COLOUR_YELLOW, string );
                SetTimer("scavengetimer",5000, false); //Here
                PlayerInfo[playerid][Srt] = 1;

                new rand = random(20);


                switch(rand)
                {
                    case 0, 3, 5, 7:
                    {
                        SendClientMessage(playerid, COLOUR_WHITE, "You found a Stimpack!");
                        PlayerInfo[playerid][Stimpack]++;
                    }
                    case 1, 4, 6, 8:
                    {
                        SendClientMessage(playerid, COLOUR_WHITE, "You found 300 caps!");
                    }
                    case 2, 10, 13, 16, 18, 15, 19:
                    {
                        SendClientMessage(playerid, COLOUR_WHITE, "Your hands are dirty but you find nothing!");
                    }
                    case 9, 11, 12, 14, 17:
                    {
                        SendClientMessage(playerid, COLOUR_WHITE, "You have found 100 scrap metal!");
                        PlayerInfo[playerid][Metal] += 100;
                    }
                }
            }
        }
    }
    return 1;
}
The idea is that the screen goes black and once it returns they "Find nothing" or "FInd a stimpack" using the random cases.



Quote:
Originally Posted by Hashski
Посмотреть сообщение
pawn Код:
public scavengetimer()
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
       TextDrawShowForPlayer(i, BlackTD);
       return 1;
    }
}
Try that
Thanks for the reply but wouldn't that make the screen black for everyone?


Re: Why am i getting this error! - shitbird - 01.06.2011

Use "SetTimerEx" to do that.
"SetTimer" is commonly used for functions that does something for everyone(by creating a loop through all playerids). -- Not for a single player.

pawn Код:
SetTimer("scavengetimer",5000, false); //Here
Change it to:
pawn Код:
SetTimerEx("scavengetimer", 5000, false, "i", playerid);
pawn Код:
public scavengetimer()
{
       TextDrawShowForPlayer(playerid, BlackTD);
       return true;
}
Change it to:
pawn Код:
public scavengetimer(playerid)
{
       TextDrawShowForPlayer(playerid, BlackTD);
       return true;
}



Re: Why am i getting this error! - cloudysky - 01.06.2011

Hmm thanks it solved the error but no textdraw is appearing?


Re: Why am i getting this error! - shitbird - 01.06.2011

Did you wait 5 seconds? :P
- Show me the Textdraw, and how you've created it.


Re: Why am i getting this error! - cloudysky - 01.06.2011

pawn Код:
new Text:BlackTD;
pawn Код:
public OnGameModeInit()
{
       BlackTD = TextDrawCreate(0.0, 0.0, "_");
    TextDrawUseBox(BlackTD, true);
    TextDrawColor(BlackTD, 0);
    TextDrawBoxColor(BlackTD, 0x00000000);