Help textraw scoring
#1

an you please help me make a textraw scoring board?

here is the sample I want.

Untitled.png

I tried but it is nearly different. It only show 0 from 0/15 and the rest not showing. Here is the code


On the top
Код:
new Text:Textdraw0[MAX_PLAYERS];
new Text:Textdraw2[MAX_PLAYERS];
ONPLAYERUPDATE
Код:
public OnPlayerUpdate(playerid)
{
	new string[128];
	format(string,sizeof(string),"~w~%d",GetPlayerScore(playerid));
	TextDrawSetString(Textdraw0[playerid],string);
	new string2[128];
	format(string2,sizeof(string2),"~y~K: ~w~%d ~r~D: ~w~%d",PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths]);
	TextDrawSetString(Textdraw2[playerid],string2);

	TextDrawShowForPlayer(playerid,Textdraw0[playerid]);
	return 1;
}
Код:
public OnPlayerSpawn(playerid)
{

	// Create the textdraws:
	Textdraw0[playerid] = TextDrawCreate(311.000000, 348.000000, "0");
	TextDrawBackgroundColor(Textdraw0[playerid], 255);
	TextDrawFont(Textdraw0[playerid], 1);
	TextDrawLetterSize(Textdraw0[playerid], 0.500000, 1.800000);
	TextDrawColor(Textdraw0[playerid], -65281);
	TextDrawSetOutline(Textdraw0[playerid], 0);
	TextDrawSetProportional(Textdraw0[playerid], 1);
	TextDrawSetShadow(Textdraw0[playerid], 1);


	Textdraw2[playerid] = TextDrawCreate(299.000000, 378.000000, "K");
	TextDrawBackgroundColor(Textdraw2[playerid], 255);
	TextDrawFont(Textdraw2[playerid], 1);
	TextDrawLetterSize(Textdraw2[playerid], 0.500000, 1.000000);
	TextDrawColor(Textdraw2[playerid], -1);
	TextDrawSetOutline(Textdraw2[playerid], 0);
	TextDrawSetProportional(Textdraw2[playerid], 1);
	TextDrawSetShadow(Textdraw2[playerid], 1);
Reply
#2

Main Issue
Look at this line:
pawn Код:
format(string,sizeof(string),"~w~%d",GetPlayerScore(playerid));
You're just showing the player's score, so of course it's not going to include the '/15' part. What is that for anyway? I assume 15 is the score at which the player wins the match. You need to add that to the format().

Other issues
- Please use [ pawn ] tags, not [ code ]. Code tags don't including syntax highlighting.
- Always put a space after a comma. It helps readability.
- Name variables better. 'Textdraw1', 'Textdraw2' is not good at all. How are you meant to know which is which? Give them descriptive names, for example 'TD_PlayerKDRatio'. The TD_ prefix denotes that it is a textdraw.
- Why are you defining two strings? You only need one. And it doesn't need to be 128 characters, that's way too much.
- You could (not should - could) use player textdraws for this.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)