Textdraw gifts
#1

Does anyone know how can connect gifts on textdraw?
I need help..
When I write "/cadouri" the gifts do not diminish..
https://imgur.com/a/fZxXKou
https://imgur.com/a/2x4RnhR
Reply
#2

Can you show your code?
Reply
#3

Quote:
Originally Posted by ApolloScripter
Посмотреть сообщение
Can you show your code?
Код HTML:
CMD:cadouri(playerid, params[])
{
    new BigString[2048], LittleCounterg[10], cadou[512], namestr[MAX_PLAYER_NAME+20];
	//--------------------------------------------------------------------------
	format(LittleCounterg, 10, "%d", CosminInfo[playerid][Gifts]); TextDrawSetString(GiftsInfo[2], LittleCounterg); TextDrawSetString(GiftsInfo[1], LittleCounterg);
    //--------------------------------------------------------------------------
    foreach(new l: Player) if(CosminInfo[l][Gifts] >= 1)
   	{
	   if(CosminInfo[l][Gifts] == 0) TextDrawShowForPlayer(l, GiftsInfo[2]), TextDrawShowForPlayer(l, GiftsInfo[1]);
    }
	//--------------------------------------------------------------------------
	format(cadou, 512, "{FFFFFF}Total Gifts: {FF0000}%d", CosminInfo[playerid][Gifts]);
	//--------------------------------------------------------------------------
	format(namestr, MAX_PLAYER_NAME+20, "{FFFFFF}Welcome %s !\n", PlayerName(playerid));
    //--------------------------------------------------------------------------
	switch(CosminInfo[playerid][Language])
	{
		case 0:
		{
            strcat(BigString, namestr);
            strcat(BigString,"{FF0000}Below you will find some information about gifts.\n\
                      \n\
                      {FFFFFF}Hello,I created this system for you, as a sign of thanks for choosing to play here.\n\
	   			      {FFFFFF}This system works very easily.\n\
                      {FFFFFF}When you will receive a gift,use the order {FF0000}/cadouri {FFFFFF}for open ghifts.\n\
                      {FFFFFF}Continue to have fun\n\
                      \n\
                      {FFFFFF}The Best Server: {6699FF}Romania {FFFF1A}Stunt {FF0000}Zone. {FFFFFF}Only For You.\n");
		    //------------------------------------------------------------------
            ShowPlayerDialog(playerid, GiftBoxRandom, DIALOG_STYLE_MSGBOX, cadou, BigString, "Next", "Close");
            return 1;
		}
	  	case 1:
		{
            strcat(BigString, namestr);
            strcat(BigString,"{FF0000}Mai jos vei gasi cateva informatii despre cadouri.\n\
                      \n\
                      {FFFFFF}Salut,am creat acest system pentru voi,in semn de multumire ca a-ti ales sa jucati aici.\n\
	   			      {FFFFFF}Acest system functioneaza foarte usor.\n\
                      {FFFFFF}Cand primiti un cadou,folositi comanda {FF0000}/cadouri {FFFFFF}pentru a deschide cadourile.\n\
                      {FFFFFF}Distractie placuta in continuare.\n\
                      \n\
                      {FFFFFF}Cel mai tare server: {6699FF}Romania {FFFF1A}Stunt {FF0000}Zone. {FFFFFF}Numai pentru tine.\n");
		}
	}
    return ShowPlayerDialog(playerid, GiftBoxRandom, DIALOG_STYLE_MSGBOX, cadou, BigString, "Next", "Close");
}
Gifts are diminishing when I write "/cadouri" but,not work so good..
Reply
#4

Which of the TXD is responsible for saying the gift number, as shown in this image (the number in red)
https://imgur.com/a/2x4RnhR
Reply
#5

Quote:
Originally Posted by ApolloScripter
Посмотреть сообщение
Which of the TXD is responsible for saying the gift number, as shown in this image (the number in red)
https://imgur.com/a/2x4RnhR
Код HTML:
CMD:giveallgift(playerid, params[])
{
    if(CosminInfo[playerid][King] < 1 && CosminInfo[playerid][ElPatron] < 1 && CosminInfo[playerid][Reaper] < 1 && CosminInfo[playerid][AccRcon] == 0 && CosminInfo[playerid][Management] < 1) return SendError2(playerid,"{FFFFFF}You must to be RCON Admin to use that command!", "{FFFFFF}Trebuie sa fi RCON Admin pentru a folosi comanda respectiva!");
    //--------------------------------------------------------------------------
    new LittleCounterg[10]; eString[0] = EOS;
	//--------------------------------------------------------------------------
	foreach(new i: Player) CosminInfo[i][Gifts] += 1, PlayerPlaySound(i, 1057, 0.0, 0.0, 0.0);
	CMDMessageToAdmins(playerid, "GiveAllGift");
    //--------------------------------------------------------------------------
    foreach(new i: Player) Announce(i, "~r~~h~Congratulations!~n~~g~~h~you got +1 gift!~n~~y~Open it with ~n~~r~~h~/ogifts!", 5000, 6);
	//--------------------------------------------------------------------------
	format(LittleCounterg, 10, "%d", CosminInfo[playerid][Gifts]); TextDrawSetString(GiftsInfo[2], LittleCounterg); foreach(new i: Player) TextDrawShowForPlayer(i, GiftsInfo[2]), TextDrawShowForPlayer(i, GiftsInfo[1]);
	//--------------------------------------------------------------------------
	format(eString, sizeof(eString), "Administrator %s gave you +1 Gift!", PlayerName(playerid));
	SendClientMessageToAll(COLOR_ABLUE, eString);
	//--------------------------------------------------------------------------
	eLog[0] = EOS; format(eLog, sizeof(eLog), "RCON : %s gave all +1 gift!", PlayerName(playerid)), SendLog(eLog);
	//--------------------------------------------------------------------------
	return 1;
}
That is it..
Reply
#6

"GiftsInfo[1]" or "GiftsInfo[2]" is the number of gifts that show in the right down side
Reply
#7

Quote:
Originally Posted by ApolloScripter
Посмотреть сообщение
"GiftsInfo[1]" or "GiftsInfo[2]" is the number of gifts that show in the right down side
"GiftsInfo[2]" is the number of gifts.
Reply
#8

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(strgsizeof(strg), "%i"GiftAmount[i])
  for(new 
0MAX_PLAYERSi++)
  {
    
PlayerTextDrawSetString(iGiftsInfo[i][2], strg);
    
PlayerTextDrawShow(iGiftsInfo[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(strgsizeof(strg), "%i"countdown[playerid])
  for(new 
0MAX_PLAYERSi++)
  {
    
PlayerTextDrawSetString(iGiftsInfo[i][2], strg);
    
PlayerTextDrawShow(iGiftsInfo[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(playeridRED"You Haven't gift!"); 
I hope you understood.
Reply
#9

Quote:
Originally Posted by ApolloScripter
Посмотреть сообщение
I hope you understood.
Yes,I understand,I wll try to make like that,thanks.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)