public Gift(playerid)
{
GiftPlayer(playerid, 1);
gifttimer[playerid] = 0;
gettinggift[playerid] = 0;
return 1;
}
stock GiftPlayer(giveplayerid, gifted = 0)
{
new string[256];
new randgift = Random(1, 100);
if(randgift >= 1 && randgift <= 83)
{
new gift = Random(1, 13);
if(gift == 1)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted $500!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
GiveMoney(giveplayerid, 500);
return 1;
}
else if(gift == 2)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 100 Gun parts!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pMats] += 100;
return 1;
}
else if(gift == 3)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 25 seeds!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pSeeds] += 25;
return 1;
}
else if(gift == 7)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 3 cookies!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pCookies] += 3;
return 1;
}
else if(gift == 8)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted full health!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
SetPlayerHealth(giveplayerid, 100);
return 1;
}
else if(gift == 9)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted full armour!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
SetPlayerArmour(giveplayerid, 100);
return 1;
}
else if(gift == 10)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a full weapon set!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
GivePlayerGun(giveplayerid, 24);
GivePlayerGun(giveplayerid, 27);
GivePlayerGun(giveplayerid, 31);
GivePlayerGun(giveplayerid, 29);
GivePlayerGun(giveplayerid, 34);
return 1;
}
else if(gift == 11)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted nothing, Sucks for them!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
return 1;
}
else if(gift == 12)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a level up!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pLevel]++;
return 1;
}
}
else if(randgift > 83 && randgift <= 98)
{
new gift = Random(1, 12);
if(gift == 1)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted $2,000!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
GiveMoney(giveplayerid, 2000);
return 1;
}
else if(gift == 2)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 2,000 gun parts!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pMats] += 2000;
return 1;
}
else if(gift == 3)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 100 seeds!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pSeeds] += 100;
return 1;
}
else if(gift == 7)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a free car!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
SendClientMessage(giveplayerid, GREY, "It may take up to 24 hours to receive your car.");
format(string, sizeof(string), "WARNING: %s was just gifted a free car.", PlayerName(giveplayerid));
ABroadCast(RED, string, 1337);
new logstring[256];
new year, month, day;
getdate(year, month, day);
format(logstring, sizeof(logstring), "WARNING: %s was just gifted a free car.",PlayerName(giveplayerid),month,day,year);
GiftLog(logstring);
return 1;
}
else if(gift == 8)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 25 cookies!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pCookies] += 25;
return 1;
}
else if(gift == 9)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a triple level up!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pLevel] += 3;
return 1;
}
else if(gift == 11)
{
if (PlayerInfo[giveplayerid][pDonateRank] >= 1) return SendClientMessage(giveplayerid, GREY, "You would of won a 24 hour Bronze VIP pass, but you're already VIP!");
new year, month, day;
getdate(year, month, day);
format(string, sizeof(string), "* Congratulations! %s was just gifted a 1 month Bronze VIP subscription!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
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(1, 12);
if(gift == 2)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a Flamethrower!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
GivePlayerGun(giveplayerid, 37);
return 1;
}
else if(gift == 3)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a free house!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
SendClientMessage(giveplayerid, GREY, "It may take up to 24 hours to receive your house.");
format(string, sizeof(string), "WARNING: %s was just gifted a free house.", PlayerName(giveplayerid));
ABroadCast(RED, string, 1337);
new logstring[256];
new year, month, day;
getdate(year, month, day);
format(logstring, sizeof(logstring), "WARNING: %s was just gifted a free house.",PlayerName(giveplayerid),month,day,year);
GiftLog(logstring);
return 1;
}
else if(gift == 4)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted a free business!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
SendClientMessage(giveplayerid, GREY, "It may take up to 24 hours to receive your business.");
format(string, sizeof(string), "WARNING: %s was just gifted a free business.", PlayerName(giveplayerid));
ABroadCast(RED, string, 1337);
new logstring[256];
new year, month, day;
getdate(year, month, day);
format(logstring, sizeof(logstring), "WARNING: %s was just gifted a free business.",PlayerName(giveplayerid),month,day,year);
GiftLog(logstring);
return 1;
}
else if(gift == 5)
{
new year, month, day;
getdate(year, month, day);
format(string, sizeof(string), "* Congratulations! %s was just gifted a 1 month Silver VIP subscription!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
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(string, sizeof(string), "* Congratulations! %s was just gifted $15,000!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
GiveMoney(giveplayerid, 15000);
return 1;
}
else if(gift == 7)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 7,500 gun parts!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pMats] += 7500;
return 1;
}
else if(gift == 8)
{
format(string, sizeof(string), "* Congratulations! %s was just gifted 1000 seeds!", PlayerName(giveplayerid));
SendClientMessageToAll(YELLOW, string);
PlayerInfo[giveplayerid][pSeeds] += 1000;
return 1;
}
}
if (gifted == 1) gifttimer[giveplayerid] = 3600;
return 1;
}
if(strcmp(cmd, "/giftbox", true) == 0)
{
if(PlayerInfo[playerid][pAdmin] >= 5)
{
if(!giftsenabled)
{
new randbox = random(6);
switch(randbox)
{
case 0: randbox = 19058;
case 1: randbox = 19056;
case 2: randbox = 19055;
case 3: randbox = 19057;
case 4: randbox = 19054;
case 5, 6: randbox = 19056;
}
new Float:x, Float:y, Float:z, Float:a, location[MAX_ZONE_NAME];
GetPlayerPos(playerid, x, y, z);
GetPlayerFacingAngle(playerid, a);
dynamicgift = CreateDynamicObject(randbox, x, y, z-0.4, 0.0, 0.0, a, -1, -1, -1, 200.0);
dynamicgift3DText = CreateStreamed3DTextLabel("/getgift",LIGHTBLUE, x, y, z+0.25,8.0,GetPlayerVirtualWorld(playerid));
SetPlayerPosEx(playerid, x, y, z+3);
giftsenabled = 1;
Get2DZone(location, MAX_ZONE_NAME, x, y, z);
format(string, sizeof(string), "{FF6347}%s has enabled gifts @ %s (%f, %f, %f)",PlayerName(playerid), location, x, y, z);
ABroadCast(RED, string, 5);
format(string, sizeof(string), "* %s would like you to come to %s to receive free gifts and to enjoy yourself.", PlayerName(playerid), location);
SendClientMessageToAll(LIGHTBLUE, string);
return 1;
}
else
{
new Float:x, Float:y, Float:z, location[MAX_ZONE_NAME];
GetPlayerPos(playerid, x, y, z);
Get2DZone(location, MAX_ZONE_NAME, x, y, z);
giftsenabled = 0;
DestroyDynamicObject(dynamicgift);
DestroyDynamic3DTextLabel(dynamicgift3DText);
format(string, sizeof(string), "{FF6347}%s has disabled the gift box.",PlayerName(playerid));
ABroadCast(RED, string, 5);
format(string, sizeof(string), "* Gifts at %s are now over. Enjoy your gift!", location);
SendClientMessageToAll(LIGHTBLUE, string);
}
return 1;
}
else
{
SendClientMessage(playerid, GREY, " You are not authorized to use that command.");
}
return 1;
}
if(strcmp(cmd, "/getgift", true) == 0)
{
if(giftsenabled)
{
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))
{
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);
return 1;
}
else
{
SendClientMessage(playerid, GREY, "You are not near the gift box.");
return 1;
}
}
else
{
SendClientMessage(playerid, GREY, "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(playerid, GREY, " You must wait 3 seconds before opening another gift.");
}
else
{
SendClientMessage(playerid, GREY, " You don't have any gifts to open.");
return 1;
}
}
return 1;
}
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;
}
...
pawn Код:
|
Have you changed the timer? Because 1 second...
SetTimerEx("Gift", 1000, false, "i", playerid); |
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;
}
Meh.. i will try to explain you a bit of "your" code
pawn Код:
|