Giftbox issue
#1

So before I was having an issue with my giftbox where it would not let a player get a gift, because it said that you received one within the last hour already, although you hadn't. Now I have another issue with it, that I only just recently discovered. When someone types /getgift, it will allow them to get the gift, but then they can just re-type it immediately. It's supposed to have an hour delay. What is my problem?

PHP код:
public Gift(playerid)
{
    
GiftPlayer(playerid1);
    
gifttimer[playerid] = 0;
    
gettinggift[playerid] = 0;
    return 
1;

PHP код:
stock GiftPlayer(giveplayeridgifted 0)
{
    new 
string[256];
    new 
randgift Random(1100);
    if(
randgift >= && randgift <= 83)
    {
         new 
gift Random(113);
         if(
gift == 1)
         {
            
format(stringsizeof(string), "* Congratulations! %s was just gifted $500!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
GiveMoney(giveplayerid500);
            return 
1;
         }
         else if(
gift == 2)
         {
             
format(stringsizeof(string), "* Congratulations! %s was just gifted 100 Gun parts!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pMats] += 100;
            return 
1;
        }
        else if(
gift == 3)
        {
            
format(stringsizeof(string), "* Congratulations! %s was just gifted 25 seeds!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pSeeds] += 25;
             return 
1;
        }
          else if(
gift == 7)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted 3 cookies!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pCookies] += 3;
             return 
1;
        }
        else if(
gift == 8)
        {
            
format(stringsizeof(string), "* Congratulations! %s was just gifted full health!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
SetPlayerHealth(giveplayerid100);
             return 
1;
          }
          else if(
gift == 9)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted full armour!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
            
SetPlayerArmour(giveplayerid100);
            return 
1;
        }
        else if(
gift == 10)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted a full weapon set!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
GivePlayerGun(giveplayerid24);
             
GivePlayerGun(giveplayerid27);
             
GivePlayerGun(giveplayerid31);
             
GivePlayerGun(giveplayerid29);
             
GivePlayerGun(giveplayerid34);
             return 
1;
          }
          else if(
gift == 11)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted nothing, Sucks for them!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             return 
1;
        }
        else if(
gift == 12)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted a level up!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pLevel]++;
             return 
1;
        }
    }
    else if(
randgift 83 && randgift <= 98)
    {
        new 
gift Random(112);
         if(
gift == 1)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted $2,000!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
GiveMoney(giveplayerid2000);
             return 
1;
        }
        else if(
gift == 2)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted 2,000 gun parts!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pMats] += 2000;
             return 
1;
        }
        else if(
gift == 3)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted 100 seeds!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pSeeds] += 100;
             return 
1;
        }
        else if(
gift == 7)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted a free car!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
SendClientMessage(giveplayeridGREY"It may take up to 24 hours to receive your car.");
             
format(stringsizeof(string), "WARNING: %s was just gifted a free car."PlayerName(giveplayerid));
            
ABroadCast(REDstring1337);
            new 
logstring[256];
            new 
yearmonthday;
            
getdate(yearmonthday);
            
format(logstringsizeof(logstring), "WARNING: %s was just gifted a free car.",PlayerName(giveplayerid),month,day,year);
            
GiftLog(logstring);
             return 
1;
        }
        else if(
gift == 8)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted 25 cookies!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pCookies] += 25;
             return 
