hospital.pwn 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728
  1. /*
  2. /$$ /$$ /$$$$$$ /$$$$$$$ /$$$$$$$
  3. | $$$ | $$ /$$__ $$ | $$__ $$| $$__ $$
  4. | $$$$| $$| $$ \__/ | $$ \ $$| $$ \ $$
  5. | $$ $$ $$| $$ /$$$$ /$$$$$$| $$$$$$$/| $$$$$$$/
  6. | $$ $$$$| $$|_ $$|______/| $$__ $$| $$____/
  7. | $$\ $$$| $$ \ $$ | $$ \ $$| $$
  8. | $$ \ $$| $$$$$$/ | $$ | $$| $$
  9. |__/ \__/ \______/ |__/ |__/|__/
  10. Hospital System
  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. new InsurancePoint[2];
  35. #define DIALOG_HOSPITAL_MENU 7000
  36. #define MESSAGE_INSUFFICIENT_FUNDS "You have insufficient funds for this."
  37. hook OnGameModeInit() {
  38. InsurancePoint[0] = CreateDynamicSphere(2383.0728,2662.0520,8001.1479, 2.0); // regular hospital interior
  39. InsurancePoint[1] = CreateDynamicSphere(564.54, 1437.02, 6000.47, 2.0); // doc hospital
  40. CreateDynamic3DTextLabel("Insurance Point\nPress ~k~~CONVERSATION_YES~", COLOR_YELLOW, 2383.0728,2662.0520,8001.1479, 10); // Main Hospital Interior
  41. CreateDynamic3DTextLabel("Insurance Point\nPress ~k~~CONVERSATION_YES~", COLOR_YELLOW, 564.54, 1437.02, 6000.47, 10); // Doc Hospital Interior
  42. CreateDynamicPickup(1240, 23, 2383.0728,2662.0520,8001.1479, -1); // Main hospital interior pickup
  43. CreateDynamicPickup(1240, 23, 564.54, 1437.02, 6000.47, -1); // Doc hospital interior pickup
  44. return 1;
  45. }
  46. hook OnPlayerKeyStateChange(playerid, newkeys, oldkeys) {
  47. if(newkeys & KEY_YES && (IsPlayerInDynamicArea(playerid, InsurancePoint[0]) || IsPlayerInDynamicArea(playerid, InsurancePoint[1]))) {
  48. format(szMiscArray, sizeof(szMiscArray), "Level 1 Healthcare\t\t$1000\nLevel 2 Healthcare\t\t$2000\nLevel 3 Healthcare\t\t$3000\nLevel 4 Healthcare\t\t$4000\nBuy Insurance");
  49. ShowPlayerDialogEx(playerid, DIALOG_HOSPITAL_MENU, DIALOG_STYLE_LIST, "Hospital Menu", szMiscArray, "Select", "Cancel");
  50. }
  51. return 1;
  52. }
  53. DeliverPlayerToHospital(playerid, iHospital)
  54. {
  55. TogglePlayerControllable(playerid, 0);
  56. SetHealth(playerid, 0.5);
  57. SetPlayerInterior(playerid, 1);
  58. PlayerInfo[playerid][pInt] = 1;
  59. PlayerInfo[playerid][pHospital] = 1;
  60. PlayerInfo[playerid][pDuty] = 0;
  61. PlayerCuffed[playerid] = 0;
  62. DeletePVar(playerid, "PlayerCuffed");
  63. DeletePVar(playerid, "IsFrozen");
  64. DeletePVar(playerid, "renderaid");
  65. PlayerCuffedTime[playerid] = 0;
  66. if(PlayerInfo[playerid][pFitness] >= 6) PlayerInfo[playerid][pFitness] -= 6;
  67. else PlayerInfo[playerid][pFitness] = 0;
  68. if(GetPVarInt(playerid, "_HospitalBeingDelivered") != 1)
  69. {
  70. ResetPlayerWeaponsEx(playerid);
  71. PlayerInfo[playerid][pHasCuff] = 0;
  72. PlayerInfo[playerid][pHasTazer] = 0;
  73. }
  74. new string[128];
  75. new index = GetFreeHospitalBed(iHospital);
  76. arrHospitalBedData[iHospital][bBedOccupied][index] = true;
  77. SetTimerEx("Hospital_StreamIn", FREEZE_TIME, false, "iii", playerid, iHospital, index);
  78. if(iHospital == HOSPITAL_DOCJAIL)
  79. {
  80. Streamer_UpdateEx(playerid, DocHospitalSpawns[index][0], DocHospitalSpawns[index][1], DocHospitalSpawns[index][2]);
  81. SetPlayerPos(playerid, DocHospitalSpawns[index][0], DocHospitalSpawns[index][1], DocHospitalSpawns[index][2]);
  82. SetPlayerFacingAngle(playerid, DocHospitalSpawns[index][3]);
  83. SetPlayerVirtualWorld(playerid, 0);
  84. PlayerInfo[playerid][pVW] = 0;
  85. }
  86. else
  87. {
  88. Streamer_UpdateEx(playerid, HospitalSpawns[index][0], HospitalSpawns[index][1], HospitalSpawns[index][2]);
  89. SetPlayerPos(playerid, HospitalSpawns[index][0], HospitalSpawns[index][1], HospitalSpawns[index][2]);
  90. SetPlayerFacingAngle(playerid, 180);
  91. SetPlayerVirtualWorld(playerid, iHospital);
  92. PlayerInfo[playerid][pVW] = iHospital;
  93. }
  94. SetPVarInt(playerid, "_SpawningAtHospital", 1);
  95. if(GetPVarInt(playerid, "_HospitalBeingDelivered") == 1) // if player is delivered
  96. {
  97. arrHospitalBedData[iHospital][iCountDown][index] = 10;
  98. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have been delivered to the hospital by an ambulance.");
  99. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You will now be treated at the hospital for your injuries.");
  100. }
  101. else if(PlayerInfo[playerid][pWantedLevel] >= 1) // if player wanted
  102. {
  103. arrHospitalBedData[iHospital][iCountDown][index] = 60;
  104. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You are wanted and thus the authorities have been informed.");
  105. format(string, sizeof(string), " %s Hospital has reported %s as a wanted person.", GetHospitalName(iHospital), GetPlayerNameEx(playerid));
  106. if(PlayerInfo[playerid][pSHealth] > 0) {SetArmour(playerid, PlayerInfo[playerid][pSHealth]);}
  107. SendGroupMessage(GROUP_TYPE_LEA, DEPTRADIO, string);
  108. }
  109. else if(PlayerInfo[playerid][pDonateRank] >= 4)
  110. {
  111. arrHospitalBedData[iHospital][iCountDown][index] = 5;
  112. SetPVarInt(playerid, "HealthCareActive", 1);
  113. if(PlayerInfo[playerid][pSHealth] > 0) {SetArmour(playerid, PlayerInfo[playerid][pSHealth]);}
  114. }
  115. else if(PlayerInfo[playerid][pHealthCare] > 0) // if player has credit insurance
  116. {
  117. if(PlayerInfo[playerid][pHealthCare] == 1)
  118. {
  119. if(PlayerInfo[playerid][pCredits] >= ShopItems[18][sItemPrice])
  120. {
  121. arrHospitalBedData[iHospital][iCountDown][index] = 40;
  122. GivePlayerCredits(playerid, -ShopItems[18][sItemPrice], 1);
  123. printf("Price18: %d", 1);
  124. SetPVarInt(playerid, "HealthCareActive", 1);
  125. AmountSold[18]++;
  126. AmountMade[18] += ShopItems[18][sItemPrice];
  127. new szQuery[128];
  128. mysql_format(MainPipeline, szQuery, sizeof(szQuery), "UPDATE `sales` SET `TotalSold18` = '%d', `AmountMade18` = '%d' WHERE `Month` > NOW() - INTERVAL 1 MONTH", AmountSold[18], AmountMade[18]);
  129. mysql_tquery(MainPipeline, szQuery, "OnQueryFinish", "i", SENDDATA_THREAD);
  130. format(string, sizeof(string), "[HC] [User: %s(%i)][IP: %s][Credits: %s][Adv][Price: %s]", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(PlayerInfo[playerid][pCredits]), number_format(ShopItems[18][sItemPrice]));
  131. Log("logs/credits.log", string), print(string);
  132. }
  133. else
  134. {
  135. arrHospitalBedData[iHospital][iCountDown][index] = 40;
  136. DeletePVar(playerid, "HealthCareActive");
  137. SendClientMessageEx(playerid, COLOR_CYAN, "You didn't have enough credits for advanced health care.");
  138. }
  139. }
  140. else if(PlayerInfo[playerid][pHealthCare] == 2)
  141. {
  142. if(PlayerInfo[playerid][pCredits] >= ShopItems[19][sItemPrice])
  143. {
  144. arrHospitalBedData[iHospital][iCountDown][index] = 5;
  145. GivePlayerCredits(playerid, -ShopItems[19][sItemPrice], 1);
  146. printf("Price19: %d", 2);
  147. SetPVarInt(playerid, "HealthCareActive", 1);
  148. AmountSold[19]++;
  149. AmountMade[19] += ShopItems[19][sItemPrice];
  150. new szQuery[128];
  151. mysql_format(MainPipeline, szQuery, sizeof(szQuery), "UPDATE `sales` SET `TotalSold19` = '%d', `AmountMade19` = '%d' WHERE `Month` > NOW() - INTERVAL 1 MONTH", AmountSold[19], AmountMade[19]);
  152. mysql_tquery(MainPipeline, szQuery, "OnQueryFinish", "i", SENDDATA_THREAD);
  153. format(string, sizeof(string), "[AHC] [User: %s(%i)][IP: %s][Credits: %s][Super][Price: %s]", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid), GetPlayerIpEx(playerid), number_format(PlayerInfo[playerid][pCredits]), number_format(ShopItems[19][sItemPrice]));
  154. Log("logs/credits.log", string), print(string);
  155. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "You have advanced healthcare toggled, you will spawn faster as a result.");
  156. }
  157. else
  158. {
  159. arrHospitalBedData[iHospital][iCountDown][index] = 40;
  160. DeletePVar(playerid, "HealthCareActive");
  161. SendClientMessageEx(playerid, COLOR_CYAN, "You didn't have enough credits for super advanced health care.");
  162. }
  163. }
  164. if(PlayerInfo[playerid][pSHealth] > 0) {SetArmour(playerid, PlayerInfo[playerid][pSHealth]);}
  165. }
  166. else // if player has regular insurance
  167. {
  168. arrHospitalBedData[iHospital][iCountDown][index] = 40;
  169. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "Want to spawn faster? Enable advanced healthcare using /togglehealthcare.");
  170. if(PlayerInfo[playerid][pSHealth] > 0) {SetArmour(playerid, PlayerInfo[playerid][pSHealth]);}
  171. }
  172. format(string, sizeof(string), "Time Left: ~r~%d ~w~seconds", arrHospitalBedData[iHospital][iCountDown][index]);
  173. PlayerTextDrawHide(playerid, HospTime[playerid]);
  174. PlayerTextDrawSetString(playerid, HospTime[playerid], string);
  175. PlayerTextDrawShow(playerid, HospTime[playerid]);
  176. arrHospitalBedData[iHospital][iTimer][index] = SetTimerEx("ReleaseFromHospital", 1000, false, "iii", playerid, iHospital, index);
  177. for(new i = 0; i < MAX_PLAYERTOYS; i++)
  178. {
  179. if(PlayerToyInfo[playerid][i][ptAutoAttach] == -1 || PlayerToyInfo[playerid][i][ptAutoAttach] == GetPlayerSkin(playerid)) AttachToy(playerid, i, 0);
  180. }
  181. return 1;
  182. }
  183. forward Hospital_StreamIn(playerid, iHospital, index);
  184. public Hospital_StreamIn(playerid, iHospital, index)
  185. {
  186. if(iHospital == HOSPITAL_DOCJAIL)
  187. {
  188. SetPlayerPos(playerid, DocHospitalSpawns[index][0], DocHospitalSpawns[index][1], DocHospitalSpawns[index][2]);
  189. SetPlayerFacingAngle(playerid, DocHospitalSpawns[index][3]);
  190. }
  191. else
  192. {
  193. SetPlayerPos(playerid, HospitalSpawns[index][0], HospitalSpawns[index][1], HospitalSpawns[index][2]);
  194. SetPlayerFacingAngle(playerid, 180);
  195. }
  196. TogglePlayerControllable(playerid, 1);
  197. ApplyAnimation(playerid, "SWAT", "gnstwall_injurd", 4.0, 1, 0, 0, 0, 0, 1);
  198. return 1;
  199. }
  200. GetFreeHospitalBed(iHospital)
  201. {
  202. new iFree;
  203. if(iHospital == HOSPITAL_DOCJAIL)
  204. {
  205. for(new i = 0; i < MAX_DOCHOSPITALBEDS; i++)
  206. {
  207. if(arrHospitalBedData[iHospital][bBedOccupied][i] == false)
  208. {
  209. iFree = i;
  210. break;
  211. }
  212. }
  213. }
  214. else
  215. {
  216. for(new i = 0; i < MAX_HOSPITALBEDS; i++)
  217. {
  218. if(arrHospitalBedData[iHospital][bBedOccupied][i] == false)
  219. {
  220. iFree = i;
  221. break;
  222. }
  223. }
  224. }
  225. return iFree;
  226. }
  227. GetHospitalName(iHospital)
  228. {
  229. new string[32];
  230. switch(iHospital)
  231. {
  232. case HOSPITAL_ALLSAINTS: string = "All Saints";
  233. case HOSPITAL_COUNTYGEN: string = "County General";
  234. case HOSPITAL_SANFIERRO: string = "San Fierro";
  235. case HOSPITAL_REDCOUNTY: string = "Red County";
  236. case HOSPITAL_ELQUEBRADOS: string = "El Quebrados";
  237. case HOSPITAL_LASVENTURAS: string = "Las Venturas";
  238. case HOSPITAL_FORTCARSON: string = "Fort Carson";
  239. case HOSPITAL_ANGELPINE: string = "Angel Pine";
  240. case HOSPITAL_FLINT: string = "Flint County";
  241. case HOSPITAL_DEMORGAN: string = "DeMorgan";
  242. case HOSPITAL_DOCJAIL: string = "DOC Jail";
  243. case HOSPITAL_LSVIP: string = "LS VIP";
  244. case HOSPITAL_SFVIP: string = "SF VIP";
  245. case HOSPITAL_LVVIP: string = "LV VIP";
  246. case HOSPITAL_HOMECARE: string = "Homecare";
  247. case HOSPITAL_FAMED: string = "Famed Lounge";
  248. case HOSPITAL_TRFAMED: string = "TR Famed Lounge";
  249. case HOSPITAL_PALOMINO: string = "Palomino Creek";
  250. }
  251. return string;
  252. }
  253. forward ReleaseFromHospital(playerid, iHospital, iBed);
  254. public ReleaseFromHospital(playerid, iHospital, iBed)
  255. {
  256. if(!IsPlayerConnected(playerid))
  257. {
  258. arrHospitalBedData[iHospital][bBedOccupied][iBed] = false;
  259. return 1;
  260. }
  261. if(GetPVarInt(playerid, "_SpawningAtHospital") == 2)
  262. {
  263. arrHospitalBedData[iHospital][iCountDown][iBed] = 0;
  264. }
  265. new string[128];
  266. if(--arrHospitalBedData[iHospital][iCountDown][iBed] <= 0)
  267. {
  268. ApplyAnimation(playerid, "SUNBATHE", "Lay_Bac_out", 4.0, 0, 1, 1, 0, 0, 1);
  269. DeletePVar(playerid, "_SpawningAtHospital");
  270. DeletePVar(playerid, "_HospitalBeingDelivered");
  271. arrHospitalBedData[iHospital][bBedOccupied][iBed] = false;
  272. KillTimer(arrHospitalBedData[iHospital][iTimer][iBed]);
  273. PlayerTextDrawHide(playerid, HospTime[playerid]);
  274. if(TakePlayerMoney(playerid, HospitalSpawnInfo[iHospital][0])) {
  275. if(PlayerInfo[playerid][pInsurance] == HOSPITAL_HOMECARE && PlayerInfo[playerid][pWantedLevel] < 1) // if they have homecare, set them at home for free
  276. {
  277. // set them to their house entrance location....
  278. // using house spawn system from previous insurance system
  279. ShowPlayerDialogEx(playerid, SPAWNATHOME_CHOICE, DIALOG_STYLE_LIST, "Choose your house", "Home 1\nHome 2\nHome 3", "Spawn", "");
  280. format(string, sizeof(string), "Medical: You have been charged $%d for your hospital bill and transported to your home.", HospitalSpawnInfo[iHospital][0]);
  281. SendClientMessageEx(playerid, COLOR_RED, string);
  282. }
  283. else
  284. {
  285. format(string, sizeof(string), "Medical: You have been charged $%d for your hospital bill at %s", HospitalSpawnInfo[iHospital][0], GetHospitalName(iHospital));
  286. SendClientMessageEx(playerid, COLOR_RED, string);
  287. }
  288. PlayerInfo[playerid][pHospital] = 0;
  289. switch(iHospital) {
  290. case 3, 4, 7, 8, 16: {
  291. TRTax += HospitalSpawnInfo[iHospital][1]; // NE Hospitals
  292. format(string, sizeof(string), "%s has paid their medical fees, adding $%d to the vault.", GetPlayerNameEx(playerid), HospitalSpawnInfo[iHospital][0]);
  293. GroupPayLog(8, string);
  294. }
  295. default: {
  296. Tax += (HospitalSpawnInfo[iHospital][1] / 2); // SA Hospitals
  297. arrGroupData[9][g_iBudget] += (HospitalSpawnInfo[iHospital][1] / 2);
  298. format(string, sizeof(string), "%s has paid their medical fees, adding $%d to the vault.", GetPlayerNameEx(playerid), (HospitalSpawnInfo[iHospital][0] / 2));
  299. GroupPayLog(9, string);
  300. }
  301. }
  302. } else {
  303. if(PlayerInfo[playerid][pInsurance] == HOSPITAL_HOMECARE && PlayerInfo[playerid][pWantedLevel] < 1) // if they have homecare, set them at home for free
  304. {
  305. format(string, sizeof(string), "Medical: You have been charged $%d for your hospital bill and transported to your home.", HospitalSpawnInfo[iHospital][0]);
  306. SendClientMessageEx(playerid, COLOR_RED, string);
  307. }
  308. else
  309. {
  310. format(string, sizeof(string), "Medical: You have been charged $%d for your hospital bill at %s", HospitalSpawnInfo[iHospital][0], GetHospitalName(iHospital));
  311. SendClientMessageEx(playerid, COLOR_RED, string);
  312. }
  313. PlayerInfo[playerid][pHospital] = 0;
  314. GivePlayerCash(playerid, -HospitalSpawnInfo[iHospital][0]);
  315. }
  316. if(!GetPVarType(playerid, "HealthCareActive")) SetHealth(playerid, 50);
  317. else SetHealth(playerid, 100), DeletePVar(playerid, "HealthCareActive");
  318. PlayerInfo[playerid][pHydration] = 100;
  319. if(PlayerInfo[playerid][pDonateRank] >= 3)
  320. {
  321. SetHealth(playerid, 100.0);
  322. }
  323. DeletePVar(playerid, "VIPSpawn");
  324. arrHospitalBedData[iHospital][iCountDown][iBed] = 0;
  325. }
  326. else
  327. {
  328. if(iHospital != HOSPITAL_DOCJAIL)
  329. {
  330. if(!IsPlayerInRangeOfPoint(playerid, 7.0, HospitalSpawns[iBed][0], HospitalSpawns[iBed][1], HospitalSpawns[iBed][2]))
  331. {
  332. TogglePlayerControllable(playerid, 0);
  333. SetTimerEx("Hospital_StreamIn", FREEZE_TIME, false, "iii", playerid, iHospital, iBed);
  334. Streamer_UpdateEx(playerid, HospitalSpawns[iBed][0], HospitalSpawns[iBed][1], HospitalSpawns[iBed][2]);
  335. SetPlayerPos(playerid, HospitalSpawns[iBed][0], HospitalSpawns[iBed][1], HospitalSpawns[iBed][2]);
  336. SetPlayerFacingAngle(playerid, 180);
  337. SetPlayerInterior(playerid, 1);
  338. PlayerInfo[playerid][pInt] = 1;
  339. SetPlayerVirtualWorld(playerid, iHospital);
  340. PlayerInfo[playerid][pVW] = iHospital;
  341. }
  342. }
  343. format(string, sizeof(string), "Time Left: ~r~%d ~w~seconds", arrHospitalBedData[iHospital][iCountDown][iBed]);
  344. PlayerTextDrawHide(playerid, HospTime[playerid]);
  345. PlayerTextDrawSetString(playerid, HospTime[playerid], string);
  346. PlayerTextDrawShow(playerid, HospTime[playerid]);
  347. new Float:curhealth;
  348. GetHealth(playerid, curhealth);
  349. SetHealth(playerid, curhealth+1);
  350. if(curhealth > 100) SetHealth(playerid, 100);
  351. arrHospitalBedData[iHospital][iTimer][iBed] = SetTimerEx("ReleaseFromHospital", 1000, false, "iii", playerid, iHospital, iBed);
  352. }
  353. return 1;
  354. }
  355. IsAtDeliverPatientPoint(playerid)
  356. {
  357. for(new i = 0; i < MAX_DELIVERY_POINTS; i++)
  358. {
  359. if(IsPlayerInRangeOfPoint(playerid, 5.0, HospitalDeliveryPoints[i][0], HospitalDeliveryPoints[i][1], HospitalDeliveryPoints[i][2])) return true;
  360. }
  361. return 0;
  362. }
  363. GetClosestDeliverPatientPoint(playerid)
  364. {
  365. new iPoint;
  366. for(new i = 0; i < MAX_DELIVERY_POINTS; i++)
  367. {
  368. if(IsPlayerInRangeOfPoint(playerid, 5.0, HospitalDeliveryPoints[i][0], HospitalDeliveryPoints[i][1], HospitalDeliveryPoints[i][2]))
  369. {
  370. iPoint = i;
  371. break;
  372. }
  373. }
  374. return iPoint;
  375. }
  376. ReturnDeliveryPoint(iDPID)
  377. {
  378. // if you're going to add a new hospital delivery point, add the corresponding hospital ID to here.
  379. new iPoint;
  380. switch(iDPID)
  381. {
  382. case 0: iPoint = HOSPITAL_ALLSAINTS;
  383. case 1: iPoint = HOSPITAL_ALLSAINTS;
  384. case 2: iPoint = HOSPITAL_COUNTYGEN;
  385. case 3: iPoint = HOSPITAL_COUNTYGEN;
  386. case 4: iPoint = HOSPITAL_REDCOUNTY;
  387. case 5: iPoint = HOSPITAL_REDCOUNTY;
  388. case 6: iPoint = HOSPITAL_FORTCARSON;
  389. case 7: iPoint = HOSPITAL_FORTCARSON;
  390. case 8: iPoint = HOSPITAL_SANFIERRO;
  391. case 9: iPoint = HOSPITAL_SANFIERRO;
  392. case 10: iPoint = HOSPITAL_ELQUEBRADOS;
  393. case 11: iPoint = HOSPITAL_FLINT;
  394. case 12: iPoint = HOSPITAL_DEMORGAN;
  395. case 13: iPoint = HOSPITAL_LASVENTURAS;
  396. case 14: iPoint = HOSPITAL_ANGELPINE;
  397. case 15: iPoint = HOSPITAL_DOCJAIL;
  398. case 16: iPoint = HOSPITAL_DEMORGAN;
  399. case 17: iPoint = HOSPITAL_DOCJAIL;
  400. case 18: iPoint = HOSPITAL_PALOMINO;
  401. case 19: iPoint = HOSPITAL_PALOMINO;
  402. case 20: iPoint = HOSPITAL_LASVENTURAS;
  403. case 21: iPoint = HOSPITAL_FLINT;
  404. }
  405. return iPoint;
  406. }
  407. ReturnDeliveryPointNation(point)
  408. {
  409. // if you're going to add a new hospital delivery point, add the corresponding hospital ID to here if it is a New Robada hospital.
  410. // 0 = San Andreas
  411. // 1 = New Robada
  412. new nation;
  413. switch(point)
  414. {
  415. case 13, 18 .. 20: nation = 1;
  416. default: nation = 0;
  417. }
  418. return nation;
  419. }
  420. CMD:setinsurance(playerid, params[])
  421. {
  422. if (PlayerInfo[playerid][pAdmin] >= 4 || PlayerInfo[playerid][pASM] >= 1)
  423. {
  424. new string[128], giveplayerid, insurance;
  425. if(sscanf(params, "ud", giveplayerid, insurance))
  426. {
  427. SendClientMessageEx(playerid, COLOR_GREY, "USAGE: /setinsurance [player] [insurance]");
  428. format(string, sizeof(string), "Available Insurances: 0 - %d", MAX_HOSPITALS-1);
  429. SendClientMessageEx(playerid, COLOR_GRAD2, string);
  430. return 1;
  431. }
  432. if(insurance >= 0 && insurance <= MAX_HOSPITALS-1)
  433. {
  434. format(string, sizeof(string), " Your insurance has been changed to %s.", GetHospitalName(insurance));
  435. SendClientMessageEx(giveplayerid,COLOR_YELLOW,string);
  436. format(string, sizeof(string), " You have changed %s's insurance to %s.", GetPlayerNameEx(giveplayerid), GetHospitalName(insurance));
  437. SendClientMessageEx(playerid,COLOR_YELLOW,string);
  438. PlayerInfo[giveplayerid][pInsurance] = insurance;
  439. return 1;
  440. }
  441. }
  442. else
  443. {
  444. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use that command.");
  445. }
  446. return 1;
  447. }
  448. HospHeal(playerid)
  449. {
  450. if(IsPlayerInRangeOfPoint(playerid, 6.0, 2383.0728,2662.0520,8001.1479) || IsPlayerInRangeOfPoint(playerid, 6.0, 564.54, 1437.02, 6000.47))//2103.3252,2824.2102,-16.1672
  451. {
  452. if(GetPVarType(playerid, "STD"))
  453. {
  454. DeletePVar(playerid, "STD");
  455. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, "* You are no longer infected with a STD anymore because of the Hospital's help!");
  456. }
  457. else
  458. {
  459. SendClientMessageEx(playerid, COLOR_GREY, " Your STD results also came back negative!");
  460. return 1;
  461. }
  462. }
  463. else
  464. {
  465. SendClientMessageEx(playerid, COLOR_GREY, " You are not at a Hospital!");
  466. }
  467. return 1;
  468. }
  469. CMD:buyinsurance(playerid, params[])
  470. {
  471. new string[128],
  472. iHospitalVW = GetPlayerVirtualWorld(playerid);
  473. if(IsPlayerInRangeOfPoint(playerid, 2.00, 2383.0728,2662.0520,8001.1479)) // all regular hospital points
  474. {
  475. if(iHospitalVW >= MAX_HOSPITALS) return SendClientMessageEx(playerid, -1, "No hospital has been setup for this Virtual World!");
  476. if(PlayerInfo[playerid][pInsurance] == iHospitalVW) return SendClientMessageEx(playerid, -1, "You already have insurance at this hospital!");
  477. if(GetPlayerCash(playerid) < HospitalSpawnInfo[iHospitalVW][1]) return SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  478. PlayerInfo[playerid][pInsurance] = iHospitalVW;
  479. format(string, sizeof(string), "Medical: You have purchased insurance at %s for $%d.", GetHospitalName(iHospitalVW), HospitalSpawnInfo[iHospitalVW][1]);
  480. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  481. GivePlayerCash(playerid, - HospitalSpawnInfo[iHospitalVW][1]);
  482. switch(iHospitalVW) {
  483. case 3, 17: TRTax += HospitalSpawnInfo[iHospitalVW][1]; // NE Hospitals
  484. default: Tax += HospitalSpawnInfo[iHospitalVW][1]; // SA Hospitals
  485. }
  486. format(string, sizeof(string), "%s has purchased their medical insurance for $%d", GetPlayerNameEx(playerid), HospitalSpawnInfo[iHospitalVW][0]);
  487. GroupPayLog(9, string);
  488. }
  489. else if(IsPlayerInRangeOfPoint(playerid, 2.00, 564.54, 1437.02, 6000.47)) // doc hospital purchase point
  490. {
  491. if(GetPlayerCash(playerid) < HospitalSpawnInfo[HOSPITAL_DOCJAIL][1]) return SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  492. PlayerInfo[playerid][pInsurance] = HOSPITAL_DOCJAIL;
  493. format(string, sizeof(string), "Medical: You have purchased insurance at %s for $%d.", GetHospitalName(HOSPITAL_DOCJAIL), HospitalSpawnInfo[HOSPITAL_DOCJAIL][1]);
  494. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  495. GivePlayerCash(playerid, - HospitalSpawnInfo[HOSPITAL_DOCJAIL][1]);
  496. Tax += HospitalSpawnInfo[HOSPITAL_DOCJAIL][1];
  497. format(string, sizeof(string), "%s has purchased their medical insurance for $%d", GetPlayerNameEx(playerid), HospitalSpawnInfo[iHospitalVW][0]);
  498. GroupPayLog(9, string);
  499. }
  500. else SendClientMessageEx(playerid, COLOR_GREY, "ERROR: You are not in range of a hospital counter.");
  501. return 1;
  502. }
  503. CMD:kill(playerid, params[]) {
  504. if(!IsPlayerConnected(playerid)) return SendClientMessageEx (playerid, COLOR_GRAD2, "You cannot do this at this time.");
  505. else if(HungerPlayerInfo[playerid][hgInEvent] != 0) return SendClientMessageEx(playerid, COLOR_GREY, " You cannot do this while being in the Hunger Games Event!");
  506. else if(GetPVarInt( playerid, "EventToken" ) == 1 || PlayerInfo[playerid][pBeingSentenced] != 0 || GetPVarInt(playerid, "Injured") != 0 || GetPVarInt(playerid, "IsFrozen") != 0 || PlayerCuffed[playerid] != 0 || PlayerTied[playerid] != 0 || PlayerInfo[playerid][pHospital] != 0 || PlayerInfo[playerid][pJailTime] != 0) return SendClientMessageEx (playerid, COLOR_GRAD2, "You cannot do this at this time.");
  507. else
  508. {
  509. if(GetPVarInt(playerid, "EventToken") >= 1 || GetPVarType(playerid, "IsInArena"))
  510. {
  511. if(GetPVarType(playerid, "IsInArena"))
  512. {
  513. if(PaintBallArena[GetPVarInt(playerid, "IsInArena")][pbGameType] == 3)
  514. {
  515. if(GetPVarInt(playerid, "AOSlotPaintballFlag") != -1)
  516. {
  517. SendClientMessageEx(playerid, COLOR_WHITE, "You can not kill yourself while holding a flag.");
  518. return 1;
  519. }
  520. }
  521. }
  522. ResetPlayerWeapons(playerid);
  523. }
  524. if(GetPVarInt(playerid, "commitSuicide") == 1) {
  525. return SendClientMessageEx(playerid, COLOR_GRAD2, "You have already requested to commit suicide.");
  526. }
  527. else {
  528. SetTimerEx("killPlayer", 10000, false, "i", playerid);
  529. SetPVarInt(playerid, "commitSuicide", 1);
  530. SendClientMessageEx(playerid, COLOR_YELLOW, "You requested to commit suicide, please wait 10 seconds...");
  531. }
  532. }
  533. return 1;
  534. }
  535. /*
  536. RemoveVendingMachines(playerid)
  537. {
  538. // Remove 24/7 machines
  539. RemoveBuildingForPlayer(playerid, 1302, 0.0, 0.0, 0.0, 6000.0);
  540. RemoveBuildingForPlayer(playerid, 1209, 0.0, 0.0, 0.0, 6000.0);
  541. RemoveBuildingForPlayer(playerid, 955, 0.0, 0.0, 0.0, 6000.0);
  542. RemoveBuildingForPlayer(playerid, 956, 0.0, 0.0, 0.0, 6000.0);
  543. RemoveBuildingForPlayer(playerid, 1775, 0.0, 0.0, 0.0, 6000.0);
  544. RemoveBuildingForPlayer(playerid, 1776, 0.0, 0.0, 0.0, 6000.0);
  545. RemoveBuildingForPlayer(playerid, 1977, 0.0, 0.0, 0.0, 6000.0);
  546. return 1;
  547. }
  548. */
  549. hook OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) {
  550. if(arrAntiCheat[playerid][ac_iFlags][AC_DIALOGSPOOFING] > 0) return 1;
  551. switch(dialogid)
  552. {
  553. case DIALOG_HOSPITAL_MENU:
  554. {
  555. if(!response) return 1;
  556. new Float:tHP;
  557. GetHealth(playerid, tHP);
  558. switch(listitem)
  559. {
  560. case 0: // heal them 25%
  561. {
  562. if(PlayerInfo[playerid][pCash] >= 1000)
  563. {
  564. if(tHP + 25 > 100) SetHealth(playerid, 100); else SetHealth(playerid, tHP + 25);
  565. GivePlayerCash(playerid, -1000);
  566. HospHeal(playerid);
  567. }
  568. else SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  569. }
  570. case 1: // heal them 50%
  571. {
  572. if(PlayerInfo[playerid][pCash] >= 2000)
  573. {
  574. if(tHP + 50 > 100) SetHealth(playerid, 100); else SetHealth(playerid, tHP + 50);
  575. GivePlayerCash(playerid, -2000);
  576. HospHeal(playerid);
  577. }
  578. else SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  579. }
  580. case 2: // heal them 75%
  581. {
  582. if(PlayerInfo[playerid][pCash] >= 3000)
  583. {
  584. if(tHP + 75 > 100) SetHealth(playerid, 100); else SetHealth(playerid, tHP + 75);
  585. GivePlayerCash(playerid, -3000);
  586. HospHeal(playerid);
  587. }
  588. else SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  589. }
  590. case 3: // heal them fully.
  591. {
  592. if(PlayerInfo[playerid][pCash] >= 4000)
  593. {
  594. SetHealth(playerid, 100);
  595. GivePlayerCash(playerid, -4000);
  596. HospHeal(playerid);
  597. }
  598. else SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  599. }
  600. case 4: // buy insurance
  601. {
  602. new iHospitalVW = GetPlayerVirtualWorld(playerid);
  603. if(IsPlayerInRangeOfPoint(playerid, 2.00, 2383.0728,2662.0520,8001.1479)) // all regular hospital points
  604. {
  605. if(iHospitalVW >= MAX_HOSPITALS) return SendClientMessageEx(playerid, -1, "No hospital has been setup for this Virtual World!");
  606. if(PlayerInfo[playerid][pInsurance] == iHospitalVW) return SendClientMessageEx(playerid, -1, "You already have insurance at this hospital!");
  607. if(GetPlayerCash(playerid) < HospitalSpawnInfo[iHospitalVW][1]) return SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  608. PlayerInfo[playerid][pInsurance] = iHospitalVW;
  609. format(szMiscArray, sizeof(szMiscArray), "Medical: You have purchased insurance at %s for $%d.", GetHospitalName(iHospitalVW), HospitalSpawnInfo[iHospitalVW][1]);
  610. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMiscArray);
  611. GivePlayerCash(playerid, - HospitalSpawnInfo[iHospitalVW][1]);
  612. switch(iHospitalVW) {
  613. case 3, 17: TRTax += HospitalSpawnInfo[iHospitalVW][1]; // NE Hospitals
  614. default: Tax += HospitalSpawnInfo[iHospitalVW][1]; // SA Hospitals
  615. }
  616. format(szMiscArray, sizeof(szMiscArray), "%s has purchased their medical insurance for $%d", GetPlayerNameEx(playerid), HospitalSpawnInfo[iHospitalVW][0]);
  617. GroupPayLog(9, szMiscArray);
  618. }
  619. else if(IsPlayerInRangeOfPoint(playerid, 2.00, 564.54, 1437.02, 6000.47)) // doc hospital purchase point
  620. {
  621. if(GetPlayerCash(playerid) < HospitalSpawnInfo[HOSPITAL_DOCJAIL][1]) return SendClientMessageEx(playerid, COLOR_GREY, MESSAGE_INSUFFICIENT_FUNDS);
  622. PlayerInfo[playerid][pInsurance] = HOSPITAL_DOCJAIL;
  623. format(szMiscArray, sizeof(szMiscArray), "Medical: You have purchased insurance at %s for $%d.", GetHospitalName(HOSPITAL_DOCJAIL), HospitalSpawnInfo[HOSPITAL_DOCJAIL][1]);
  624. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, szMiscArray);
  625. GivePlayerCash(playerid, - HospitalSpawnInfo[HOSPITAL_DOCJAIL][1]);
  626. Tax += HospitalSpawnInfo[HOSPITAL_DOCJAIL][1];
  627. format(szMiscArray, sizeof(szMiscArray), "%s has purchased their medical insurance for $%d", GetPlayerNameEx(playerid), HospitalSpawnInfo[iHospitalVW][0]);
  628. GroupPayLog(9, szMiscArray);
  629. }
  630. }
  631. }
  632. }
  633. case SPAWNATHOME_CHOICE: {
  634. if(!response) return ShowPlayerDialogEx(playerid, SPAWNATHOME_CHOICE, DIALOG_STYLE_LIST, "Choose your house", "Home 1\nHome 2\nHome 3", "Spawn", "");
  635. new i = INVALID_HOUSE_ID;
  636. switch(listitem) {
  637. case 0: {
  638. if(PlayerInfo[playerid][pPhousekey] == INVALID_HOUSE_ID) return ShowPlayerDialogEx(playerid, SPAWNATHOME_CHOICE, DIALOG_STYLE_LIST, "Choose your house", "Home 1\nHome 2\nHome 3", "Spawn", "");
  639. i = PlayerInfo[playerid][pPhousekey];
  640. }
  641. case 1: {
  642. if(PlayerInfo[playerid][pPhousekey2] == INVALID_HOUSE_ID) return ShowPlayerDialogEx(playerid, SPAWNATHOME_CHOICE, DIALOG_STYLE_LIST, "Choose your house", "Home 1\nHome 2\nHome 3", "Spawn", "");
  643. i = PlayerInfo[playerid][pPhousekey2];
  644. }
  645. case 2: {
  646. if(PlayerInfo[playerid][pPhousekey3] == INVALID_HOUSE_ID) return ShowPlayerDialogEx(playerid, SPAWNATHOME_CHOICE, DIALOG_STYLE_LIST, "Choose your house", "Home 1\nHome 2\nHome 3", "Spawn", "");
  647. i = PlayerInfo[playerid][pPhousekey3];
  648. }
  649. }
  650. Streamer_UpdateEx(playerid, HouseInfo[i][hInteriorX],HouseInfo[i][hInteriorY],HouseInfo[i][hInteriorZ]);
  651. SetPlayerInterior(playerid,HouseInfo[i][hIntIW]);
  652. SetPlayerPos(playerid,HouseInfo[i][hInteriorX],HouseInfo[i][hInteriorY],HouseInfo[i][hInteriorZ]);
  653. GameTextForPlayer(playerid, "~w~Welcome Home", 5000, 1);
  654. PlayerInfo[playerid][pInt] = HouseInfo[i][hIntIW];
  655. PlayerInfo[playerid][pVW] = HouseInfo[i][hIntVW];
  656. SetPlayerVirtualWorld(playerid,HouseInfo[i][hIntVW]);
  657. if(HouseInfo[i][hCustomInterior] == 1) Player_StreamPrep(playerid, HouseInfo[i][hInteriorX],HouseInfo[i][hInteriorY],HouseInfo[i][hInteriorZ], FREEZE_TIME);
  658. }
  659. }
  660. return 0;
  661. }