Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // MafiaOink's XMas GiftBox System v1.0 //
- /*
- * Initial Release
- This is a giftbox system so it will get prizes from your script, a function:
- public OnPlayerRetrieveGift(playerid, gift)
- will be called and the gift is random, You can edit it..
- Dont forget to add that function on your main gm and add prizes yourself
- */
- #include <a_samp>
- #include <Dini>
- #include <zcmd>
- #define MAX_GIFTID 5 // Ur setting not mine / This System never returns random gift id as 0! only 1 and more, even if u make it MAX_GIFTID 0 it wont return to prevent glitch
- new Cooldown[MAX_PLAYERS];
- #define GiftCoolDown 3600 // How much seconds? 1 hour = 3600 half hour = 1300 1 min = 60 10 min = 600 half min = 30
- stock GetPlayerNameEx(playerid)
- {
- new CName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, CName, MAX_PLAYER_NAME);
- return CName;
- }
- stock GetPlayerAccountPath(playerid)
- {
- new path[128];
- format(path, sizeof(path), "/MoGiftbox/%s.ini", GetPlayerNameEx(playerid));
- return path;
- }
- // Uncomment the line below to enable SNOW(might be laggy for noob pc)
- //#define Snow_Enable
- new XMasObject[9];
- public OnFilterScriptInit()
- {
- print("XMas Giftbox 0.3.7 has been Loaded\nBy MafiaOink\nHas a gift system near tree at mulholland!");
- XMasObject[0] = CreateObject(19076, 1376.81421, -1101.88611, 23.34148, 0.00000, 0.00000, 0.00000);
- XMasObject[1] = CreateObject(19054, 1374.91821, -1102.08887, 24.02473, 0.00000, 0.00000, 24.34395);
- XMasObject[2] = CreateObject(19055, 1375.42529, -1100.02661, 24.01450, 0.00000, 0.00000, 0.00000);
- XMasObject[3] = CreateObject(19056, 1373.51965, -1101.07129, 24.01930, 0.00000, 0.00000, 0.00000);
- XMasObject[4] = CreateObject(19064, 1373.07971, -1100.65381, 24.55350, 0.00000, 40.00000, 131.86729);
- XMasObject[5] = CreateObject(19057, 1377.66382, -1100.22583, 23.98165, 0.00000, 0.00000, 0.00000);
- XMasObject[6] = CreateObject(19058, 1378.35156, -1102.72412, 23.86090, 0.00000, 0.00000, 0.00000);
- XMasObject[7] = CreateObject(19063, 1376.68970, -1101.77039, 36.35170, 180.00000, 0.00000, 0.00000);
- #if defined Snow_Enable
- XMasObject[8] = CreateObject(18864, 1362.55774, -1099.42810, 25.72931, 0.00000, 0.00000, 0.00000);
- #endif
- SetTimer("SecondUpdate", 1150, true);
- SetTimer("SaveAll", 10000, true);
- return 1;
- }
- forward SaveAll();
- public SaveAll()
- {
- for(new pl=0;pl<GetPlayerPoolSize();pl++)
- {
- if(IsPlayerConnected(pl))
- {
- if(dini_Exists(GetPlayerAccountPath(pl))) dini_IntSet(GetPlayerAccountPath(pl), "Cooldown", Cooldown[pl]);
- }
- }
- return 1;
- }
- forward SecondUpdate();
- public SecondUpdate()
- {
- for(new pl=0;pl<MAX_PLAYERS ;pl++)
- {
- if(IsPlayerConnected(pl))
- {
- if(Cooldown[pl] != 0)
- {
- Cooldown[pl]--;
- }
- }
- }
- return 1;
- }
- public OnFilterScriptExit()
- {
- print("XMas 0.3.7 is now exiting\nDeleting objects...");
- for(new Object=0;Object<sizeof(XMasObject);Object++)
- {
- if(IsValidObject(Object))
- {
- printf("Object %d of this filterscript has been removed", Object);
- DestroyObject(XMasObject[Object]);
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- Cooldown[playerid] = 0;
- if(dini_Exists(GetPlayerAccountPath(playerid)))
- {
- Cooldown[playerid] = dini_Int(GetPlayerAccountPath(playerid), "Cooldown");
- }
- else
- {
- dini_Create(GetPlayerAccountPath(playerid));
- dini_IntSet(GetPlayerAccountPath(playerid), "Cooldown", 0);
- }
- return 1;
- }
- CMD:giftbox(playerid, params[])
- {
- if(IsPlayerInRangeOfPoint(playerid, 10.0, 1376.81421, -1101.88611, 23.34148))
- {
- if(Cooldown[playerid] == 0)
- {
- new randomid = random(MAX_GIFTID);
- if(randomid == 0) return cmd_giftbox(playerid, params);
- // THIS SCRIPT NEVER RETURNS RANDOM GIFTBOX ID AS 0!! BEWARE
- SendClientMessage(playerid, 0xAFAFAFAA, "You close your eyes and slowly open the giftbox......");
- CallRemoteFunction("OnPlayerRetrieveGift", "dd", playerid, randomid);
- Cooldown[playerid] = 3600;
- }
- else
- {
- new str[128];
- format(str, 128, "{FF0000}You are still on a cooldown of %d minutes(%d seconds)", Cooldown[playerid]/60, Cooldown[playerid]);
- SendClientMessage(playerid, -1, str);
- }
- }
- else
- {
- new str[128];
- format(str, 128, "{FF0000}You are not near the XMas Tree, Distance: %0.2f meters", GetPlayerDistanceFromPoint(playerid, 1376.81421, -1101.88611, 23.34148));
- SendClientMessage(playerid, -1, str);
- }
- return 1;
- }
Add Comment
Please, Sign In to add comment