Quote:
Originally Posted by ALiScripter
I wonder how people still use global textdraws with global variables for players when you need to use player text draws that does the job and are made for it.
Player textdraw code (taken from my gamemode):
How i create textdraws, using player textdraws
PHP код:
// top of the script
new PlayerText:PlayerTD;
// creating it on OPConnect
PlayerTD = CreatePlayerTextDraw(playerid, XXX.000000, XXX.000000, " ");
PlayerTextDrawBackgroundColor(playerid, PlayerTD, XXX);
PlayerTextDrawFont(playerid, PlayerTD, X);
PlayerTextDrawColor(playerid, PlayerTD, XX);
PlayerTextDrawSetOutline(playerid, PlayerTD, XX);
PlayerTextDrawSetShadow(playerid, PlayerTD, X);
PlayerTextDrawLetterSize(playerid, PlayerTD, XXX, XXX);
PlayerTextDrawSetSelectable(playerid, PlayerTD, XX);
// destroying it on OPDisconnect
PlayerTextDrawDestroy(playerid, PlayerTD);
// how to display it
PlayerTextDrawSetString(playerid, PlayerTD, "~r~ XXXXX");
PlayerTextDrawShow(playerid, PlayerTD);
This is wrong... Player who use global textdraws for players, use this method which causes bugs and isn't recommended.
PHP код:
new PlayerText:Zones[MAX_PLAYERS]; /* or */ new Text:Zones[MAX_PLAYERS]; // wrong method
Zones[playerid] = CreatePlayerTextDraw(playerid,6.5, 425.4, "_");
it should be like
PHP код:
new PlayerText:Zones; //right method
Zones = CreatePlayerTextDraw(playerid,6.5, 425.4, "_");
|
Your code is wrong... if you want to edit your player textdraws when there are more than 1 player online, how do you expect to do that if the textdraw ID gets overwritten every time a new player connects?
Correction:
pawn Код:
// top of the script
new PlayerText:PlayerTD[MAX_PLAYERS];
// creating it on OPConnect
PlayerTD[playerid] = CreatePlayerTextDraw(playerid, XXX.000000, XXX.000000, " ");
PlayerTextDrawBackgroundColor(playerid, PlayerTD[playerid], XXX);
PlayerTextDrawFont(playerid, PlayerTD[playerid], X);
PlayerTextDrawColor(playerid, PlayerTD[playerid], XX);
PlayerTextDrawSetOutline(playerid, PlayerTD[playerid], XX);
PlayerTextDrawSetShadow(playerid, PlayerTD[playerid], X);
PlayerTextDrawLetterSize(playerid, PlayerTD[playerid], XXX, XXX);
PlayerTextDrawSetSelectable(playerid, PlayerTD[playerid], XX);
// destroying it on OPDisconnect
PlayerTextDrawDestroy(playerid, PlayerTD[playerid]);
// how to display it
PlayerTextDrawSetString(playerid, PlayerTD[playerid], "~r~ XXXXX");
PlayerTextDrawShow(playerid, PlayerTD[playerid]);