SA-MP Forums Archive
Floats on a textdraw statbar, Pulls other players stats? - 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: Floats on a textdraw statbar, Pulls other players stats? (/showthread.php?tid=144910)



Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 29.04.2010

ok, i made a stat bar, for health armour kills and deaths, floating them on a textdraw, but ingame, ID 0 see's ID 1's stats.


pawn Код:
forward stats();
public stats()
{
    for(new playerid; playerid < MAX_PLAYERS; playerid ++)
    {
        if(IsPlayerConnected(playerid))
        {
    new Float:pHealth, Float:pArmour, string[15];
    GetPlayerHealth(playerid,pHealth);
    format(string, sizeof(string), "Health:%.0f", pHealth);
    TextDrawSetString(Textdraw2, string);
   
    GetPlayerArmour(playerid,pArmour);
    format(string, sizeof(string), "Armour:%.0f", pArmour);
    TextDrawSetString(Textdraw3, string);
   
    format(string, sizeof(string), "Kills:%.0f", GetPlayerScore(playerid));
    TextDrawSetString(Textdraw4, string);
   
    format(string, sizeof(string), "Deaths:%.0f", GetPVarInt(playerid,"Deaths"));
    TextDrawSetString(Textdraw5, string);
        }
    }
}
Any ideas? I need this fixed as soon as possible, i have tryed EVERYTHING and still nothing.


Re: Floats on a textdraw statbar, Pulls other players stats? - Virtual1ty - 29.04.2010

Why looping through all the players when you want to show the textdraw for a player only?

pawn Код:
forward stats(playerid);

public stats(playerid)
{
    new Float:pHealth, Float:pArmour, string[15];
    GetPlayerHealth(playerid,pHealth);
    format(string, sizeof(string), "Health:%.0f", pHealth);
    TextDrawSetString(Textdraw2, string);

    GetPlayerArmour(playerid,pArmour);
    format(string, sizeof(string), "Armour:%.0f", pArmour);
    TextDrawSetString(Textdraw3, string);

    format(string, sizeof(string), "Kills:%.0f", GetPlayerScore(playerid));
    TextDrawSetString(Textdraw4, string);

    format(string, sizeof(string), "Deaths:%.0f", GetPVarInt(playerid,"Deaths"));
    TextDrawSetString(Textdraw5, string);
}



Re: Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 29.04.2010

I beleive someone told me not to do it this way, but ill try it.

EDIT: Works, thanks .


Re: Floats on a textdraw statbar, Pulls other players stats? - Niixie - 29.04.2010

looping that way is for checking all players, not just one. Keep that in your mind


Re: Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 29.04.2010

Sure will, Someone told me to use
Код:
for(new playerid =0; playerid<MAX_PLAYERS; playerid++)
But all that did was lag then crash.


Re: Floats on a textdraw statbar, Pulls other players stats? - MadeMan - 29.04.2010

The problem is, that you use same textdraws for all players. You should have textdraws for every player.


Re: Floats on a textdraw statbar, Pulls other players stats? - RyDeR` - 29.04.2010

Quote:
Originally Posted by [N
BL!nk ]
Sure will, Someone told me to use
Код:
for(new playerid =0; playerid<MAX_PLAYERS; playerid++)
But all that did was lag then crash.
If you use it correct; it will never crash


Re: Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 29.04.2010

Ok well.. i changed the look of the stat bar, and now it doesnt work anymore, all the other id's get id 0's stats.
Код:
public stats(playerid)
{
new Float:pHealth, Float:pArmour, string[15];
GetPlayerHealth(playerid,pHealth);
format(string, sizeof(string), "Health:%.0f", pHealth);
TextDrawSetString(Textdraw2, string);

GetPlayerArmour(playerid,pArmour);
format(string, sizeof(string), "Armour:%.0f", pArmour);
TextDrawSetString(Textdraw3, string);

format(string, sizeof(string), "Kills:%d", GetPlayerScore(playerid));
TextDrawSetString(Textdraw4, string);

format(string, sizeof(string), "Deaths:%d", GetPVarInt(playerid,"Deaths"));
TextDrawSetString(Textdraw5, string);

format(string, sizeof(string), "ID:%d", GetPlayerID(playerid));
TextDrawSetString(Textdraw6, string);
}



Re: Floats on a textdraw statbar, Pulls other players stats? - MadeMan - 30.04.2010

Quote:
Originally Posted by MadeMan
The problem is, that you use same textdraws for all players. You should have textdraws for every player.



Re: Floats on a textdraw statbar, Pulls other players stats? - Uninvited - 06.05.2010

I have also same problem that i only get stats from id 0

So how should it be fixed?


Re: Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 06.05.2010

Univited, i fixed this along time ago, use 1 textdraw.

Then use MAX_PLAYERS 1++ for it, then it works. hope i helped


Re: Floats on a textdraw statbar, Pulls other players stats? - Hernaner28 - 02.06.2010

Please, help me. I dont understand what MAX_PLAYERS (i) do. When someone enters to the server the level textdraw should update. And that is what it does, I have this:
Quote:

public UpdateLevel()
{
new string[15];
format(string, sizeof(string), "%d", GetPVarInt(playerid, NIVELES));
TextDrawSetString(Textdraw1, string);
return 1;
}

So, this "UpdateLevel" happens when somebody level ups or when they spawn. For example I am level 10 and Im already in the server and then a level 50 spawns my textdraw also changes to 50.
Any solution? THANKS!


Re: Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 02.06.2010

Dude this is so old, i fixed this after i posted it


Re: Floats on a textdraw statbar, Pulls other players stats? - Hernaner28 - 02.06.2010

May you help me? Thanks.


Re: Floats on a textdraw statbar, Pulls other players stats? - -Rebel Son- - 03.06.2010

yeah! the hole problem was, i was using two many textdraws with formated texts, Try to use 1 or two. and make a textdraw for everyplayer with a variable [MAX_PLAYERS].



Re: Floats on a textdraw statbar, Pulls other players stats? - Hernaner28 - 03.06.2010

Could you explain me more detailed? I didnt understand anything. Can you give a pawn code of how can I fix what I previously posted? Thanks!