Okay, there's an order of items you need to do first, and understand too, come on.
1 - Your TXD that shows the amount of gifts that the player has is the player's own, no one else, so the first step is to change your variable that stores the TXD, it should look like this:
PHP код:
new PlayerText:TextName[MAX_PLAYERS][Your Array];
// "TextName" is the name of your Text Draw
// "Your Array" is your Array index, if there is.
2 - This sort the specific TextDraw for the player, after this you need to change everything who has the name of TextDraw, should stay like this
PHP код:
// Exemple:
TextName[playerid][Array Index];
// In Your case:
GiftsInfo[playerid][2];
3 - After an exchange of all your "GiftsInfo [2]" to "GiftsInfo [playerid] [2]" let's to code.
All you need to do to upgrade is a count that updates whenever there is a change in the number of gifts, so...
Now you need to have some variability that will store the amount of gifts that each player has, so you create it:
put on top of your GM:
PHP код:
new GiftAmount[MAX_PLAYERS] = 0;
new countdown[MAX_PLAYERS];
Of course, every time the admin gives a gift to everyone, this value should be +1
Then you create a loop, for each player to receive 1 gift,
Inside the command "CMD:giveallgift(playerid, params[])" you put
PHP код:
GiftAmount[playerid] = GiftAmount[playerid]+1;
// Then the command give a gift every time it is typed
Now, you need to edit the TXD and show it for all players, then you do a loop
PHP код:
new strg[250];
format(strg, sizeof(strg), "%i", GiftAmount[i])
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerTextDrawSetString(i, GiftsInfo[i][2], strg);
PlayerTextDrawShow(i, GiftsInfo[i][2]);
}
Inside of your command: "CMD:cadouri(playerid, params[])" put the following
PHP код:
countdown[playerid] = GiftAmount[playerid];
countdown[playerid] = countdown[playerid] - 1;
This will remove 1 gift from the gift list
Now it's the same looping process
PHP код:
new strg[250];
format(strg, sizeof(strg), "%i", countdown[playerid])
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayerTextDrawSetString(i, GiftsInfo[i][2], strg);
PlayerTextDrawShow(i, GiftsInfo[i][2]);
}
To conclude simply create an if, which will check if the player still has gift, so put on top of your command: "CMD:cadouri(playerid, params[])"
PHP код:
if(GiftAmount[playerid] == 0)
return SendClientMessage(playerid, RED, "You Haven't gift!");
I hope you understood.