1;
        }
        else if(
gift == 9)
          {
              
format(stringsizeof(string), "* Congratulations! %s was just gifted a triple level up!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
PlayerInfo[giveplayerid][pLevel] += 3;
             return 
1;
        }
        else if(
gift == 11)
          {
            if (
PlayerInfo[giveplayerid][pDonateRank] >= 1) return SendClientMessage(giveplayeridGREY"You would of won a 24 hour Bronze VIP pass, but you're already VIP!");
              new 
yearmonthday;
            
getdate(yearmonthday);
              
format(stringsizeof(string), "* Congratulations! %s was just gifted a 1 month Bronze VIP subscription!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
            
PlayerInfo[giveplayerid][pDonateRank] = 1;
            
PlayerInfo[giveplayerid][pVIPJoinDate][1] = day;
            
PlayerInfo[giveplayerid][pVIPJoinDate][2] = month;
            
PlayerInfo[giveplayerid][pVIPJoinDate][3] = year;
            
PlayerInfo[giveplayerid][pVIPExpDate][1] = day;
            if ((
month 1) <= 12)
            {
                
PlayerInfo[giveplayerid][pVIPExpDate][2] = month 1;
                
PlayerInfo[giveplayerid][pVIPExpDate][3] = year;
            }
            if ((
month 1) == 13)
            {
                
PlayerInfo[giveplayerid][pVIPExpDate][2] = 1;
                
PlayerInfo[giveplayerid][pVIPExpDate][3] = year 1;
            }
            return 
1;
        }
    }
    else if(
randgift 98 && randgift <= 100)
    {
        new 
gift Random(112);
        if(
gift == 2)
        {
            
format(stringsizeof(string), "* Congratulations! %s was just gifted a Flamethrower!"PlayerName(giveplayerid));
             
SendClientMessageToAll(YELLOWstring);
             
GivePlayerGun(giveplayerid37);
             return 
1;
          }
        else if(
gift == 3)
        {
            
format(stringsizeof(string), "* Congratulations! %s was just gifted a free house!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
SendClientMessage(giveplayeridGREY"It may take up to 24 hours to receive your house.");
             
format(stringsizeof(string), "WARNING: %s was just gifted a free house."PlayerName(giveplayerid));
            
ABroadCast(REDstring1337);
            new 
logstring[256];
            new 
yearmonthday;
            
getdate(yearmonthday);
            
format(logstringsizeof(logstring), "WARNING: %s was just gifted a free house.",PlayerName(giveplayerid),month,day,year);
            
GiftLog(logstring);
            return 
1;
        }
        else if(
gift == 4)
        {
            
format(stringsizeof(string), "* Congratulations! %s was just gifted a free business!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
SendClientMessage(giveplayeridGREY"It may take up to 24 hours to receive your business.");
             
format(stringsizeof(string), "WARNING: %s was just gifted a free business."PlayerName(giveplayerid));
            
ABroadCast(REDstring1337);
            new 
logstring[256];
            new 
yearmonthday;
            
getdate(yearmonthday);
            
format(logstringsizeof(logstring), "WARNING: %s was just gifted a free business.",PlayerName(giveplayerid),month,day,year);
            
GiftLog(logstring);
            return 
1;
        }
        else if(
gift == 5)
        {
               new 
yearmonthday;
            
getdate(yearmonthday);
             
format(stringsizeof(string), "* Congratulations! %s was just gifted a 1 month Silver VIP subscription!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
PlayerInfo[giveplayerid][pDonateRank] = 2;
            
PlayerInfo[giveplayerid][pVIPJoinDate][1] = day;
            
PlayerInfo[giveplayerid][pVIPJoinDate][2] = month;
            
PlayerInfo[giveplayerid][pVIPJoinDate][3] = year;
            
PlayerInfo[giveplayerid][pVIPExpDate][1] = day;
            if ((
month 1) <= 12)
            {
                
PlayerInfo[giveplayerid][pVIPExpDate][2] = month 1;
                
PlayerInfo[giveplayerid][pVIPExpDate][3] = year;
            }
            if ((
month 1) == 13)
            {
                
PlayerInfo[giveplayerid][pVIPExpDate][2] = 1;
                
PlayerInfo[giveplayerid][pVIPExpDate][3] = year 1;
            }
            return 
1;
           }
           else if(
gift == 6)
           {
               
format(stringsizeof(string), "* Congratulations! %s was just gifted $15,000!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
GiveMoney(giveplayerid15000);
            return 
1;
        }
        else if(
gift == 7)
           {
               
format(stringsizeof(string), "* Congratulations! %s was just gifted 7,500 gun parts!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
PlayerInfo[giveplayerid][pMats] += 7500;
            return 
1;
        }
        else if(
gift == 8)
        {
               
format(stringsizeof(string), "* Congratulations! %s was just gifted 1000 seeds!"PlayerName(giveplayerid));
            
SendClientMessageToAll(YELLOWstring);
            
PlayerInfo[giveplayerid][pSeeds] += 1000;
            return 
1;
        }
    }
    if (
gifted == 1gifttimer[giveplayerid] = 3600;
    return 
1;

PHP код:
        if(strcmp(cmd"/giftbox"true) == 0)
    {
        if(
PlayerInfo[playerid][pAdmin] >= 5)
        {
            if(!
giftsenabled)
            {
                new 
randbox random(6);
                switch(
randbox)
                {
                    case 
0randbox 19058;
                    case 
1randbox 19056;
                    case 
2randbox 19055;
                    case 
3randbox 19057;
                    case 
4randbox 19054;
                    case 
56randbox 19056;
                }
                new 
Float:xFloat:yFloat:zFloat:alocation[MAX_ZONE_NAME];
                
GetPlayerPos(playeridxyz);
                
GetPlayerFacingAngle(playerida);
                
dynamicgift CreateDynamicObject(randboxxyz-0.40.00.0a, -1, -1, -1200.0);
                
dynamicgift3DText CreateStreamed3DTextLabel("/getgift",LIGHTBLUExyz+0.25,8.0,GetPlayerVirtualWorld(playerid));
                
SetPlayerPosEx(playeridxyz+3);
                
giftsenabled 1;
                
Get2DZone(locationMAX_ZONE_NAMExyz);
                
format(stringsizeof(string), "{FF6347}%s has enabled gifts @ %s (%f, %f, %f)",PlayerName(playerid), locationxyz);
                
ABroadCast(REDstring5);
                
format(stringsizeof(string), "* %s would like you to come to %s to receive free gifts and to enjoy yourself."PlayerName(playerid), location);
                
SendClientMessageToAll(LIGHTBLUEstring);
                return 
1;
            }
            else
            {
                new 
Float:xFloat:yFloat:zlocation[MAX_ZONE_NAME];
                
GetPlayerPos(playeridxyz);
                
Get2DZone(locationMAX_ZONE_NAMExyz);
                
giftsenabled 0;
                
DestroyDynamicObject(dynamicgift);
                
DestroyDynamic3DTextLabel(dynamicgift3DText);
                
format(stringsizeof(string), "{FF6347}%s has disabled the gift box.",PlayerName(playerid));
                
ABroadCast(REDstring5);
                
format(stringsizeof(string), "* Gifts at %s are now over. Enjoy your gift!"location);
                
SendClientMessageToAll(LIGHTBLUEstring);
            }
            return 
1;
        }
        else
        {
            
SendClientMessage(playeridGREY"    You are not authorized to use that command.");
          }
          return 
1;
    } 
PHP код:
    if(strcmp(cmd"/getgift"true) == 0)
    {
        if(
giftsenabled)
        {
            if(
gifttimer[playerid]) return SendClientMessage(playeridGREY"You must wait an hour before getting another gift.");
            new 
Float:xFloat:yFloat:z;
            
GetDynamicObjectPos(dynamicgiftxyz);
            if(
gettinggift[playerid]) return 1;
            if(
IsPlayerInRangeOfPoint(playerid3.0xyz))
            {
                
gettinggift[playerid] = 1;
                
format(stringsizeof(string), "* %s reaches inside the box with their eyes closed and grabs something."PlayerName(playerid));
                
ProxDetector(30.0playeridstringPURPLEPURPLEPURPLEPURPLEPURPLE);
                
SetTimerEx("Gift"1000false"i"playerid);
                return 
1;
            }
            else
            {
                
SendClientMessage(playeridGREY"You are not near the gift box.");
                return 
1;
               }
        }
        else
        {
            
SendClientMessage(playeridGREY"Gifts are disabled. Please try again later.");
          }
          return 
1;
    }
        if(
strcmp(cmd"/open"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
            if(
PlayerInfo[playerid][pGiftBoxes] > 0)
            {
                if (
GetPVarInt(playerid"GiftWait") == 0)
                {
                    
PlayerInfo[playerid][pGiftBoxes]--;
                    
GiftPlayer(playerid);
                    
SetPVarInt(playerid"GiftWait"3);
                    return 
1;
                }
                else return 
SendClientMessage(playeridGREY"    You must wait 3 seconds before opening another gift.");
            }
            else
            {
                
SendClientMessage(playeridGREY"    You don't have any gifts to open.");
                return 
1;
            }
        }
        return 
1;
    } 
Reply
#2

pawn Код:
public Gift(playerid)
{
    GiftPlayer(playerid, 1);
    gifttimer[playerid] = 0;
    gettinggift[playerid] = 0;
    giftsenabled = 1;//try this
    return 1;
}  

and here
...
if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
            {
                gettinggift[playerid] = 1;
                giftsenabled = 0;/////////////////////
                format(string, sizeof(string), "* %s reaches inside the box with their eyes closed and grabs something.", PlayerName(playerid));
                ProxDetector(30.0, playerid, string, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
                SetTimerEx("Gift", 1000, false, "i", playerid);
                return 1;
            }
...
Reply
#3

Quote:
Originally Posted by Matess
Посмотреть сообщение
pawn Код:
public Gift(playerid)
{
    GiftPlayer(playerid, 1);
    gifttimer[playerid] = 0;
    gettinggift[playerid] = 0;
    giftsenabled = 1;//try this
    return 1;
}  

and here
...
if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
            {
                gettinggift[playerid] = 1;
                giftsenabled = 0;/////////////////////
                format(string, sizeof(string), "* %s reaches inside the box with their eyes closed and grabs something.", PlayerName(playerid));
                ProxDetector(30.0, playerid, string, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
                SetTimerEx("Gift", 1000, false, "i", playerid);
                return 1;
            }
...
Nope, this didn't work.
Reply
#4

Have you changed the timer? Because 1 second...

SetTimerEx("Gift", 1000, false, "i", playerid);
Reply
#5

Quote:
Originally Posted by Matess
Посмотреть сообщение
Have you changed the timer? Because 1 second...

SetTimerEx("Gift", 1000, false, "i", playerid);
1 second is 1000? So then an hour is 3,600,000 right?
Reply
#6

Yeah but for testing try 15000 or something
Reply
#7

I took out the giftsenabled bit from the two areas you told me to put it in, I don't think it will mess anything up, so should I keep it out for now?
Reply
#8

Quote:
Originally Posted by Matess
Посмотреть сообщение
Yeah but for testing try 15000 or something
All this did was make it take longer for it to give you your gift.
Reply
#9

Meh.. i will try to explain you a bit of "your" code

pawn Код:
if(giftsenabled) // If this variable is 1 the code will continue and you will recieve gift, so it means that you must set this variable on 0 if you want to skip this process for some time
        {
            if(gifttimer[playerid]) return SendClientMessage(playerid, GREY, "You must wait an hour before getting another gift.");
            new Float:x, Float:y, Float:z;
            GetDynamicObjectPos(dynamicgift, x, y, z);
            if(gettinggift[playerid]) return 1;
            if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
            {
                //When is everything correct, then you will get your gift
                giftsenabled = 0;//So you can block this part of code for some time
                gettinggift[playerid] = 1;

                format(string, sizeof(string), "* %s reaches inside the box with their eyes closed and grabs something.", PlayerName(playerid));
                ProxDetector(30.0, playerid, string, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
                SetTimerEx("Gift", 1000, false, "i", playerid); //you will block it for an hour (3600000) and then
                return 1;
            }
            else
            {
                SendClientMessage(playerid, GREY, "You are not near the gift box.");
                return 1;
               }
...

public Gift(playerid) //this will be processed every 1 hour
{
    GiftPlayer(playerid, 1);
    gifttimer[playerid] = 0;
    gettinggift[playerid] = 0;
    giftsenabled = 1;//and there you will enable the /getgift command
    return 1;
}
Reply
#10

Quote:
Originally Posted by Matess
Посмотреть сообщение
Meh.. i will try to explain you a bit of "your" code

pawn Код:
if(giftsenabled) // If this variable is 1 the code will continue and you will recieve gift, so it means that you must set this variable on 0 if you want to skip this process for some time
        {
            if(gifttimer[playerid]) return SendClientMessage(playerid, GREY, "You must wait an hour before getting another gift.");
            new Float:x, Float:y, Float:z;
            GetDynamicObjectPos(dynamicgift, x, y, z);
            if(gettinggift[playerid]) return 1;
            if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
            {
                //When is everything correct, then you will get your gift
                giftsenabled = 0;//So you can block this part of code for some time
                gettinggift[playerid] = 1;

                format(string, sizeof(string), "* %s reaches inside the box with their eyes closed and grabs something.", PlayerName(playerid));
                ProxDetector(30.0, playerid, string, PURPLE, PURPLE, PURPLE, PURPLE, PURPLE);
                SetTimerEx("Gift", 1000, false, "i", playerid); //you will block it for an hour (3600000) and then
                return 1;
            }
            else
            {
                SendClientMessage(playerid, GREY, "You are not near the gift box.");
                return 1;
               }
...

public Gift(playerid) //this will be processed every 1 hour
{
    GiftPlayer(playerid, 1);
    gifttimer[playerid] = 0;
    gettinggift[playerid] = 0;
    giftsenabled = 1;//and there you will enable the /getgift command
    return 1;
}
All changing the timer does is change the amount of time it takes for the box to get your gift. So during the trial, setting it to 15,000, (15 seconds I think), just makes it so the box takes 15 seconds to give you your gift. Either I'm not understanding something or changing the timer does absolutely nothing.
Reply


Forum Jump:


Users browsing this thread: 4 Guest(s)