SA-MP Forums Archive
Showing wrong 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)
+--- Thread: Showing wrong stats (/showthread.php?tid=561898)



Showing wrong stats - lulo356 - 05.02.2015

I created for the /spectate some textdraw thats showing some information but its showing my information instand of the other players information and i dont know the problem.

pawn Код:
if(GetPlayerState(playerid) == PLAYER_STATE_SPECTATING)
        {
            new userid;
            new string[128],string1[128],string2[128],string3[128],string4[128],string5[128],string6[128],string7[128],string8[128],string9[128];
            if(userid != INVALID_PLAYER_ID)
            {
                new ip[16], Float:H, Float:A;
                GetPlayerIp(userid, ip, sizeof(ip));
                GetPlayerHealth(userid, H); GetPlayerArmour(userid, A);
                format(string, sizeof(string), "Health: %0.1f", H);
                PlayerTextDrawSetString(playerid,Health1, string);
                format(string1, sizeof(string1), "Armour: %0.1f", A);
                PlayerTextDrawSetString(playerid, Armour1, string1);
                format(string2, sizeof(string2), "Money: %d", GetPlayerMoney(userid));
                PlayerTextDrawSetString(playerid, Money, string2);
                format(string3, sizeof(string3), "Name: %s", ReturnName(userid, 0));
                PlayerTextDrawSetString(playerid, Name, string3);
                format(string4, sizeof(string4), "IP: %s", ip);
                PlayerTextDrawSetString(playerid, IP1, string4);
                format(string5, sizeof(string5), "%s", PlayerData[userid][CMD1]);
                PlayerTextDrawSetString(playerid, sCMD0,string5);
                format(string6, sizeof(string6), "%s", PlayerData[userid][CMD2]);
                PlayerTextDrawSetString(playerid, sCMD1,string6);
                format(string7, sizeof(string7), "%s", PlayerData[userid][CMD3]);
                PlayerTextDrawSetString(playerid, sCMD2,string7);
                format(string8, sizeof(string8), "%s", PlayerData[userid][CMD4]);
                PlayerTextDrawSetString(playerid, sCMD3,string8);
                format(string9, sizeof(string9), "%s", PlayerData[userid][CMD5]);
                PlayerTextDrawSetString(playerid, sCMD4,string9);
            }
        }



Re: Showing wrong stats - Vince - 05.02.2015

Quote:
pawn Код:
new userid;
Do you expect this to be magically filled or something?

You can also use the same string to format the messages. There's absolutely no need to use 10. The last 5 variables (CMD1..5) don't even need to be formatted at all and can be inserted into TextDrawSetString directly.


Re: Showing wrong stats - lulo356 - 05.02.2015

Quote:
Originally Posted by Vince
Посмотреть сообщение
Do you expect this to be magically filled or something?

You can also use the same string to format the messages. There's absolutely no need to use 10. The last 5 variables (CMD1..5) don't even need to be formatted at all and can be inserted into TextDrawSetString directly.
but the problem is not in the string but in the Userid,


Re: Showing wrong stats - Schneider - 05.02.2015

Yes, and like Vince already said... Do you expect 'userid' to be magically filled or something?


Re: Showing wrong stats - lulo356 - 05.02.2015

Quote:
Originally Posted by Schneider
Посмотреть сообщение
Yes, and like Vince already said... Do you expect 'userid' to be magically filled or something?
Im here to learn so if you can tell me what i need to do, otherwise i can't do anything.


Re: Showing wrong stats - dominik523 - 05.02.2015

You just can't create a variable Userid and do anything with it. There is a playerid for a reason.


Re: Showing wrong stats - lulo356 - 05.02.2015

found it out
pawn Код:
new userid = PlayerData[playerid][pSpectator];