undefined symbol "playerid"
#1

Hello,

Im getting this error:
pawn Код:
(912) : error 017: undefined symbol "playerid"
with
pawn Код:
public OnGameModeInit()
{
    Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[playerid][Kills]);
    TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
    TextDrawAlignment(Textdraw14, 1);
    TextDrawColor(Textdraw14, -1);
    TextDrawSetShadow(Textdraw14, 0);
    TextDrawSetOutline(Textdraw14, 1);
    TextDrawBackgroundColor(Textdraw14, 51);
    TextDrawFont(Textdraw14, 1);
    TextDrawSetProportional(Textdraw14, 1);
        return 1;
}
i know its because playerid isnt in ongamemodeinit but where should i put this then?
Reply
#2

pawn Код:
Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~0");
When it's about to show the textdraw to a player use TextDrawSetString to show the kills.
Reply
#3

So how do i do that ?
Reply
#4

Use this
pawn Код:
forward UpdateTextDraw14(playerid);

new Text:Textdraw14[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    Textdraw14[playerid] = TextDrawCreate(501.714233, 102.400001,"-");
    TextDrawLetterSize(Textdraw14[playerid], 0.362760, 1.382398);
    TextDrawAlignment(Textdraw14[playerid], 1);
    TextDrawColor(Textdraw14[playerid], -1);
    TextDrawSetShadow(Textdraw14[playerid], 0);
    TextDrawSetOutline(Textdraw14[playerid], 1);
    TextDrawBackgroundColor(Textdraw14[playerid], 51);
    TextDrawFont(Textdraw14[playerid], 1);
    TextDrawSetProportional(Textdraw14[playerid], 1);

    TextDrawShowForPlayer(playerid,Textdraw14[playerid]);

    SetTimer("UpdateTextDraw14",1000,true);
    return 1;
}

public UpdateTextDraw14(playerid)
{
    new string[128];
    format(string,sizeof(string),"Kills: ~w~%d", pInfo[playerid][Kills]);
    TextDrawSetString(Textdraw14[playerid],string);
    return 1;
}
Reply
#5

use TextDrawSetString or PlayerTextDrawSetString
Reply
#6

You could put a loop inside OnGameModeInit

Like this
pawn Код:
public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Non #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[playerid][Kills]);
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}

public OnGameModeInit()
{
    foreach(Player, i) // With #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[playerid][Kills]);
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}
Reply
#7

Quote:
Originally Posted by pds2012
Посмотреть сообщение
You could put a loop inside OnGameModeInit

Like this
pawn Код:
public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Non #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[playerid][Kills]);
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}

public OnGameModeInit()
{
    foreach(Player, i) // With #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[playerid][Kills]);
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}
You wrong... If you that it just undefined symbol "playerid"

You must change this

pawn Код:
public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Non #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[i][Kills]);// "playerid" to "i"
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by xganyx
Посмотреть сообщение
You wrong... If you that it just undefined symbol "playerid"

You must change this

pawn Код:
public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Non #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[i][Kills]);// "playerid" to "i"
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}
Alright, I aplogize, I just forgot to change 1 integer. thanks for correcting me though.
Reply
#9

And this is wrong to must do it like me... Don't need to loop

I read on samp wiki is

pawn Код:
TextDrawCreate(Float:x, Float:y, text[]);
Don't have Float:... so my way is right... We must to put it under OnPlayerConnect and format it... Like my code

Quote:
Originally Posted by xganyx
Посмотреть сообщение
Use this
pawn Код:
forward UpdateTextDraw14(playerid);

new Text:Textdraw14[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    Textdraw14[playerid] = TextDrawCreate(501.714233, 102.400001,"-");
    TextDrawLetterSize(Textdraw14[playerid], 0.362760, 1.382398);
    TextDrawAlignment(Textdraw14[playerid], 1);
    TextDrawColor(Textdraw14[playerid], -1);
    TextDrawSetShadow(Textdraw14[playerid], 0);
    TextDrawSetOutline(Textdraw14[playerid], 1);
    TextDrawBackgroundColor(Textdraw14[playerid], 51);
    TextDrawFont(Textdraw14[playerid], 1);
    TextDrawSetProportional(Textdraw14[playerid], 1);

    TextDrawShowForPlayer(playerid,Textdraw14[playerid]);

    SetTimer("UpdateTextDraw14",1000,true);
    return 1;
}

public UpdateTextDraw14(playerid)
{
    new string[128];
    format(string,sizeof(string),"Kills: ~w~%d", pInfo[playerid][Kills]);
    TextDrawSetString(Textdraw14[playerid],string);
    return 1;
}
Not like this

pawn Код:
public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Non #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[i][Kills]);// "playerid" to "i"
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}
Reply
#10

Quote:
Originally Posted by xganyx
Посмотреть сообщение
And this is wrong to must do it like me... Don't need to loop

I read on samp wiki is

pawn Код:
TextDrawCreate(Float:x, Float:y, text[]);
Don't have Float:... so my way is right... We must to put it under OnPlayerConnect and format it... Like my code



Not like this

pawn Код:
public OnGameModeInit()
{
    for(new i = 0; i < MAX_PLAYERS; i++) // Non #include <foreach>
    {
        Textdraw14 = TextDrawCreate(501.714233, 102.400001, "Kills: ~w~%d", pInfo[i][Kills]);// "playerid" to "i"
        TextDrawLetterSize(Textdraw14, 0.362760, 1.382398);
        TextDrawAlignment(Textdraw14, 1);
        TextDrawColor(Textdraw14, -1);
        TextDrawSetShadow(Textdraw14, 0);
        TextDrawSetOutline(Textdraw14, 1);
        TextDrawBackgroundColor(Textdraw14, 51);
        TextDrawFont(Textdraw14, 1);
        TextDrawSetProportional(Textdraw14, 1);
    }
    return 1;
}
It doesn't really matter to be honest, I won't argue with you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)