rfl.pwn 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Relay For Life Event
  11. Next Generation Gaming, LLC
  12. (created by Next Generation Gaming Development Team)
  13. * Copyright (c) 2016, Next Generation Gaming, LLC
  14. *
  15. * All rights reserved.
  16. *
  17. * Redistribution and use in source and binary forms, with or without modification,
  18. * are not permitted in any case.
  19. *
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  25. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  26. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  27. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  28. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  29. * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  30. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  31. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. */
  33. #include <YSI\y_hooks>
  34. stock CountRFLTeams()
  35. {
  36. new var;
  37. for(new i = 0; i < MAX_RFLTEAMS; i++)
  38. {
  39. if(RFLInfo[i][RFLused] != 0)
  40. {
  41. var++;
  42. }
  43. }
  44. return var;
  45. }
  46. forward RFLCheckpointu(playerid);
  47. public RFLCheckpointu(playerid)
  48. {
  49. SetPlayerCheckpoint(playerid, EventRCPX[ConfigEventCPId[playerid]], EventRCPY[ConfigEventCPId[playerid]], EventRCPZ[ConfigEventCPId[playerid]], EventRCPS[ConfigEventCPId[playerid]]);
  50. }
  51. forward WateringStation(playerid);
  52. public WateringStation(playerid)
  53. {
  54. if(GetPVarInt(playerid, "EventToken") == 1 && GetPVarInt(playerid, "InWaterStationRCP") == 1)
  55. {
  56. if(PlayerInfo[playerid][pHydration] < 100) {
  57. PlayerInfo[playerid][pHydration] += 4;
  58. } else {
  59. KillTimer(GetPVarInt(playerid, "WSRCPTimerId"));
  60. SetPVarInt(playerid, "WSRCPTimerId", 0);
  61. SetPVarInt(playerid, "InWaterStationRCP", 0);
  62. RCPIdCurrent[playerid]++;
  63. if(EventRCPT[RCPIdCurrent[playerid]] == 1) {
  64. DisablePlayerCheckpoint(playerid);
  65. SetPlayerCheckpoint(playerid, EventRCPX[RCPIdCurrent[playerid]], EventRCPY[RCPIdCurrent[playerid]], EventRCPZ[RCPIdCurrent[playerid]], EventRCPS[RCPIdCurrent[playerid]]);
  66. }
  67. else if(EventRCPT[RCPIdCurrent[playerid]] == 4) {
  68. DisablePlayerCheckpoint(playerid);
  69. SetPlayerCheckpoint(playerid, EventRCPX[RCPIdCurrent[playerid]], EventRCPY[RCPIdCurrent[playerid]], EventRCPZ[RCPIdCurrent[playerid]], EventRCPS[RCPIdCurrent[playerid]]);
  70. } else {
  71. DisablePlayerCheckpoint(playerid);
  72. SetPlayerCheckpoint(playerid, EventRCPX[RCPIdCurrent[playerid]], EventRCPY[RCPIdCurrent[playerid]], EventRCPZ[RCPIdCurrent[playerid]], EventRCPS[RCPIdCurrent[playerid]]);
  73. }
  74. SendClientMessageEx(playerid, COLOR_WHITE, "You are now fully rehydrated you can continue to your next checkpoint.");
  75. }
  76. } else {
  77. KillTimer(GetPVarInt(playerid, "WSRCPTimerId"));
  78. }
  79. }
  80. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  81. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  82. szMiscArray[0] = 0;
  83. switch(dialogid)
  84. {
  85. case DIALOG_RFL_SEL:
  86. {
  87. if(response)
  88. {
  89. if(listitem == 0) {
  90. mysql_tquery(MainPipeline, "SELECT * FROM `rflteams` WHERE `used` > 0 ORDER BY `laps` DESC LIMIT 15;", "OnRFLPScore", "ii", playerid, 1);
  91. }
  92. else if(listitem == 1) {
  93. mysql_tquery(MainPipeline, "SELECT `Username`, `RacePlayerLaps` FROM `accounts` WHERE `RacePlayerLaps` > 0 ORDER BY `RacePlayerLaps` DESC LIMIT 25;", "OnRFLPScore", "ii", playerid, 2);
  94. }
  95. }
  96. return 1;
  97. }
  98. case DIALOG_RFL_PLAYERS:
  99. {
  100. if(response)
  101. {
  102. return 1;
  103. }
  104. else
  105. {
  106. return 1;
  107. }
  108. }
  109. case DIALOG_RFL_TEAMS:
  110. {
  111. new temp = GetPVarInt(playerid, "rflTemp");
  112. if(response)
  113. {
  114. if(temp > 0) {
  115. mysql_format(MainPipeline, szMiscArray, sizeof(szMiscArray), "SELECT * FROM `rflteams` WHERE `used` > 0 ORDER BY `laps` DESC LIMIT %d , 15;", temp);
  116. mysql_tquery(MainPipeline, szMiscArray, "OnRFLPScore", "ii", playerid, 1);
  117. }
  118. }
  119. else
  120. {
  121. DeletePVar(playerid, "rflTemp");
  122. return 1;
  123. }
  124. }
  125. }
  126. return 0;
  127. }
  128. // Relay For Life
  129. CMD:setlapcount(playerid, params[])
  130. {
  131. if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command.");
  132. new totallaps;
  133. if(sscanf(params, "i", totallaps)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setlapcount [totallaps]");
  134. RaceTotalLaps = totallaps;
  135. new string[52];
  136. format(string, sizeof(string), "You have changed the Total Laps Completed to: %d", RaceTotalLaps);
  137. SendClientMessageEx(playerid, COLOR_WHITE, string);
  138. return 1;
  139. }
  140. CMD:eventstats(playerid, params[])
  141. {
  142. if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command.");
  143. new string[50];
  144. format(string, sizeof(string), "Total Laps Completed: %d | Total Players: %d", RaceTotalLaps, TotalJoinsRace);
  145. SendClientMessageEx(playerid, COLOR_WHITE, string);
  146. return 1;
  147. }
  148. CMD:rfltoggle(playerid, params[])
  149. {
  150. if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command.");
  151. if(rflstatus > 0) {
  152. rflstatus = 0;
  153. SendClientMessageEx(playerid, COLOR_GREY, "You have disabled relay for life.");
  154. Misc_Save();
  155. }
  156. else {
  157. rflstatus = 1;
  158. SendClientMessageEx(playerid, COLOR_GREY, "You have enabled relay for life.");
  159. Misc_Save();
  160. }
  161. return 1;
  162. }
  163. CMD:toglapcount(playerid, params[]) {
  164. if(PlayerInfo[playerid][pAdmin] < 1337) return SendClientMessageEx(playerid, COLOR_GREY, "You are not authorized to use this command.");
  165. if(toglapcount == 0) {
  166. toglapcount = 1;
  167. SendClientMessageEx(playerid, COLOR_WHITE, "Lap counting has been turned off, new laps completed by players will not be counted.");
  168. } else {
  169. toglapcount = 0;
  170. SendClientMessageEx(playerid, COLOR_WHITE, "Lap counting has been turned on, new laps completed by players will now be counted.");
  171. }
  172. return 1;
  173. }
  174. CMD:rflscore(playerid, params[])
  175. {
  176. ShowPlayerDialogEx(playerid, DIALOG_RFL_SEL, DIALOG_STYLE_LIST, "Relay For Life Scoreboard", "Team Scores\nPlayer Top 25", "Choose", "Close");
  177. return 1;
  178. }
  179. CMD:buyrflteam(playerid, params[])
  180. {
  181. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  182. if(PlayerInfo[playerid][pRFLTeam] != -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are already part of a team.");
  183. if(GetPlayerCash(playerid) < 100000) return SendClientMessageEx(playerid, COLOR_GREY, "You need $100000 to buy a team.");
  184. for(new i = 0; i < MAX_RFLTEAMS; i++) {
  185. if(RFLInfo[i][RFLmembers] < 1) {
  186. format(RFLInfo[i][RFLname], 25, "Team %s", GetPlayerNameEx(playerid));
  187. format(RFLInfo[i][RFLleader], 25, "%s", GetPlayerNameEx(playerid));
  188. RFLInfo[i][RFLused] = 1;
  189. RFLInfo[i][RFLmembers] = 1;
  190. RFLInfo[i][RFLlaps] = 0;
  191. PlayerInfo[playerid][pRFLTeam] = i;
  192. PlayerInfo[playerid][pRFLTeamL] = i;
  193. GivePlayerCash(playerid, -100000);
  194. SendClientMessageEx(playerid, COLOR_GREY, "You have bought a team for $100000. You may now use /rflhelp.");
  195. if( GetPVarInt( playerid, "EventToken" ) == 1 ) {
  196. if( EventKernel[ EventStatus ] == 1 || EventKernel[ EventStatus ] == 2 ) {
  197. if(EventKernel[EventType] == 3) {
  198. new Float:X, Float:Y, Float:Z, string[64];
  199. GetPlayerPos( playerid, X, Y, Z );
  200. format(string, sizeof(string), "Team: %s", RFLInfo[i][RFLname]);
  201. RFLTeamN3D[playerid] = CreateDynamic3DTextLabel(string,0x008080FF,X,Y,Z,10.0,.attachedplayer = playerid, .worldid = GetPlayerVirtualWorld(playerid));
  202. }
  203. }
  204. }
  205. SaveRelayForLifeTeam(i);
  206. OnPlayerStatsUpdate(i);
  207. return 1;
  208. }
  209. }
  210. SendClientMessageEx(playerid, COLOR_GREY, "All team slots have been used.");
  211. return 1;
  212. }
  213. CMD:leaverflteam(playerid, params[])
  214. {
  215. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  216. if(PlayerInfo[playerid][pRFLTeam] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not part of a team.");
  217. new team = PlayerInfo[playerid][pRFLTeam];
  218. if(PlayerInfo[playerid][pRFLTeamL] == team)
  219. {
  220. new string[128];
  221. format(RFLInfo[team][RFLname], 25, "Unused");
  222. format(RFLInfo[team][RFLleader], 25, "None");
  223. RFLInfo[team][RFLlaps] = 0;
  224. RFLInfo[team][RFLmembers] = 0;
  225. RFLInfo[team][RFLused] = 0;
  226. PlayerInfo[playerid][pRFLTeam] = -1;
  227. PlayerInfo[playerid][pRFLTeamL] = -1;
  228. if(IsValidDynamic3DTextLabel(RFLTeamN3D[playerid])) {
  229. DestroyDynamic3DTextLabel(RFLTeamN3D[playerid]);
  230. RFLTeamN3D[playerid] = Text3D:-1;
  231. }
  232. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Your team has been deleted due to you being the leader.");
  233. foreach(new i: Player)
  234. {
  235. if(PlayerInfo[i][pRFLTeam] == team) {
  236. PlayerInfo[i][pRFLTeam] = -1;
  237. PlayerInfo[i][pRFLTeamL] = -1;
  238. if(IsValidDynamic3DTextLabel(RFLTeamN3D[i])) {
  239. DestroyDynamic3DTextLabel(RFLTeamN3D[i]);
  240. RFLTeamN3D[playerid] = Text3D:-1;
  241. }
  242. SendClientMessageEx(i, COLOR_LIGHTBLUE, "You have been removed from your team due to it being removed.");
  243. OnPlayerStatsUpdate(i);
  244. }
  245. }
  246. OnPlayerStatsUpdate(playerid);
  247. mysql_format(MainPipeline, string, sizeof(string), "UPDATE `accounts` SET `RFLTeam` = -1, `RFLTeamL` = -1 WHERE `RFLTeam` = %d", team);
  248. mysql_tquery(MainPipeline, string, "OnQueryFinish", "i", SENDDATA_THREAD);
  249. }
  250. else
  251. {
  252. RFLInfo[team][RFLmembers] -= 1;
  253. PlayerInfo[playerid][pRFLTeam] = -1;
  254. PlayerInfo[playerid][pRFLTeamL] = -1;
  255. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have left the team.");
  256. OnPlayerStatsUpdate(playerid);
  257. }
  258. SaveRelayForLifeTeam(team);
  259. return 1;
  260. }
  261. CMD:rflinvite(playerid, params[])
  262. {
  263. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  264. if(PlayerInfo[playerid][pRFLTeam] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not part of a team.");
  265. if(PlayerInfo[playerid][pRFLTeamL] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not the leader of this team.");
  266. if(RFLInfo[PlayerInfo[playerid][pRFLTeam]][RFLmembers] >= 20) return SendClientMessageEx(playerid, COLOR_GREY, "You cannot invite more than 19 members.");
  267. new giveplayerid;
  268. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /rflinvite [playerid/PlayerName]");
  269. if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  270. if(PlayerInfo[giveplayerid][pRFLTeam] != -1) return SendClientMessageEx(playerid, COLOR_GREY, "This player is already part of a team.");
  271. new string[128];
  272. SetPVarInt(giveplayerid, "RFLTeam_Invite", 1);
  273. SetPVarInt(giveplayerid, "RFLTeam_Team", PlayerInfo[playerid][pRFLTeam]);
  274. SetPVarInt(giveplayerid, "RFLTeam_Inviter", playerid);
  275. format(string, sizeof(string), "* You have offered %s to join your team.", GetPlayerNameEx(giveplayerid));
  276. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  277. format(string, sizeof(string), "* %s has offered you to join his team. Use /accept rflteam to accept it.", GetPlayerNameEx(playerid));
  278. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  279. return 1;
  280. }
  281. CMD:rflkick(playerid, params[])
  282. {
  283. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  284. if(PlayerInfo[playerid][pRFLTeam] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not part of a team.");
  285. if(PlayerInfo[playerid][pRFLTeamL] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not the leader of this team.");
  286. new giveplayerid;
  287. if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /rflkick [playerid/PlayerName]");
  288. if(!IsPlayerConnected(giveplayerid)) return SendClientMessageEx(playerid, COLOR_GREY, "Invalid player specified.");
  289. if(PlayerInfo[giveplayerid][pRFLTeam] != PlayerInfo[playerid][pRFLTeam]) return SendClientMessageEx(playerid, COLOR_GREY, "This player is not part of your team.");
  290. new string[128], team = PlayerInfo[playerid][pRFLTeam];
  291. PlayerInfo[giveplayerid][pRFLTeam] = -1;
  292. PlayerInfo[giveplayerid][pRFLTeamL] = -1;
  293. RFLInfo[team][RFLmembers] -=1;
  294. format(string, sizeof(string), "* You have kicked %s out of your team.", GetPlayerNameEx(giveplayerid));
  295. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  296. format(string, sizeof(string), "* %s has kicked you out of his team.", GetPlayerNameEx(playerid));
  297. SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
  298. if(IsValidDynamic3DTextLabel(RFLTeamN3D[giveplayerid])) {
  299. DestroyDynamic3DTextLabel(RFLTeamN3D[giveplayerid]);
  300. }
  301. OnPlayerStatsUpdate(giveplayerid);
  302. SaveRelayForLifeTeam(team);
  303. return 1;
  304. }
  305. CMD:rflmembers(playerid, params[])
  306. {
  307. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  308. if(PlayerInfo[playerid][pRFLTeam] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not part of a team.");
  309. new string[64];
  310. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* Listing all team members online:");
  311. foreach(new i: Player)
  312. {
  313. if(PlayerInfo[i][pRFLTeam] == PlayerInfo[playerid][pRFLTeam]) {
  314. if(PlayerInfo[i][pRFLTeamL] != -1) {
  315. format(string, sizeof(string), "%s - Leader", GetPlayerNameEx(i));
  316. SendClientMessageEx(playerid, COLOR_GREY, string);
  317. }
  318. else {
  319. SendClientMessageEx(playerid, COLOR_GREY, GetPlayerNameEx(i));
  320. }
  321. }
  322. }
  323. return 1;
  324. }
  325. CMD:rflchangename(playerid, params[])
  326. {
  327. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  328. if(PlayerInfo[playerid][pRFLTeam] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not part of a team.");
  329. if(PlayerInfo[playerid][pRFLTeamL] == -1) return SendClientMessageEx(playerid, COLOR_GREY, "You are not the leader of this team.");
  330. new name[25];
  331. if(sscanf(params, "s[25]", name)) return SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /rflchangename <teamname>");
  332. if(GetPVarType(playerid, "HasReport")) {
  333. SendClientMessageEx(playerid, COLOR_GREY, "You can only have 1 active report at a time. (/cancelreport)");
  334. return 1;
  335. }
  336. if(strfind(name, "'", true) != -1) {
  337. SendClientMessageEx(playerid, COLOR_GREY, "Please do not use ' inside of your teamname.");
  338. return 1;
  339. }
  340. new String[128];
  341. SetPVarInt(playerid, "RFLNameRequest", 1);
  342. SetPVarString(playerid, "NewRFLName", name);
  343. format( String, sizeof( String ), "You have requested to change your team name to %s, please wait for an admin to approve it.", name);
  344. SendClientMessageEx( playerid, COLOR_YELLOW, String );
  345. SendReportToQue(playerid, "Team Name Request", 2, 4);
  346. return 1;
  347. }
  348. CMD:rflhelp(playerid, params[])
  349. {
  350. if(rflstatus < 1) return SendClientMessageEx(playerid, COLOR_GREY, "Relay For Life is currently not enabled.");
  351. SendClientMessageEx(playerid, COLOR_WHITE, "Relay For Life Commands");
  352. SendClientMessageEx(playerid, COLOR_GREEN, "_____________________________________________________________________________________________________");
  353. SendClientMessageEx(playerid, COLOR_GREY, "GENERAL: /rflscore /buyrflteam(100k) /leaverflteam");
  354. if(PlayerInfo[playerid][pRFLTeam] != -1)
  355. {
  356. SendClientMessageEx(playerid, COLOR_GREY, "MEMBER: /rflmembers");
  357. }
  358. if(PlayerInfo[playerid][pRFLTeamL] != -1)
  359. {
  360. SendClientMessageEx(playerid, COLOR_GREY, "TEAMOWNER: /rflinvite (20 Members Max.) /rflkick /rflchangename");
  361. }
  362. if(PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  363. {
  364. SendClientMessageEx(playerid, COLOR_GREY, "ADMIN: /toglapcount /rfltoggle /setlapcount /eventstats /seteventtype race /editevent checkpoints");
  365. }
  366. SendClientMessageEx(playerid, COLOR_GREEN, "_____________________________________________________________________________________________________");
  367. return 1;
  368. }