Textdraw [+REP]
#1

I am using it OnPlayerUpdate
Код:
	
       new PlayerText:Textdraw0;
	new string[18];
	format(string, sizeof(string), "Score: %i", GetPlayerScore(playerid));

	CreatePlayerTextDraw(playerid, 501.000000, 100.000000, string);
	PlayerTextDrawBackgroundColor(playerid,Textdraw0, -1);
	PlayerTextDrawFont(playerid,Textdraw0, 1);
	PlayerTextDrawLetterSize(playerid,Textdraw0, 0.320000, 0.799999);
	PlayerTextDrawColor(playerid,Textdraw0, 65535);
	PlayerTextDrawSetOutline(playerid,Textdraw0, 1);
	PlayerTextDrawSetProportional(playerid,Textdraw0, 1);
	PlayerTextDrawUseBox(playerid,Textdraw0, 1);
	PlayerTextDrawBoxColor(playerid,Textdraw0, 0x00000044);
	PlayerTextDrawTextSize(playerid,Textdraw0, 606.000000, 0.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw0, 0);
I get these warnings
Код:
warning 219: local variable "string" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.
Reply
#2

That error means you already defined the string, but you shouldn't use it under OnPlayerUpdate, that would create unlimited textdraws.
Also you need to have Textdraw0 as an array so it's different for each player.
Код:
new PlayerText:Textdraw0[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
	new string[18];
	format(string, sizeof(string), "Score: %i", GetPlayerScore(playerid));

	Textdraw0[playerid] = CreatePlayerTextDraw(playerid, 501.000000, 100.000000, string); // Textdraw0 needs to be assigned to this textdraw
	PlayerTextDrawBackgroundColor(playerid,Textdraw0[playerid], -1);
	PlayerTextDrawFont(playerid,Textdraw0[playerid], 1);
	PlayerTextDrawLetterSize(playerid,Textdraw0[playerid], 0.320000, 0.799999);
	PlayerTextDrawColor(playerid,Textdraw0[playerid], 65535);
	PlayerTextDrawSetOutline(playerid,Textdraw0[playerid], 1);
	PlayerTextDrawSetProportional(playerid,Textdraw0[playerid], 1);
	PlayerTextDrawUseBox(playerid,Textdraw0[playerid], 1);
	PlayerTextDrawBoxColor(playerid,Textdraw0[playerid], 0x00000044);
	PlayerTextDrawTextSize(playerid,Textdraw0[playerid], 606.000000, 0.000000);
	PlayerTextDrawSetSelectable(playerid,Textdraw0[playerid], 0);
        PlayerTextDrawShow(playerid, Textdraw0[playerid]); // Remember to also show the textdraw, if you did this anywhere else in your code remove this line
}
Reply
#3

I will test it and reply.
Reply
#4

There's errors in CalvinC's snippet. Mainly under OnPlayerConnect.


PHP код:
new PlayerText:Textdraw0[MAX_PLAYERS];
public 
OnPlayerConnect(playerid)
{
    
Textdraw0[playerid] = CreatePlayerTextDraw(playerid501.000000100.000000"0"); // Textdraw0 needs to be assigned to this textdraw
    
PlayerTextDrawBackgroundColor(playerid,Textdraw0[playerid], -1);
    
PlayerTextDrawFont(playerid,Textdraw0[playerid], 1);
    
PlayerTextDrawLetterSize(playerid,Textdraw0[playerid], 0.3200000.799999);
    
PlayerTextDrawColor(playerid,Textdraw0[playerid], 65535);
    
PlayerTextDrawSetOutline(playerid,Textdraw0[playerid], 1);
    
PlayerTextDrawSetProportional(playerid,Textdraw0[playerid], 1);
    
PlayerTextDrawUseBox(playerid,Textdraw0[playerid], 1);
    
PlayerTextDrawBoxColor(playerid,Textdraw0[playerid], 0x00000044);
    
PlayerTextDrawTextSize(playerid,Textdraw0[playerid], 606.0000000.000000);
    
PlayerTextDrawSetSelectable(playerid,Textdraw0[playerid], 0);
    return 
1;
}
public 
OnPlayerSpawn(playerid)
{
    new 
string[18];
    
format(stringsizeof(string), "Score: %i"GetPlayerScore(playerid));
    
PlayerTextDrawSetString(playeridTextdraw0[playerid], string);
    
PlayerTextDrawShow(playeridTextdraw0[playerid]);
    return 
1;

Everytime you update score set the textdraw string, or even better, run a timer?
Reply
#5

You have A Global 'String' so it's shadows a variable at a preceding level
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)