1
0

stpatricks.pwn 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. new bool:StPatricksShop = false;
  2. CMD:togstpatricksshop(playerid, params[])
  3. {
  4. if(PlayerInfo[playerid][pAdmin] > 1337 || PlayerInfo[playerid][pPR] == 2 || PlayerInfo[playerid][pShopTech] == 3)
  5. {
  6. if(!StPatricksShop)
  7. StPatricksShop = true, SendClientMessageEx(playerid, COLOR_RED, "You have toggled the St Patrick's Day shop on. It will now be available to players.");
  8. else
  9. StPatricksShop = false, SendClientMessageEx(playerid, COLOR_RED, "You have toggled the St Patrick's Day shop off. It will not be available to players.");
  10. }
  11. return 1;
  12. }
  13. CMD:stpatricksshop(playerid, params[])
  14. {
  15. if(StPatricksShop == false) return SendClientMessageEx(playerid, COLOR_GREY, "The shop is currently closed.");
  16. if(!IsAtClothingStore(playerid)) return SendClientMessageEx(playerid, COLOR_GREY, "You aren't at a clothes shop.");
  17. if(!GetPVarInt(playerid, "PinConfirmed")) return PinLogin(playerid);
  18. new beerList[] = {1543, 1544, 1484, 1486};
  19. ShowModelSelectionMenuEx(playerid, beerList, sizeof(beerList), "St Patrick's Day Shop", 0317, 0.0, 0.0, 180.0);
  20. return 1;
  21. }
  22. #include <YSI\y_hooks>
  23. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  24. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  25. if(dialogid == DIALOG_STPATRICKSSHOP)
  26. {
  27. if(!response) return DeletePVar(playerid, "StPatrickToy");
  28. szMiscArray[0] = 0;
  29. if(PlayerInfo[playerid][pCredits] < 150)
  30. return SendClientMessageEx(playerid, COLOR_GREY, "You don't have enough credits to purchase this item. Visit shop.ng-gaming.net to purchase credits.");
  31. GivePlayerCredits(playerid, -150, 1);
  32. new name[24] = "None";
  33. for(new i; i < sizeof(HoldingObjectsAll); i++)
  34. {
  35. if(HoldingObjectsAll[i][holdingmodelid] == GetPVarInt(playerid, "StPatrickToy"))
  36. {
  37. format(name, sizeof(name), "%s", HoldingObjectsAll[i][holdingmodelname]);
  38. break;
  39. }
  40. }
  41. format(szMiscArray, sizeof(szMiscArray), "You have purchased the %s Toy for 150 credits.", name);
  42. SendClientMessageEx(playerid, COLOR_CYAN, szMiscArray);
  43. g_mysql_SaveAccount(playerid);
  44. format(szMiscArray, sizeof(szMiscArray), "[TOYSALE] [User: %s(%i)] [IP: %s] [Credits: %s] [%s] [Price: 150]", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(PlayerInfo[playerid][pCredits]), name);
  45. Log("logs/toys.log", szMiscArray), print(szMiscArray);
  46. new icount = GetPlayerToySlots(playerid);
  47. for(new v = 0; v < icount; v++)
  48. {
  49. if(PlayerToyInfo[playerid][v][ptModelID] == 0)
  50. {
  51. PlayerToyInfo[playerid][v][ptModelID] = GetPVarInt(playerid, "StPatrickToy");
  52. PlayerToyInfo[playerid][v][ptBone] = 5;
  53. PlayerToyInfo[playerid][v][ptPosX] = 0.0;
  54. PlayerToyInfo[playerid][v][ptPosY] = 0.0;
  55. PlayerToyInfo[playerid][v][ptPosZ] = 0.0;
  56. PlayerToyInfo[playerid][v][ptRotX] = 0.0;
  57. PlayerToyInfo[playerid][v][ptRotY] = 0.0;
  58. PlayerToyInfo[playerid][v][ptRotZ] = 0.0;
  59. PlayerToyInfo[playerid][v][ptScaleX] = 1.0;
  60. PlayerToyInfo[playerid][v][ptScaleY] = 1.0;
  61. PlayerToyInfo[playerid][v][ptScaleZ] = 1.0;
  62. PlayerToyInfo[playerid][v][ptTradable] = 1;
  63. g_mysql_NewToy(playerid, v);
  64. DeletePVar(playerid, "StPatrickToy");
  65. return 1;
  66. }
  67. }
  68. for(new i = 0; i < MAX_PLAYERTOYS; i++)
  69. {
  70. if(PlayerToyInfo[playerid][i][ptModelID] == 0)
  71. {
  72. PlayerToyInfo[playerid][i][ptModelID] = GetPVarInt(playerid, "StPatrickToy");
  73. PlayerToyInfo[playerid][i][ptBone] = 5;
  74. PlayerToyInfo[playerid][i][ptPosX] = 0.0;
  75. PlayerToyInfo[playerid][i][ptPosY] = 0.0;
  76. PlayerToyInfo[playerid][i][ptPosZ] = 0.0;
  77. PlayerToyInfo[playerid][i][ptRotX] = 0.0;
  78. PlayerToyInfo[playerid][i][ptRotY] = 0.0;
  79. PlayerToyInfo[playerid][i][ptRotZ] = 0.0;
  80. PlayerToyInfo[playerid][i][ptScaleX] = 1.0;
  81. PlayerToyInfo[playerid][i][ptScaleY] = 1.0;
  82. PlayerToyInfo[playerid][i][ptScaleZ] = 1.0;
  83. PlayerToyInfo[playerid][i][ptTradable] = 1;
  84. PlayerToyInfo[playerid][i][ptSpecial] = 1;
  85. g_mysql_NewToy(playerid, i);
  86. SendClientMessageEx(playerid, COLOR_GRAD1, "Due to you not having any available slots, we've temporarily gave you an additional slot to use/sell/trade your toy.");
  87. SendClientMessageEx(playerid, COLOR_RED, "Note: Please take note that after selling the toy, the temporarily additional toy slot will be removed.");
  88. DeletePVar(playerid, "StPatrickToy");
  89. break;
  90. }
  91. }
  92. }
  93. return 0;
  94. }
  95. //Created By AlexR - March 12, 2013 - v2.3.800
  96. enum cP
  97. {
  98. Float:cpPos[3],
  99. cpVW,
  100. cpInt
  101. }
  102. new const CharmPoints[][cP] = {
  103. {{-220.42, 1405.93, 27.76}, 1, 18},
  104. {{381.34, -188.12, 1000.63}, 1, 17},
  105. {{307.02, -142.24, 1004.06}, 1, 7},
  106. {{1221.35, 8.90, 1001.33}, 1, 2},
  107. {{2236.19, 1679.04, 1008.35}, 1, 1}
  108. };
  109. new ActiveCharmPoint = -1;
  110. new ActiveCharmPointPickup = -1;
  111. new Text3D:ActiveCharmPoint3DText;
  112. new CharmMainTimer = 0;
  113. new CharmReloadTimer = 0;
  114. RemoveCharmPoint()
  115. {
  116. if (ActiveCharmPoint == -1)
  117. return;
  118. if (IsValidDynamicPickup(ActiveCharmPointPickup))
  119. {
  120. DestroyDynamicPickup(ActiveCharmPointPickup);
  121. ActiveCharmPointPickup = -1;
  122. }
  123. if (IsValidDynamic3DTextLabel(ActiveCharmPoint3DText))
  124. {
  125. DestroyDynamic3DTextLabel(ActiveCharmPoint3DText);
  126. }
  127. // DON'T RESET ActiveCharmPoint
  128. // IT IS USED TO MAKE SURE NO POINT IS PICKED TWICE!
  129. }
  130. SelectCharmPoint()
  131. {
  132. new rand = random(sizeof(CharmPoints));
  133. while (rand == ActiveCharmPoint) // force new point
  134. {
  135. rand = random(sizeof(CharmPoints));
  136. }
  137. if (ActiveCharmPoint != -1)
  138. {
  139. if (IsValidDynamicPickup(ActiveCharmPointPickup))
  140. {
  141. DestroyDynamicPickup(ActiveCharmPointPickup);
  142. ActiveCharmPointPickup = -1;
  143. }
  144. if (IsValidDynamic3DTextLabel(ActiveCharmPoint3DText))
  145. {
  146. DestroyDynamic3DTextLabel(ActiveCharmPoint3DText);
  147. }
  148. }
  149. ActiveCharmPointPickup = CreateDynamicPickup(1274, 23, CharmPoints[rand][cpPos][0], CharmPoints[rand][cpPos][1], CharmPoints[rand][cpPos][2], .worldid = CharmPoints[rand][cpVW], .interiorid = CharmPoints[rand][cpInt]);
  150. ActiveCharmPoint3DText = CreateDynamic3DTextLabel("Collect your Lucky Charm tokens!\n/claimtokens", 0x37A621FF, CharmPoints[rand][cpPos][0], CharmPoints[rand][cpPos][1], CharmPoints[rand][cpPos][2] + 1.0, 100.0, .worldid = CharmPoints[rand][cpVW], .interiorid = CharmPoints[rand][cpInt]);
  151. ActiveCharmPoint = rand;
  152. printf("%d(%d %d) %f %f %f %d %d", ActiveCharmPoint, ActiveCharmPointPickup, _:ActiveCharmPoint3DText, CharmPoints[rand][cpPos][0], CharmPoints[rand][cpPos][1], CharmPoints[rand][cpPos][2], CharmPoints[rand][cpVW], CharmPoints[rand][cpInt]);
  153. }
  154. stock IsPlayerInRangeOfCharm(playerid)
  155. {
  156. if (ActiveCharmPoint == -1 || !IsValidDynamicPickup(ActiveCharmPointPickup))
  157. return false;
  158. new Float:x, Float:y, Float:z;
  159. x = CharmPoints[ActiveCharmPoint][cpPos][0];
  160. y = CharmPoints[ActiveCharmPoint][cpPos][1];
  161. z = CharmPoints[ActiveCharmPoint][cpPos][2];
  162. if (GetPlayerVirtualWorld(playerid) == CharmPoints[ActiveCharmPoint][cpVW] && GetPlayerInterior(playerid) == CharmPoints[ActiveCharmPoint][cpInt] && IsPlayerInRangeOfPoint(playerid, 1.0, x, y, z))
  163. return true;
  164. return false;
  165. }
  166. CMD:gotocharmpoint(playerid, params[])
  167. {
  168. if (PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  169. {
  170. SetPlayerPos(playerid, CharmPoints[ActiveCharmPoint][cpPos][0], CharmPoints[ActiveCharmPoint][cpPos][1], CharmPoints[ActiveCharmPoint][cpPos][2]);
  171. SetPlayerVirtualWorld(playerid, CharmPoints[ActiveCharmPoint][cpVW]);
  172. SetPlayerInterior(playerid, CharmPoints[ActiveCharmPoint][cpInt]);
  173. }
  174. return 1;
  175. }
  176. CMD:claimtokens(playerid, params[])
  177. {
  178. if (IsPlayerInRangeOfCharm(playerid))
  179. {
  180. if (gettime() >= PlayerInfo[playerid][pLastCharmReceived] + 3600)
  181. {
  182. SendClientMessageEx(playerid, 0x37A621FF, "You collected 5 tokens!");
  183. PlayerInfo[playerid][pLastCharmReceived] = gettime();
  184. PlayerInfo[playerid][pEventTokens] += 5;
  185. return 1;
  186. }
  187. else
  188. {
  189. SendClientMessageEx(playerid, COLOR_GRAD2, "You have already received a charm from that point!");
  190. return 1;
  191. }
  192. }
  193. else
  194. {
  195. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not near the charm point!");
  196. }
  197. return 1;
  198. }
  199. CharmTimer()
  200. {
  201. if (CharmReloadTimer == 0 && ++CharmMainTimer == 1800)
  202. {
  203. RemoveCharmPoint();
  204. }
  205. if (CharmMainTimer >= 1800)
  206. {
  207. if (++CharmReloadTimer == 5400)
  208. {
  209. SelectCharmPoint();
  210. CharmReloadTimer = 0;
  211. CharmMainTimer = 0;
  212. }
  213. }
  214. }
  215. CMD:claimtokeninfo(playerid, params[])
  216. {
  217. if(PlayerInfo[playerid][pAdmin] < 4 && PlayerInfo[playerid][pASM] < 1) return 1;
  218. szMiscArray[0] = 0;
  219. format(szMiscArray, sizeof(szMiscArray), "PointID: %d PickupID: %d 3DTextID: %d X: %f Y: %f Z: %f VW: %d Int: %d", ActiveCharmPoint, ActiveCharmPointPickup, _:ActiveCharmPoint3DText, CharmPoints[ActiveCharmPoint][cpPos][0], CharmPoints[ActiveCharmPoint][cpPos][1], CharmPoints[ActiveCharmPoint][cpPos][2], CharmPoints[ActiveCharmPoint][cpVW], CharmPoints[ActiveCharmPoint][cpInt]);
  220. SendClientMessageEx(playerid, -1, szMiscArray);
  221. format(szMiscArray, sizeof(szMiscArray), "MainTimer: %d ReloadTimer: %d PlayerLastCharmReceived: %d", CharmMainTimer, CharmReloadTimer, PlayerInfo[playerid][pLastCharmReceived]);
  222. SendClientMessageEx(playerid, -1, szMiscArray);
  223. return 1;
  224. }