17.09.2010, 19:01
(
Последний раз редактировалось ColdXX; 17.09.2010 в 19:50.
)
How can do i make the textdraw show the player's score? and also update when the player's score goes higher? I need it please help
//On top, UNDER your includes:
new Text:score[MAX_PLAYERS] = {-1, -1, ...};
#define SetPlayerScoreEx(%1,%2) SetPlayerScore((%1), (%2)); new txtstring[11]; format(txtstring, 2, "%d", (%2)); TextDrawSetString(score[(%1)], txtstring);
public OnPlayerConnect(playerid)
{
score[playerid] = TextDrawCreate(11, 280, 0);
//Other code
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(score[playerid]);
//other codes
return 1;
}
When u said Make Textdraws for everyone....for all players? i mean wtfomghax!
And didnt really understood much of ur script. Could u explain a bit more? |
public OnPlayerConnect(playerid)
{
score[playerid] = TextDrawCreate(11, 280, "0");
TextDrawShowForPlayer(playerid, score[playerid]);
//Other code
return 1;
}
//On top, UNDER your includes:
new Text:score[MAX_PLAYERS]; //Creates all the textdraws. The "{-1, -1, ...};" meant that ALL variables have a standard value of "-1", but later I saw this was kinda useless as a textdraw doesn't gets created if the player doesn't joins :P
#define SetPlayerScoreEx(%1,%2) SetPlayerScore((%1), (%2)); new txtstring[11]; format(txtstring, 2, "%d", (%2)); TextDrawSetString(score[(%1)], txtstring) //This is something which might be hard to understand, scroll to the bottom of mah post for a function ^^
public OnPlayerConnect(playerid)
{
score[playerid] = TextDrawCreate(11, 280, "Score: 0"); //Creating the textdraw
TextDrawShowForPlayer(playerid, score[playerid]); //Showing it for the player, standard value of zero "0"
//Other code
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
TextDrawDestroy(score[playerid]); //Destroys the textdraw. It's kinda useless to have it around when the player is not connected ^^
//other codes
return 1;
}
stock SetPlayerScoreEx(playerid, score)
{
if(!IsPlayerConnected(playerid)) return; //If the player is NOT connected, the textdraws will probably bug up.
SetPlayerScore(playerid, score); //Sets the score.
new string[11+7]; //Why 11? 11 is the max length of an integer (A non-float value). And +8 for "score: ".
format(string, sizeof string, "Score: %d", score); // Formats the string which contains the score.
TextDrawSetString(score[playerid], string);
}