SA-MP Forums Archive
[HELP] Stats Textdraw - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [HELP] Stats Textdraw (/showthread.php?tid=146190)



[HELP] Stats Textdraw - Uninvited - 06.05.2010

I have a problem with Stats Textdraw.

This is what i use:
Код:
public StatsUpdate()
{
	new string[128];
	new playerid;
  format(string, sizeof(string), "~r~Stats: ~n~~r~Age: ~w~ %d ~n~~r~Exp: ~w~ %d ~n~~r~Money: ~w~ %d ~n~~r~Bank: ~w~ %d ~n~~r~Drugs: ~w~ %d" , PlayerInfo[playerid][pLevel], PlayerInfo[playerid][pExp],GetPlayerMoney(playerid),PlayerInfo[playerid][pBank],PlayerInfo[playerid][pDrugs]);
  TextDrawSetString(StatsTextdraw, string);
  TextDrawShowForPlayer(playerid,StatsTextdraw);
}
Also i have a timer wich updates every 5 seconds , but after it updates it shows stats of ID 0 instead of your own.

How to solve/fix this problem?

Grtz.


Re: [HELP] Stats Textdraw - Bcklup - 06.05.2010

Make the Textdraw for every player like the variables with the "[playerid]" tags what do you call those btw?


Re: [HELP] Stats Textdraw - Uninvited - 06.05.2010

How would it look like then? I don't really understand...


Re: [HELP] Stats Textdraw - Kyosaur - 06.05.2010

Quote:
Originally Posted by Bcklup
Make the Textdraw for every player like the variables with the "[playerid]" tags what do you call those btw?
Do basically what he said. Declare a MAX_PLAYER array (make sure it has the Text handle on it). Also, remove the player id variable, and add a player id parameter to the function itself instead. Variables are equal to 0 by default when they are declared, so thats why its always ID 0's stats that are shown.


Re: [HELP] Stats Textdraw - shady91 - 06.05.2010

pawn Код:
public StatsUpdate()
{
new string[128];
for(new i = 0; i < MAX_PLAYERS; i++)
{
format(string, sizeof(string), "~r~Stats: ~n~~r~Age: ~w~ %d ~n~~r~Exp: ~w~ %d ~n~~r~Money: ~w~ %d ~n~~r~Bank: ~w~ %d ~n~~r~Drugs: ~w~ %d" , PlayerInfo[i][pLevel], PlayerInfo[i][pExp],GetPlayerMoney(i),PlayerInfo[i][pBank],PlayerInfo[i][pDrugs]);
TextDrawSetString(StatsTextdraw, string);
TextDrawShowForPlayer(i,StatsTextdraw);
}
}
It looks like you haven't so you should make sure you made a textdraw for each person other wise it won't work right.


Re: [HELP] Stats Textdraw - Uninvited - 06.05.2010

Код:
for(new i=0; i<MAX_SLOTS; i++)
	{
		new string[128];
  	format(string, sizeof(string), "~r~Stats: ~n~~r~Age: ~w~ %d ~n~~r~Exp: ~w~ %d ~n~~r~Money: ~w~ %d ~n~~r~Bank: ~w~ %d ~n~~r~Drugs: ~w~ %d" , PlayerInfo[i][pLevel], PlayerInfo[i][pExp],GetPlayerMoney(i),PlayerInfo[i][pBank],PlayerInfo[i][pDrugs]);
  	TextDrawSetString(StatsTextdraw, string);
  	TextDrawShowForPlayer(i,StatsTextdraw);
  }
Like this? I tried it but still shows ID 0


Re: [HELP] Stats Textdraw - shady91 - 06.05.2010

How I wrote it also I see its StatsTextdraw (that's one text draw for other players to work it should be for max players) so you should make it StatsTextdraw[i] so they each have there own text draw created for them.


edit:

so you should have something like this.


pawn Код:
// this at the top of your script
new Text:StatsTextdraw[MAX_PLAYERS];

public StatsUpdate()
{
new string[128];
for(new i = 0; i < MAX_PLAYERS; i++)
{
format(string, sizeof(string), "~r~Stats: ~n~~r~Age: ~w~ %d ~n~~r~Exp: ~w~ %d ~n~~r~Money: ~w~ %d ~n~~r~Bank: ~w~ %d ~n~~r~Drugs: ~w~ %d" , PlayerInfo[i][pLevel], PlayerInfo[i][pExp],GetPlayerMoney(i),PlayerInfo[i][pBank],PlayerInfo[i][pDrugs]);
TextDrawSetString(StatsTextdraw[i], string);
TextDrawShowForPlayer(i,StatsTextdraw[i]);
}
}



Re: [HELP] Stats Textdraw - Uninvited - 06.05.2010

TextDrawShowForPlayer(i,StatsTextdraw);

So i need to change this?


Re: [HELP] Stats Textdraw - Uninvited - 06.05.2010

I now get compile errors:
Код:
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1963) : error 033: array must be indexed (variable "StatsTextdraw")
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1964) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1965) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1966) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1967) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1968) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1969) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1970) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1971) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1972) : error 035: argument type mismatch (argument 1)
C:\Users\Jeroen\Documents\Downloads\PBRPG\slrpg\gamemodes\slrpg.pwn(1973) : error 035: argument type mismatch (argument 1)



Re: [HELP] Stats Textdraw - Uninvited - 06.05.2010

I know the problem its where i declare the style and so on ...

Код:
line 1963	StatsTextdraw = TextDrawCreate(445.000000, 251.000000, "~r~Stats:");
	TextDrawAlignment(StatsTextdraw, false);
	TextDrawBackgroundColor(StatsTextdraw, 0x000000ff);
	TextDrawUseBox (StatsTextdraw, true);
	TextDrawBoxColor (StatsTextdraw, 0x000000AA);
	TextDrawFont(StatsTextdraw, 2);
	TextDrawLetterSize(StatsTextdraw, 0.2, 0.7500000);
	TextDrawColor(StatsTextdraw, 0xffffffff);
	TextDrawSetOutline(StatsTextdraw, true);
	TextDrawSetProportional(StatsTextdraw, true);
line 1973	TextDrawSetShadow(StatsTextdraw, 10);