PDA

View Full Version : Showing wrong stats


lulo356
05/02/2015, 08:05 PM
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.

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);
}
}

Vince
05/02/2015, 08:15 PM
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.

lulo356
05/02/2015, 08:19 PM
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,

Schneider
05/02/2015, 08:31 PM
Yes, and like Vince already said... Do you expect 'userid' to be magically filled or something?

lulo356
05/02/2015, 08:37 PM
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.

dominik523
05/02/2015, 08:38 PM
You just can't create a variable Userid and do anything with it. There is a playerid for a reason.

lulo356
05/02/2015, 08:42 PM
found it out new userid = PlayerData[playerid][pSpectator];