#1

I have food system that is taking every minute 1 % of food and textdraw to show how many % you have...
Now when i am the only player in the server all works fine, but when there are multiple players then it dont show player HIS hunger, but somone elses... i think that is showing the last players hunger to everyone(player with the highest ID)
Here is the script:
Код:
forward TimerMin(); //This is a 1 minute timer...
public TimerMin()
{
	for(new i = 0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i))
	{
	    if(pInfo[i][Hunger] >= 1) // If player have more than 1% of hunger.
	    {
			pInfo[i][Hunger] --;
			TextDrawHideForPlayer(i,hrana);
			new hranastr[124];
			format(hranastr, sizeof(hranastr), "Hrana:  %i %", pInfo[i][Hunger]);  // Textdraw for display % of hunger.
			TextDrawSetString(hrana, hranastr);
			TextDrawShowForPlayer(i, hrana);
			if(pInfo[i][Hunger] == 1)
			{
				SendClientMessage(i, COLOR_YELLOW, "Lačni ste. Morate jesti!"); // Warns the player if he have 1% of hunger.
			}
		}
		else if(pInfo[i][Hunger] == 0) // If player have 0% of hunger...
		{
		    new Float:health;
			GetPlayerHealth(i,health);
			SetPlayerHealth(i, health - 9); // Take 9 players health...
		}
	}
    return 1;
}
Reply
#2

Try using playerid instead of i(MAX_PLAYERS) ?
Reply
#3

You need to assign the textdraw to a player id.

Example:
pawn Код:
new Text:welcomeText[MAX_PLAYERS];
And instead of creating it under OnGameModeInit, you create it under OnPlayerConnect, like:
pawn Код:
welcomeText[playerid] = TextDrawCreate(240.0,580.0,"Welcome to my SA-MP server");
Then from there, instead of using just "welcomeText", you would use "welcomeText[playerid]".
Reply
#4

Thanks that works...
Reply


Forum Jump:


Users browsing this thread: