textdraw problem
#1

Hello,i've created a textdraw to replace the old cash style with my own.This is the textdraw:

pawn Код:
new Text:Cash[MAX_PLAYERS];
OnGameModeInit:

pawn Код:
Cash[i] = TextDrawCreate(498.000000, 80.000000, "Cash: $");
    TextDrawBackgroundColor(Cash[i], 1711276202);
    TextDrawFont([Cash[i], 3);
    TextDrawLetterSize(Cash[i], 0.329998, 1.799999);
    TextDrawColor(Cash[i], -1);
    TextDrawSetOutline(Cash[i], 1);
    TextDrawSetProportional(Cash[i], 1);
    TextDrawUseBox(Cash[i], 1);
    TextDrawBoxColor(Cash[i], 255);
    TextDrawTextSize(Cash[i], 606.000000, 4.000000);
OnPlayerConnect:

pawn Код:
for(new i; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerConnected(i))
        {
            TextDrawShowForPlayer(i, Cash);
        }
    }
But when i compile,i get this errors:

Quote:

(2300) : error 029: invalid expression, assumed zero
(2300) : warning 215: expression has no effect
(2300) : warning 215: expression has no effect
(2300) : error 001: expected token: ";", but found ")"
(2300) : error 029: invalid expression, assumed zero
(2300): fatal error 107: too many error messages on one line

This is the error line:

pawn Код:
TextDrawFont([Cash[i], 3);
What's wrong?
Reply
#2

Create the textdraw OnPlayerConnect, not OnGameModeInit. You can't pass a playerid parameter OnGameModeInit, hense why the looped value ( [ i ] ) is giving you an error.

OnPlayerConnect, do it like this..

pawn Код:
public OnPlayerConnect ( playerid )
{
    YourTextDraw [ playerid ] = TextDrawCreate(498.000000, 80.000000, "Cash: $");
    TextDrawBackgroundColor(YourTextDraw [ playerid ], 1711276202);
    TextDrawFont(YourTextDraw [ playerid ], 3);
    TextDrawLetterSize(YourTextDraw [ playerid ], 0.329998, 1.799999);
    TextDrawColor(YourTextDraw [ playerid ], -1);
    TextDrawSetOutline(YourTextDraw [ playerid ], 1);
    TextDrawSetProportional(YourTextDraw [ playerid ], 1);
    TextDrawUseBox(YourTextDraw [ playerid ], 1);
    TextDrawBoxColor(YourTextDraw [ playerid ], 255);
    TextDrawTextSize(YourTextDraw [ playerid ], 606.000000, 4.000000);
   
    TextDrawShowForPlayer( playerid, YourTextDraw [ playerid ] );
    return true;
}
Of course, after this, don't forget to set either a global or per-player timer to update the string every (1?) second or so.

SetTimerEx (per-player) or SetTimer will suffice for this.
Reply
#3

EDIT: Fixed.Thanks!

+rep.
Reply
#4

Quote:
Originally Posted by Logitech90
Посмотреть сообщение
Thanks for quick answer.I make like you said and now i've this error in OnPlayerConnect:

error 035: argument type mismatch (argument 2)

Line:

pawn Код:
TextDrawShowForPlayer(playerid, Cash);
pawn Код:
TextDrawShowForPlayer( playerid, Cash [ playerid ] );
Remember these textdraws are created per-player meaning every players textdraw will (should) be different!

You're going to need to specify who's textdraw you're showing them.
Reply
#5

Yes,i fixed it,thanks.
Reply
#6

lol and you helped me to holmes thx
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)