Help please
#1

Hey all. I made a timer that updates a few things but when I use the update for my textdraw it doesnt show my score but someone elses score.
How to fix?

pawn Код:
public threetimer(playerid)
{
    new text[10];
    format(text, sizeof(text), "%d",PlayerInfo[playerid][pScore]);
    TextDrawSetString(Textdraw1, text);
    SetPlayerMoney(playerid,PlayerInfo[playerid][pCash]);
    SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
   
    return 1;
}
Reply
#2

You need some kind of for loop.
Reply
#3

You only have one textdraw for many players? Shouldn't:

pawn Код:
TextDrawSetString(Textdraw1, text);
be something like

pawn Код:
TextDrawSetString(Textdraw1[playerid], text);
Reply
#4

You can try this. I don't know if it will work tho.
pawn Код:
public threetimer(playerid)
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        new text[10];
        format(text, sizeof(text), "%d",PlayerInfo[i][pScore]);
        TextDrawSetString(Textdraw1, text);
        SetPlayerMoney(playerid,PlayerInfo[i][pCash]);
        SetPlayerScore(playerid,PlayerInfo[i][pScore]);
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by futuretrucker
Посмотреть сообщение
You can try this. I don't know if it will work tho.
pawn Код:
public threetimer(playerid)
{
    for(new i; i<MAX_PLAYERS; i++)
    {
        new text[10];
        format(text, sizeof(text), "%d",PlayerInfo[i][pScore]);
        TextDrawSetString(Textdraw1, text);
        SetPlayerMoney(playerid,PlayerInfo[i][pCash]);
        SetPlayerScore(playerid,PlayerInfo[i][pScore]);
    }
    return 1;
}
With this code my textdraw keeps staying on 0
Reply
#6

Hm I am not sure then.
Reply
#7

pawn Код:
public threetimer()
{
    for(new playerid; playerid<MAX_PLAYERS; playerid++) //if it's a time u would need this so it works for all ur players not only I'd 0
    {
        new text[10];
        format(text, sizeof(text), "%d",PlayerInfo[playerid][pScore]);
        TextDrawSetString(Textdraw1[playerid],text);  // the important part
        SetPlayerMoney(playerid,PlayerInfo[playerid][pCash]);
        SetPlayerScore(playerid,PlayerInfo[playerid][pScore]);
    }
    return 1;
}
Also remember Textdraw1[playerid] this is like that so the textdraw string is for a player each if u see what I mean
And make sure to change the new Textdraw1 to new Textdraw1[MAX_PLAYERS]

Hope that's what u need
Reply
#8

And then what do I have to do with this line?

Код:
Textdraw1 = TextDrawCreate(121.000000,435.000000,"1");
C:\Users\Bart\Desktop\SampScripting\gamemodes\Sunl ight.pwn(76) : error 033: array must be indexed (variable "Textdraw1")
Reply
#9

How to fix?
Reply
#10

pawn Код:
Textdraw1[playerid] = TextDrawCreate(121.000000,435.000000,"1");
Make sure is under OnPlayerConnect
not OnGameModeInt or OnFilterscriptInt because u will get errors
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)