Showing wrong stats
#1

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);
            }
        }
Reply
#2

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.
Reply
#3

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,
Reply
#4

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

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.
Reply
#6

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)