24.03.2015, 18:39
Is it me or is everyone using player textdraws wrong ?
People are releasing scripts and answering stuff with playertextdraws - and even the wiki does it - wrong.
Before we had player textdraws we did this: (i did too)
Now everyone - and the wiki - is doing this: (but not me)
Do you see it ?
I do. Why in the name of scripting do people still use arrays. Everyone is still using arrays for playertextdraws.
When I create player textdraws I do this and it works perfectly:
Stop using arrays for playertextdraws.
If you would think logical it explains itself why you don't need arrays:
Before playertextdraws:
After:
You see the difference ? There's a playerid parameter. You don't need an array.
If i'm wrong, please tell me why. I posted this because i'm curious btw.
Greetings.
People are releasing scripts and answering stuff with playertextdraws - and even the wiki does it - wrong.
Before we had player textdraws we did this: (i did too)
pawn Код:
// This variable is used to store the id of the textdraw
// so that we can use it throught the script
new Text:welcomeText[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
// First, create the textdraw
welcomeText[playerid] = TextDrawCreate(320.0, 240.0, "Welcome to my SA-MP server");
// Now show it
TextDrawShowForPlayer(playerid, welcomeText[playerid]);
}
Now everyone - and the wiki - is doing this: (but not me)
pawn Код:
// This variable is used to store the id of the textdraw
// so that we can use it throught the script
new PlayerText:welcomeText[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
// First, create the textdraw
welcomeText[playerid] = CreatePlayerTextDraw(playerid, 320.0, 240.0, "Welcome to my SA-MP server");
// Now show it
PlayerTextDrawShow(playerid, welcomeText[playerid]);
}
I do. Why in the name of scripting do people still use arrays. Everyone is still using arrays for playertextdraws.
When I create player textdraws I do this and it works perfectly:
pawn Код:
new PlayerText:Stats;
public OnPlayerConnect(playerid)
{
Stats = CreatePlayerTextDraw(playerid,246.000000,434.000000,"~r~ Score: ~y~ x ~r~ Deaths:~y~ x ~r~ Kills: ~y~ x");
PlayerTextDrawUseBox(playerid,Stats,1);
PlayerTextDrawBoxColor(playerid,Stats,0x00ffff33);
//....
}
forward UpdateStats(playerid);
public UpdateStats(playerid)
{
new string[256];
format(string,sizeof string,"~r~Score: ~y~%i ~r~Deaths: ~y~%i ~r~Kills: ~y~%i ~r~Headshots: ~y~%i",GetPlayerScore(playerid),Player[playerid][Deaths],Player[playerid][Kills],Player[playerid][Headshots]);
PlayerTextDrawSetString(playerid,Stats,string);
PlayerTextDrawShow(playerid,Stats);;
}
If you would think logical it explains itself why you don't need arrays:
Before playertextdraws:
Quote:
welcomeText[playerid] = TextDrawCreate(320.0, 240.0, "Welcome to my SA-MP server"); |
Quote:
welcomeText[playerid] = CreatePlayerTextDraw(playerid, 320.0, 240.0, "Welcome to my SA-MP server"); |
pawn Код:
welcomeText = CreatePlayerTextDraw(playerid, 320.0, 240.0, "Welcome to my SA-MP server");
Greetings.