KevY007

MafiaOink's Xmas Giftbox System v1.0

Dec 30th, 2015
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.44 KB | None | 0 0
  1. // MafiaOink's XMas GiftBox System v1.0 //
  2.  
  3. /*
  4.  
  5. * Initial Release
  6.  
  7. This is a giftbox system so it will get prizes from your script, a function:
  8. public OnPlayerRetrieveGift(playerid, gift)
  9. will be called and the gift is random, You can edit it..
  10.  
  11. Dont forget to add that function on your main gm and add prizes yourself
  12. */
  13.  
  14. #include <a_samp>
  15. #include <Dini>
  16. #include <zcmd>
  17.  
  18. #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
  19.  
  20. new Cooldown[MAX_PLAYERS];
  21.  
  22. #define GiftCoolDown 3600 // How much seconds? 1 hour = 3600 half hour = 1300 1 min = 60 10 min = 600 half min = 30
  23.  
  24. stock GetPlayerNameEx(playerid)
  25. {
  26.     new CName[MAX_PLAYER_NAME];
  27.     GetPlayerName(playerid, CName, MAX_PLAYER_NAME);
  28.     return CName;
  29. }
  30.  
  31. stock GetPlayerAccountPath(playerid)
  32. {
  33.     new path[128];
  34.     format(path, sizeof(path), "/MoGiftbox/%s.ini", GetPlayerNameEx(playerid));
  35.     return path;
  36. }
  37.  
  38. // Uncomment the line below to enable SNOW(might be laggy for noob pc)
  39. //#define Snow_Enable
  40.  
  41. new XMasObject[9];
  42.  
  43. public OnFilterScriptInit()
  44. {
  45.     print("XMas Giftbox 0.3.7 has been Loaded\nBy MafiaOink\nHas a gift system near tree at mulholland!");
  46.     XMasObject[0] = CreateObject(19076, 1376.81421, -1101.88611, 23.34148,   0.00000, 0.00000, 0.00000);
  47.     XMasObject[1] = CreateObject(19054, 1374.91821, -1102.08887, 24.02473,   0.00000, 0.00000, 24.34395);
  48.     XMasObject[2] = CreateObject(19055, 1375.42529, -1100.02661, 24.01450,   0.00000, 0.00000, 0.00000);
  49.     XMasObject[3] = CreateObject(19056, 1373.51965, -1101.07129, 24.01930,   0.00000, 0.00000, 0.00000);
  50.     XMasObject[4] = CreateObject(19064, 1373.07971, -1100.65381, 24.55350,   0.00000, 40.00000, 131.86729);
  51.     XMasObject[5] = CreateObject(19057, 1377.66382, -1100.22583, 23.98165,   0.00000, 0.00000, 0.00000);
  52.     XMasObject[6] = CreateObject(19058, 1378.35156, -1102.72412, 23.86090,   0.00000, 0.00000, 0.00000);
  53.     XMasObject[7] = CreateObject(19063, 1376.68970, -1101.77039, 36.35170,   180.00000, 0.00000, 0.00000);
  54.     #if defined Snow_Enable
  55.     XMasObject[8] = CreateObject(18864, 1362.55774, -1099.42810, 25.72931,   0.00000, 0.00000, 0.00000);
  56.     #endif
  57.    
  58.     SetTimer("SecondUpdate", 1150, true);
  59.     SetTimer("SaveAll", 10000, true);
  60.     return 1;
  61. }
  62.  
  63. forward SaveAll();
  64. public SaveAll()
  65. {
  66.     for(new pl=0;pl<GetPlayerPoolSize();pl++)
  67.     {
  68.         if(IsPlayerConnected(pl))
  69.         {
  70.             if(dini_Exists(GetPlayerAccountPath(pl))) dini_IntSet(GetPlayerAccountPath(pl), "Cooldown", Cooldown[pl]);
  71.         }
  72.     }
  73.     return 1;
  74. }
  75.  
  76. forward SecondUpdate();
  77. public SecondUpdate()
  78. {
  79.     for(new pl=0;pl<MAX_PLAYERS ;pl++)
  80.     {
  81.         if(IsPlayerConnected(pl))
  82.         {
  83.             if(Cooldown[pl] != 0)
  84.             {
  85.                 Cooldown[pl]--;
  86.             }
  87.         }
  88.     }
  89.     return 1;
  90. }
  91.  
  92. public OnFilterScriptExit()
  93. {
  94.     print("XMas 0.3.7 is now exiting\nDeleting objects...");
  95.     for(new Object=0;Object<sizeof(XMasObject);Object++)
  96.     {
  97.         if(IsValidObject(Object))
  98.         {
  99.             printf("Object %d of this filterscript has been removed", Object);
  100.             DestroyObject(XMasObject[Object]);
  101.         }
  102.     }
  103.     return 1;
  104. }
  105.  
  106. public OnPlayerConnect(playerid)
  107. {
  108.     Cooldown[playerid] = 0;
  109.     if(dini_Exists(GetPlayerAccountPath(playerid)))
  110.     {
  111.         Cooldown[playerid] = dini_Int(GetPlayerAccountPath(playerid), "Cooldown");
  112.     }
  113.     else
  114.     {
  115.         dini_Create(GetPlayerAccountPath(playerid));
  116.         dini_IntSet(GetPlayerAccountPath(playerid), "Cooldown", 0);
  117.     }
  118.     return 1;
  119. }
  120.  
  121. CMD:giftbox(playerid, params[])
  122. {
  123.     if(IsPlayerInRangeOfPoint(playerid, 10.0, 1376.81421, -1101.88611, 23.34148))
  124.     {
  125.         if(Cooldown[playerid] == 0)
  126.         {
  127.             new randomid = random(MAX_GIFTID);
  128.             if(randomid == 0) return cmd_giftbox(playerid, params);
  129.             // THIS SCRIPT NEVER RETURNS RANDOM GIFTBOX ID AS 0!! BEWARE
  130.             SendClientMessage(playerid, 0xAFAFAFAA, "You close your eyes and slowly open the giftbox......");
  131.             CallRemoteFunction("OnPlayerRetrieveGift", "dd", playerid, randomid);
  132.             Cooldown[playerid] = 3600;
  133.         }
  134.         else
  135.         {
  136.             new str[128];
  137.             format(str, 128, "{FF0000}You are still on a cooldown of %d minutes(%d seconds)", Cooldown[playerid]/60, Cooldown[playerid]);
  138.             SendClientMessage(playerid, -1, str);
  139.         }
  140.     }
  141.     else
  142.     {
  143.         new str[128];
  144.         format(str, 128, "{FF0000}You are not near the XMas Tree, Distance: %0.2f meters", GetPlayerDistanceFromPoint(playerid, 1376.81421, -1101.88611, 23.34148));
  145.         SendClientMessage(playerid, -1, str);
  146.     }
  147.     return 1;
  148. }
Add Comment
Please, Sign In to add comment