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


Messages In This Thread
Giftbox issue - by K9IsGodly - 13.03.2014, 20:43
Re: Giftbox issue - by Matess - 13.03.2014, 20:47
Re: Giftbox issue - by K9IsGodly - 13.03.2014, 21:07
Re: Giftbox issue - by Matess - 13.03.2014, 21:11
Re: Giftbox issue - by K9IsGodly - 13.03.2014, 21:17
Re: Giftbox issue - by Matess - 13.03.2014, 21:17
Re: Giftbox issue - by K9IsGodly - 13.03.2014, 21:19
Re: Giftbox issue - by K9IsGodly - 13.03.2014, 21:25
Re: Giftbox issue - by Matess - 13.03.2014, 21:25
Re: Giftbox issue - by K9IsGodly - 13.03.2014, 21:43

Forum Jump:


Users browsing this thread: 3 Guest(s)