Need help.... - 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: Need help.... (
/showthread.php?tid=245296)
Need help.... -
[Ha]Lommo - 30.03.2011
Код:
Stats()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
new temp[256];
format(temp,sizeof(temp),"%s Kills: %d Deaths: %d Ratio: %0.2f\r\n Teamkills: %d",name,PlayerData[i][Kills],
PlayerData[i][Deaths],ratio,PlayerData[i][Tkills]);
SendClientMessageToAll(COLOR_RED,temp);
TextDrawSetString(Text:DikkeDraw,temp);
TextDrawShowForAll(Text:DikkeDraw);
}
}
}
The problem is the SendClientMessage works perfect, it shows the stats of all players who are online. The textdraw only shows 1player.. how to fix this? i really need help with this problem.. would be cool if someone can help me.Or give ur msn or something so u can explain..
Thanks.
Re: Need help.... -
iRemix - 30.03.2011
I'm not sure if it will work, but try
pawn Код:
TextDrawShowForPlayer(i, DikkeDraw);
Instead of:
pawn Код:
TextDrawShowForAll(Text:DikkeDraw);
Re: Need help.... -
[Ha]Lommo - 30.03.2011
Still the same. Someone else knows?
Re: Need help.... -
iggy1 - 30.03.2011
EDIT: I failed
The reason its not working is because you set (TextDrawSetString) the text inside a loop. When you set the text it deletes the old one. Even if you formated the textdraw string you might not get the desired result because you would have x amount of players. Unless you have made the textdraw ok to hold all the info for your max players.
Re: Need help.... -
[Ha]Lommo - 31.03.2011
Don't really understand..
Re: Need help.... -
Kwarde - 31.03.2011
Hmm. Some fails...
pawn Код:
Stats()
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
new temp[256]; //Max client message length = 128. This is too big string. And using this in a loop? WTF
format(temp,sizeof(temp),"%s Kills: %d Deaths: %d Ratio: %0.2f\r\n Teamkills: %d",name,PlayerData[i][Kills],
PlayerData[i][Deaths],ratio,PlayerData[i][Tkills]);
SendClientMessageToAll(COLOR_RED,temp); //In a loop? So it'll send the message ~ times (~ = ammount of connected players)
TextDrawSetString(Text:DikkeDraw,temp); //Edit it ~ times for everyone? + Make a PLAYER textdraw.
TextDrawShowForAll(Text:DikkeDraw); //See above
}
}
}
About the Make a PLAYEr textdraw:
That thing above is a global textdraw, I see. So, the player with the highest ID that's connected, his stats'll be displayed to everyone.
Re: Need help.... -
linuxthefish - 31.03.2011
Try indenting your code to make it easier to read!