Guest User

HELP

a guest
May 22nd, 2014
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 300.76 KB | None | 0 0
  1. //--------------------------------[ FUNCTIONS ]---------------------------
  2.  
  3. PinLogin(playerid)
  4. {
  5. new string[128];
  6. format(string, sizeof(string), "SELECT `Pin` FROM `accounts` WHERE `id` = %d", GetPlayerSQLId(playerid));
  7. mysql_function_query(MainPipeline, string, true, "OnPinCheck", "i", playerid);
  8. }
  9.  
  10. Group_DisbandGroup(iGroupID) {
  11.  
  12. new
  13. i = 0,
  14. szQuery[128];
  15.  
  16. arrGroupData[iGroupID][g_iAllegiance] = 0;
  17. arrGroupData[iGroupID][g_szGroupName][0] = 0;
  18. arrGroupData[iGroupID][g_szGroupMOTD][0] = 0;
  19.  
  20. arrGroupData[iGroupID][g_hDutyColour] = 0xFFFFFF;
  21. arrGroupData[iGroupID][g_hRadioColour] = 0xFFFFFF;
  22.  
  23. DestroyDynamic3DTextLabel(arrGroupData[iGroupID][g_tCrate3DLabel]);
  24.  
  25. while(i < MAX_GROUP_DIVS) {
  26. arrGroupDivisions[iGroupID][i++][0] = 0;
  27. }
  28. i = 0;
  29.  
  30. while(i < MAX_GROUP_RANKS) {
  31. arrGroupRanks[iGroupID][i][0] = 0;
  32. arrGroupData[iGroupID][g_iPaycheck][i++] = 0;
  33. }
  34. i = 0;
  35.  
  36. while(i < MAX_GROUP_WEAPONS) {
  37. arrGroupData[iGroupID][g_iLockerGuns][i] = 0;
  38. arrGroupData[iGroupID][g_iLockerCost][i++] = 0;
  39. }
  40.  
  41. i = 0;
  42. while(i < MAX_GROUP_LOCKERS) {
  43. DestroyDynamic3DTextLabel(arrGroupLockers[iGroupID][i][g_tLocker3DLabel]);
  44. arrGroupLockers[iGroupID][i][g_fLockerPos][0] = 0.0;
  45. arrGroupLockers[iGroupID][i][g_fLockerPos][1] = 0.0;
  46. arrGroupLockers[iGroupID][i][g_fLockerPos][2] = 0.0;
  47. arrGroupData[iGroupID][g_iLockerGuns][i] = 0;
  48. arrGroupData[iGroupID][g_iLockerCost][i++] = 0;
  49. }
  50. SaveGroup(iGroupID);
  51.  
  52. foreach(new x: Player)
  53. {
  54. if(PlayerInfo[x][pMember] == iGroupID || PlayerInfo[x][pLeader] == iGroupID) {
  55. SendClientMessageEx(x, COLOR_WHITE, "Your group has been disbanded by an administrator. All members have been automatically removed.");
  56. PlayerInfo[x][pLeader] = INVALID_GROUP_ID;
  57. PlayerInfo[x][pMember] = INVALID_GROUP_ID;
  58. PlayerInfo[x][pRank] = INVALID_RANK;
  59. PlayerInfo[x][pDivision] = INVALID_DIVISION;
  60. }
  61. if (PlayerInfo[x][pBugged] == iGroupID) PlayerInfo[x][pBugged] = INVALID_GROUP_ID;
  62. }
  63.  
  64.  
  65. format(szQuery, sizeof szQuery, "DELETE FROM `groupbans` WHERE `GroupBan` = %i", iGroupID);
  66. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, iGroupID+1);
  67.  
  68. format(szQuery, sizeof szQuery, "UPDATE `accounts` SET `Member` = "#INVALID_GROUP_ID", `Leader` = "#INVALID_GROUP_ID", `Division` = "#INVALID_DIVISION", `Rank` = "#INVALID_RANK" WHERE `Member` = %i OR `Leader` = %i", iGroupID, iGroupID);
  69. return mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, iGroupID);
  70. }
  71.  
  72. SaveGroup(iGroupID) {
  73.  
  74. /*
  75. Internally, every group array/subarray starts from zero (divisions, group ids etc)
  76. When displaying to the clients or saving to the db, we add 1 to them!
  77. The only exception is ranks which already start from zero.
  78. */
  79.  
  80. if(!(0 <= iGroupID < MAX_GROUPS)) // Array bounds check. Use it.
  81. return 0;
  82.  
  83. new
  84. szQuery[2048],
  85. i = 0;
  86.  
  87. format(szQuery, sizeof szQuery, "UPDATE `groups` SET \
  88. `Type` = %i, `Name` = '%s', `MOTD` = '%s', `Allegiance` = %i, `Bug` = %i, \
  89. `Radio` = %i, `DeptRadio` = %i, `IntRadio` = %i, `GovAnnouncement` = %i, `FreeNameChange` = %i, `DutyColour` = %i, `RadioColour` = %i, ",
  90. arrGroupData[iGroupID][g_iGroupType], g_mysql_ReturnEscaped(arrGroupData[iGroupID][g_szGroupName], MainPipeline), arrGroupData[iGroupID][g_szGroupMOTD], arrGroupData[iGroupID][g_iAllegiance], arrGroupData[iGroupID][g_iBugAccess],
  91. arrGroupData[iGroupID][g_iRadioAccess], arrGroupData[iGroupID][g_iDeptRadioAccess], arrGroupData[iGroupID][g_iIntRadioAccess], arrGroupData[iGroupID][g_iGovAccess], arrGroupData[iGroupID][g_iFreeNameChange], arrGroupData[iGroupID][g_hDutyColour], arrGroupData[iGroupID][g_hRadioColour]
  92. );
  93. format(szQuery, sizeof szQuery, "%s\
  94. `Stock` = %i, `CrateX` = '%.2f', `CrateY` = '%.2f', `CrateZ` = '%.2f', \
  95. `SpikeStrips` = %i, `Barricades` = %i, `Cones` = %i, `Flares` = %i, `Barrels` = %i, \
  96. `Budget` = %i, `BudgetPayment` = %i, LockerCostType = %i, `CratesOrder` = '%d', `CrateIsland` = '%d', \
  97. `GarageX` = '%.2f', `GarageY` = '%.2f', `GarageZ` = '%.2f'",
  98. szQuery,
  99. arrGroupData[iGroupID][g_iLockerStock], arrGroupData[iGroupID][g_fCratePos][0], arrGroupData[iGroupID][g_fCratePos][1], arrGroupData[iGroupID][g_fCratePos][2],
  100. arrGroupData[iGroupID][g_iSpikeStrips], arrGroupData[iGroupID][g_iBarricades], arrGroupData[iGroupID][g_iCones], arrGroupData[iGroupID][g_iFlares], arrGroupData[iGroupID][g_iBarrels],
  101. arrGroupData[iGroupID][g_iBudget], arrGroupData[iGroupID][g_iBudgetPayment], arrGroupData[iGroupID][g_iLockerCostType], arrGroupData[iGroupID][g_iCratesOrder], arrGroupData[iGroupID][g_iCrateIsland],
  102. arrGroupData[iGroupID][g_fGaragePos][0], arrGroupData[iGroupID][g_fGaragePos][1], arrGroupData[iGroupID][g_fGaragePos][2]);
  103.  
  104. for(i = 0; i != MAX_GROUP_RANKS; ++i) format(szQuery, sizeof szQuery, "%s, `Rank%i` = '%s'", szQuery, i, arrGroupRanks[iGroupID][i]);
  105. for(i = 0; i != MAX_GROUP_RANKS; ++i) format(szQuery, sizeof szQuery, "%s, `Rank%iPay` = %i", szQuery, i, arrGroupData[iGroupID][g_iPaycheck][i]);
  106. for(i = 0; i != MAX_GROUP_DIVS; ++i) format(szQuery, sizeof szQuery, "%s, `Div%i` = '%s'", szQuery, i+1, arrGroupDivisions[iGroupID][i]);
  107. for(i = 0; i != MAX_GROUP_WEAPONS; ++i) format(szQuery, sizeof szQuery, "%s, `Gun%i` = %i, `Cost%i` = %i", szQuery, i+1, arrGroupData[iGroupID][g_iLockerGuns][i], i+1, arrGroupData[iGroupID][g_iLockerCost][i]);
  108. format(szQuery, sizeof szQuery, "%s WHERE `id` = %i", szQuery, iGroupID+1);
  109. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  110.  
  111. for (i = 0; i < MAX_GROUP_LOCKERS; i++) {
  112. format(szQuery, sizeof(szQuery), "UPDATE `lockers` SET `LockerX` = '%.2f', `LockerY` = '%.2f', `LockerZ` = '%.2f', `LockerVW` = %d, `LockerShare` = %d WHERE `Id` = %d", arrGroupLockers[iGroupID][i][g_fLockerPos][0], arrGroupLockers[iGroupID][i][g_fLockerPos][1], arrGroupLockers[iGroupID][i][g_fLockerPos][2], arrGroupLockers[iGroupID][i][g_iLockerVW], arrGroupLockers[iGroupID][i][g_iLockerShare], arrGroupLockers[iGroupID][i][g_iLockerSQLId]);
  113. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  114. }
  115. return 1;
  116. }
  117.  
  118. DynVeh_Save(iDvSlotID) {
  119. if((iDvSlotID > MAX_DYNAMIC_VEHICLES)) // Array bounds check. Use it.
  120. return 0;
  121.  
  122. new
  123. szQuery[2248],
  124. i = 0;
  125.  
  126. format(szQuery, sizeof szQuery,
  127. "UPDATE `groupvehs` SET `SpawnedID`= '%d',`gID`= '%d',`gDivID`= '%d', `fID`='%d', `rID`='%d', `vModel`= '%d', \
  128. `vPlate` = '%s',`vMaxHealth`= '%.2f',`vType`= '%d',`vLoadMax`= '%d',`vCol1`= '%d',`vCol2`= '%d', \
  129. `vX`= '%.2f',`vY`= '%.2f',`vZ`= '%.2f',`vRotZ`= '%.2f', `vUpkeep` = '%d', `vVW` = '%d', `vDisabled` = '%d', \
  130. `vInt` = '%d', `vFuel` = '%.5f'"
  131. , DynVehicleInfo[iDvSlotID][gv_iSpawnedID], DynVehicleInfo[iDvSlotID][gv_igID], DynVehicleInfo[iDvSlotID][gv_igDivID], DynVehicleInfo[iDvSlotID][gv_ifID], DynVehicleInfo[iDvSlotID][gv_irID], DynVehicleInfo[iDvSlotID][gv_iModel],
  132. g_mysql_ReturnEscaped(DynVehicleInfo[iDvSlotID][gv_iPlate], MainPipeline), DynVehicleInfo[iDvSlotID][gv_fMaxHealth], DynVehicleInfo[iDvSlotID][gv_iType], DynVehicleInfo[iDvSlotID][gv_iLoadMax], DynVehicleInfo[iDvSlotID][gv_iCol1], DynVehicleInfo[iDvSlotID][gv_iCol2],
  133. DynVehicleInfo[iDvSlotID][gv_fX], DynVehicleInfo[iDvSlotID][gv_fY], DynVehicleInfo[iDvSlotID][gv_fZ], DynVehicleInfo[iDvSlotID][gv_fRotZ], DynVehicleInfo[iDvSlotID][gv_iUpkeep], DynVehicleInfo[iDvSlotID][gv_iVW], DynVehicleInfo[iDvSlotID][gv_iDisabled],
  134. DynVehicleInfo[iDvSlotID][gv_iInt], DynVehicleInfo[iDvSlotID][gv_fFuel]);
  135.  
  136. for(i = 0; i != MAX_DV_OBJECTS; ++i) {
  137. format(szQuery, sizeof szQuery, "%s, `vAttachedObjectModel%i` = '%d'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_iAttachedObjectModel][i]);
  138. format(szQuery, sizeof szQuery, "%s, `vObjectX%i` = '%.2f'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_fObjectX][i]);
  139. format(szQuery, sizeof szQuery, "%s, `vObjectY%i` = '%.2f'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_fObjectY][i]);
  140. format(szQuery, sizeof szQuery, "%s, `vObjectZ%i` = '%.2f'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_fObjectZ][i]);
  141. format(szQuery, sizeof szQuery, "%s, `vObjectRX%i` = '%.2f'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_fObjectRX][i]);
  142. format(szQuery, sizeof szQuery, "%s, `vObjectRY%i` = '%.2f'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_fObjectRY][i]);
  143. format(szQuery, sizeof szQuery, "%s, `vObjectRZ%i` = '%.2f'", szQuery, i+1, DynVehicleInfo[iDvSlotID][gv_fObjectRZ][i]);
  144. }
  145.  
  146. for(i = 0; i != MAX_DV_MODS; ++i) format(szQuery, sizeof szQuery, "%s, `vMod%d` = %i", szQuery, i, DynVehicleInfo[iDvSlotID][gv_iMod][i]);
  147.  
  148. format(szQuery, sizeof szQuery, "%s WHERE `id` = %i", szQuery, iDvSlotID);
  149. return mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  150. }
  151.  
  152. //--------------------------------[ INITIATE/EXIT ]---------------------------
  153.  
  154. // g_mysql_Init()
  155. // Description: Called with Gamemode Init.
  156. stock g_mysql_Init()
  157. {
  158. new SQL_HOST[64], SQL_DB[64], SQL_USER[32], SQL_PASS[128], SQL_DEBUG, SQL_DEBUGLOG;
  159. new SQL_SHOST[64], SQL_SDB[64], SQL_SUSER[32], SQL_SPASS[128];
  160. new fileString[128], File: fileHandle = fopen("mysql.cfg", io_read);
  161.  
  162. while(fread(fileHandle, fileString, sizeof(fileString))) {
  163. if(ini_GetValue(fileString, "HOST", SQL_HOST, sizeof(SQL_HOST))) continue;
  164. if(ini_GetValue(fileString, "DB", SQL_DB, sizeof(SQL_DB))) continue;
  165. if(ini_GetValue(fileString, "USER", SQL_USER, sizeof(SQL_USER))) continue;
  166. if(ini_GetValue(fileString, "PASS", SQL_PASS, sizeof(SQL_PASS))) continue;
  167. if(ini_GetInt(fileString, "SHOPAUTOMATED", ShopToggle)) continue;
  168. if(ini_GetValue(fileString, "SHOST", SQL_SHOST, sizeof(SQL_SHOST))) continue;
  169. if(ini_GetValue(fileString, "SDB", SQL_SDB, sizeof(SQL_SDB))) continue;
  170. if(ini_GetValue(fileString, "SUSER", SQL_SUSER, sizeof(SQL_SUSER))) continue;
  171. if(ini_GetValue(fileString, "SPASS", SQL_SPASS, sizeof(SQL_SPASS))) continue;
  172. if(ini_GetInt(fileString, "SERVER", servernumber)) continue;
  173. if(ini_GetInt(fileString, "DEBUG", SQL_DEBUG)) continue;
  174. if(ini_GetInt(fileString, "DEBUGLOG", SQL_DEBUGLOG)) continue;
  175. }
  176. fclose(fileHandle);
  177.  
  178. mysql_log(SQL_DEBUG, SQL_DEBUGLOG);
  179. MainPipeline = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
  180.  
  181. printf("[MySQL] (Main Pipelines) Connecting to %s...", SQL_HOST);
  182. if(mysql_errno(MainPipeline) != 0)
  183. {
  184. printf("[MySQL] (MainPipeline) Fatal Error! Could not connect to MySQL: Host %s - DB: %s - User: %s", SQL_HOST, SQL_DB, SQL_USER);
  185. print("[MySQL] Note: Make sure that you have provided the correct connection credentials.");
  186. printf("[MySQL] Error number: %d", mysql_errno(MainPipeline));
  187. SendRconCommand("exit");
  188. }
  189. else print("[MySQL] (MainPipeline) Connection successful toward MySQL Database Server!");
  190.  
  191. if(ShopToggle == 1)
  192. {
  193. ShopPipeline = mysql_connect(SQL_SHOST, SQL_SUSER, SQL_SDB, SQL_SPASS);
  194.  
  195. printf("[MySQL] (Shop Pipelines) Connecting to %s...", SQL_SHOST);
  196. if(mysql_errno(ShopPipeline) != 0)
  197. {
  198. printf("[MySQL] (ShopPipeline) Fatal Error! Could not connect to MySQL: Host %s - DB: %s - User: %s", SQL_SHOST, SQL_SDB, SQL_SUSER);
  199. print("[MySQL] Note: Make sure that you have provided the correct connection credentials.");
  200. printf("[MySQL] Error number: %d", mysql_errno(ShopPipeline));
  201. //SendRconCommand("exit");
  202. }
  203. else print("[MySQL] (ShopPipeline) Connection successful toward MySQL Database Server!");
  204. }
  205.  
  206. InitiateGamemode(); // Start the server
  207.  
  208. return 1;
  209. }
  210.  
  211. // g_mysql_Exit()
  212. // Description: Called with Gamemode Exit.
  213. stock g_mysql_Exit()
  214. {
  215. mysql_close(MainPipeline);
  216. if(ShopToggle == 1) mysql_close(ShopPipeline);
  217. return 1;
  218. }
  219.  
  220. //--------------------------------[ CALLBACKS ]--------------------------------
  221.  
  222. forward OnQueryFinish(resultid, extraid, handleid);
  223. public OnQueryFinish(resultid, extraid, handleid)
  224. {
  225. new rows, fields;
  226. if(resultid != SENDDATA_THREAD) {
  227. if(extraid != INVALID_PLAYER_ID) {
  228. if(g_arrQueryHandle{extraid} != -1 && g_arrQueryHandle{extraid} != handleid) return 0;
  229. }
  230. cache_get_data(rows, fields, MainPipeline);
  231. }
  232. switch(resultid)
  233. {
  234. case LOADSALEDATA_THREAD:
  235. {
  236. if(rows > 0)
  237. {
  238. for(new i;i < rows;i++)
  239. {
  240. new szResult[32], szField[15];
  241. for(new z = 0; z < MAX_ITEMS; z++)
  242. {
  243. format(szField, sizeof(szField), "TotalSold%d", z);
  244. cache_get_field_content(i, szField, szResult, MainPipeline);
  245. AmountSold[z] = strval(szResult);
  246. //ShopItems[z][sSold] = strval(szResult);
  247.  
  248.  
  249. format(szField, sizeof(szField), "AmountMade%d", z);
  250. cache_get_field_content(i, szField, szResult, MainPipeline);
  251. AmountMade[z] = strval(szResult);
  252. //ShopItems[z][sMade] = strval(szResult);
  253. printf("TotalSold%d: %d | AmountMade%d: %d", z, AmountSold[z], z, AmountMade[z]);
  254. }
  255. break;
  256. }
  257. }
  258. else
  259. {
  260. mysql_function_query(MainPipeline, "INSERT INTO `sales` (`Month`) VALUES (NOW())", false, "OnQueryFinish", "i", SENDDATA_THREAD);
  261. mysql_function_query(MainPipeline, "SELECT * FROM `sales` WHERE `Month` > NOW() - INTERVAL 1 MONTH", true, "OnQueryFinish", "iii", LOADSALEDATA_THREAD, INVALID_PLAYER_ID, -1);
  262. print("[LOADSALEDATA] Inserted new row into `sales`");
  263. }
  264. }
  265. case LOADSHOPDATA_THREAD:
  266. {
  267. for(new i;i < rows;i++)
  268. {
  269. new szResult[32], szField[14];
  270. for(new z = 0; z < MAX_ITEMS; z++)
  271. {
  272. format(szField, sizeof(szField), "Price%d", z);
  273. cache_get_field_content(i, szField, szResult, MainPipeline);
  274. ShopItems[z][sItemPrice] = strval(szResult);
  275. Price[z] = strval(szResult);
  276. if(ShopItems[z][sItemPrice] == 0) ShopItems[z][sItemPrice] = 99999999;
  277. printf("Price%d: %d", z, ShopItems[z][sItemPrice]);
  278. }
  279. //printf("[LOADSHOPDATA] Price0: %d, Price1: %d, Price2: %d, Price3: %d, Price4: %d, Price5: %d, Price6: %d, Price7: %d, Pricr8: %d, Price9: %d, Price10: %d", Price[0], Price[1], Price[2], Price[3], Price[4], Price[5], Price[6], Price[7], Price[8], Price[9], Price[10]);
  280. break;
  281. }
  282. }
  283. case LOADMOTDDATA_THREAD:
  284. {
  285. for(new i;i < rows;i++)
  286. {
  287. new szResult[32];
  288. cache_get_field_content(i, "gMOTD", GlobalMOTD, MainPipeline, 128);
  289. cache_get_field_content(i, "aMOTD", AdminMOTD, MainPipeline, 128);
  290. cache_get_field_content(i, "vMOTD", VIPMOTD, MainPipeline, 128);
  291. cache_get_field_content(i, "cMOTD", CAMOTD, MainPipeline, 128);
  292. cache_get_field_content(i, "pMOTD", pMOTD, MainPipeline, 128);
  293. cache_get_field_content(i, "ShopTechPay", szResult, MainPipeline); ShopTechPay = floatstr(szResult);
  294. cache_get_field_content(i, "GiftCode", GiftCode, MainPipeline, 32);
  295. cache_get_field_content(i, "GiftCodeBypass", szResult, MainPipeline); GiftCodeBypass = strval(szResult);
  296. cache_get_field_content(i, "SecurityCode", SecurityCode, MainPipeline, 32);
  297. cache_get_field_content(i, "ShopClosed", szResult, MainPipeline); ShopClosed = strval(szResult);
  298. cache_get_field_content(i, "RimMod", szResult, MainPipeline); RimMod = strval(szResult);
  299. cache_get_field_content(i, "CarVoucher", szResult, MainPipeline); CarVoucher = strval(szResult);
  300. cache_get_field_content(i, "PVIPVoucher", szResult, MainPipeline); PVIPVoucher = strval(szResult);
  301. cache_get_field_content(i, "GarageVW", szResult, MainPipeline); GarageVW = strval(szResult);
  302. cache_get_field_content(i, "PumpkinStock", szResult, MainPipeline); PumpkinStock = strval(szResult);
  303. cache_get_field_content(i, "HalloweenShop", szResult, MainPipeline); HalloweenShop = strval(szResult);
  304. break;
  305. }
  306. }
  307. case LOADUSERDATA_THREAD:
  308. {
  309. if(IsPlayerConnected(extraid))
  310. {
  311. new szField[MAX_PLAYER_NAME], szResult[64];
  312.  
  313. for(new row;row < rows;row++)
  314. {
  315. cache_get_field_content(row, "Username", szField, MainPipeline, MAX_PLAYER_NAME);
  316.  
  317. if(strcmp(szField, GetPlayerNameExt(extraid), true) != 0)
  318. {
  319. return 1;
  320. }
  321. cache_get_field_content(row, "id", szResult, MainPipeline); PlayerInfo[extraid][pId] = strval(szResult);
  322. cache_get_field_content(row, "Online", szResult, MainPipeline); PlayerInfo[extraid][pOnline] = strval(szResult);
  323. cache_get_field_content(row, "Email", PlayerInfo[extraid][pEmail], MainPipeline, 128);
  324. cache_get_field_content(row, "IP", PlayerInfo[extraid][pIP], MainPipeline, 16);
  325. cache_get_field_content(row, "SecureIP", PlayerInfo[extraid][pSecureIP], MainPipeline, 16);
  326. cache_get_field_content(row, "FishLic", szResult, MainPipeline); PlayerInfo[extraid][pFishLic] = strval(szResult);
  327. cache_get_field_content(row, "CheckCash", szResult, MainPipeline); PlayerInfo[extraid][pCheckCash] = strval(szResult);
  328. cache_get_field_content(row, "Checks", szResult, MainPipeline); PlayerInfo[extraid][pChecks] = strval(szResult);
  329. cache_get_field_content(row, "GunLic", szResult, MainPipeline); PlayerInfo[extraid][pGunLic] = strval(szResult);
  330.  
  331. for(new i = 0; i < 12; i++)
  332. {
  333. format(szField, sizeof(szField), "Gun%d", i);
  334. cache_get_field_content(row, szField, szResult, MainPipeline);
  335. PlayerInfo[extraid][pGuns][i] = strval(szResult);
  336. }
  337.  
  338. cache_get_field_content(row, "DrugsTime", szResult, MainPipeline); PlayerInfo[extraid][pDrugsTime] = strval(szResult);
  339. cache_get_field_content(row, "LawyerTime", szResult, MainPipeline); PlayerInfo[extraid][pLawyerTime] = strval(szResult);
  340. cache_get_field_content(row, "ShopNotice", szResult, MainPipeline); PlayerInfo[extraid][pShopNotice] = strval(szResult);
  341. cache_get_field_content(row, "SVIPExVoucher", szResult, MainPipeline); PlayerInfo[extraid][pSVIPExVoucher] = strval(szResult);
  342. cache_get_field_content(row, "GVIPExVoucher", szResult, MainPipeline); PlayerInfo[extraid][pGVIPExVoucher] = strval(szResult);
  343. cache_get_field_content(row, "VIPSellable", szResult, MainPipeline); PlayerInfo[extraid][pVIPSellable] = strval(szResult);
  344. cache_get_field_content(row, "ReceivedPrize", szResult, MainPipeline); PlayerInfo[extraid][pReceivedPrize] = strval(szResult);
  345.  
  346. GetPartnerName(extraid);
  347. IsEmailPending(extraid, PlayerInfo[extraid][pId], PlayerInfo[extraid][pEmail]);
  348.  
  349. if(PlayerInfo[extraid][pCredits] > 0)
  350. {
  351. new szLog[128];
  352. format(szLog, sizeof(szLog), "[LOGIN] [User: %s(%i)] [IP: %s] [Credits: %s]", GetPlayerNameEx(extraid), PlayerInfo[extraid][pId], GetPlayerIpEx(extraid), number_format(PlayerInfo[extraid][pCredits]));
  353. Log("logs/logincredits.log", szLog), print(szLog);
  354. }
  355.  
  356. g_mysql_LoadPVehicles(extraid);
  357. g_mysql_LoadPlayerToys(extraid);
  358.  
  359. SetPVarInt(extraid, "pSQLID", PlayerInfo[extraid][pId]);
  360.  
  361. //g_mysql_LoadPVehiclePositions(extraid);
  362. OnPlayerLoad(extraid);
  363. break;
  364. }
  365. }
  366. return 1;
  367. }
  368. case SENDDATA_THREAD:
  369. {
  370. if(GetPVarType(extraid, "RestartKick")) {
  371. gPlayerLogged{extraid} = 0;
  372. GameTextForPlayer(extraid, "Scheduled Maintenance...", 5000, 5);
  373. SendClientMessage(extraid, COLOR_LIGHTBLUE, "* The server will be going down for Scheduled Maintenance. A brief period of downtime will follow.");
  374. SendClientMessage(extraid, COLOR_GRAD2, "We will be going down to do some maintenance on the server/script, we will be back online shortly.");
  375. SetTimerEx("KickEx", 1000, 0, "i", extraid);
  376.  
  377. foreach(extraid: Player) if(gPlayerLogged{extraid}) {
  378. SetPVarInt(extraid, "RestartKick", 1);
  379. return OnPlayerStatsUpdate(extraid);
  380. }
  381. ABroadCast(COLOR_YELLOW, "{AA3333}Maintenance{FFFF00}: Account saving finished!", 1);
  382. //g_mysql_DumpAccounts();
  383.  
  384. SetTimer("FinishMaintenance", 1500, false);
  385. }
  386. if(GetPVarType(extraid, "AccountSaving") && (GetPVarInt(extraid, "AccountSaved") == 0)) {
  387. SetPVarInt(extraid, "AccountSaved", 1);
  388. foreach(extraid: Player)
  389. {
  390. if(gPlayerLogged{extraid} && (GetPVarInt(extraid, "AccountSaved") == 0))
  391. {
  392. SetPVarInt(extraid, "AccountSaving", 1);
  393. return OnPlayerStatsUpdate(extraid);
  394. }
  395. }
  396. ABroadCast(COLOR_YELLOW, "{AA3333}Maintenance{FFFF00}: Account saving finished!", 1);
  397. print("Account Saving Complete");
  398. foreach(new i: Player)
  399. {
  400. DeletePVar(i, "AccountSaved");
  401. DeletePVar(i, "AccountSaving");
  402. }
  403. //g_mysql_DumpAccounts();
  404. }
  405. return 1;
  406. }
  407. case AUTH_THREAD:
  408. {
  409. new name[24];
  410. for(new i;i < rows;i++)
  411. {
  412. cache_get_field_content(i, "Username", name, MainPipeline, MAX_PLAYER_NAME);
  413. if(strcmp(name, GetPlayerNameExt(extraid), true) == 0)
  414. {
  415. HideNoticeGUIFrame(extraid);
  416. SafeLogin(extraid, 1);
  417. return 1;
  418. }
  419. else
  420. {
  421. return 1;
  422. }
  423. }
  424. HideNoticeGUIFrame(extraid);
  425. SafeLogin(extraid, 2);
  426. return 1;
  427. }
  428. case LOGIN_THREAD:
  429. {
  430. for(new i;i < rows;i++)
  431. {
  432. new
  433. szPass[129],
  434. szResult[129],
  435. szBuffer[129];
  436.  
  437. cache_get_field_content(i, "Username", szResult, MainPipeline, MAX_PLAYER_NAME);
  438. if(strcmp(szResult, GetPlayerNameExt(extraid), true) != 0)
  439. {
  440. //g_mysql_AccountAuthCheck(extraid);
  441. return 1;
  442. }
  443. cache_get_field_content(i, "Key", szResult, MainPipeline, 129);
  444. GetPVarString(extraid, "PassAuth", szBuffer, sizeof(szBuffer));
  445. WP_Hash(szPass, sizeof(szPass), szBuffer);
  446.  
  447. if((isnull(szPass)) || (isnull(szResult)) || (strcmp(szPass, szResult) != 0)) {
  448. // Invalid Password - Try Again!
  449. ShowMainMenuDialog(extraid, 3);
  450. HideNoticeGUIFrame(extraid);
  451. if(++gPlayerLogTries[extraid] == 2) {
  452. SendClientMessage(extraid, COLOR_RED, "SERVER: Wrong password, you have been kicked out automatically.");
  453. SetTimerEx("KickEx", 1000, 0, "i", extraid);
  454. }
  455. return 1;
  456. }
  457. DeletePVar(extraid, "PassAuth");
  458. break;
  459. }
  460. HideNoticeGUIFrame(extraid);
  461. g_mysql_LoadAccount(extraid);
  462. return 1;
  463. }
  464. case REGISTER_THREAD:
  465. {
  466. if(IsPlayerConnected(extraid))
  467. {
  468. g_mysql_AccountLoginCheck(extraid);
  469. TotalRegister++;
  470. }
  471. }
  472. case LOADPTOYS_THREAD:
  473. {
  474. if(IsPlayerConnected(extraid))
  475. {
  476. new i = 0;
  477. while( i < rows)
  478. {
  479. if(i >= MAX_PLAYERTOYS)
  480. break;
  481.  
  482. new szResult[32];
  483.  
  484. cache_get_field_content(i, "id", szResult, MainPipeline);
  485. PlayerToyInfo[extraid][i][ptID] = strval(szResult);
  486.  
  487. cache_get_field_content(i, "modelid", szResult, MainPipeline);
  488. PlayerToyInfo[extraid][i][ptModelID] = strval(szResult);
  489.  
  490. if(PlayerToyInfo[extraid][i][ptModelID] != 0)
  491. {
  492. cache_get_field_content(i, "bone", szResult, MainPipeline);
  493. PlayerToyInfo[extraid][i][ptBone] = strval(szResult);
  494.  
  495. if(PlayerToyInfo[extraid][i][ptBone] > 18 || PlayerToyInfo[extraid][i][ptBone] < 1) PlayerToyInfo[extraid][i][ptBone] = 1;
  496.  
  497. cache_get_field_content(i, "tradable", szResult, MainPipeline);
  498. PlayerToyInfo[extraid][i][ptTradable] = strval(szResult);
  499.  
  500. cache_get_field_content(i, "posx", szResult, MainPipeline);
  501. PlayerToyInfo[extraid][i][ptPosX] = floatstr(szResult);
  502.  
  503. cache_get_field_content(i, "posy", szResult, MainPipeline);
  504. PlayerToyInfo[extraid][i][ptPosY] = floatstr(szResult);
  505.  
  506. cache_get_field_content(i, "posz", szResult, MainPipeline);
  507. PlayerToyInfo[extraid][i][ptPosZ] = floatstr(szResult);
  508.  
  509. cache_get_field_content(i, "rotx", szResult, MainPipeline);
  510. PlayerToyInfo[extraid][i][ptRotX] = floatstr(szResult);
  511.  
  512. cache_get_field_content(i, "roty", szResult, MainPipeline);
  513. PlayerToyInfo[extraid][i][ptRotY] = floatstr(szResult);
  514.  
  515. cache_get_field_content(i, "rotz", szResult, MainPipeline);
  516. PlayerToyInfo[extraid][i][ptRotZ] = floatstr(szResult);
  517.  
  518. cache_get_field_content(i, "scalex", szResult, MainPipeline);
  519. PlayerToyInfo[extraid][i][ptScaleX] = floatstr(szResult);
  520.  
  521. cache_get_field_content(i, "scaley", szResult, MainPipeline);
  522. PlayerToyInfo[extraid][i][ptScaleY] = floatstr(szResult);
  523.  
  524. cache_get_field_content(i, "scalez", szResult, MainPipeline);
  525. PlayerToyInfo[extraid][i][ptScaleZ] = floatstr(szResult);
  526.  
  527. cache_get_field_content(i, "special", szResult, MainPipeline);
  528. PlayerToyInfo[extraid][i][ptSpecial] = strval(szResult);
  529.  
  530. new szLog[128];
  531. format(szLog, sizeof(szLog), "[TOYSLOAD] [User: %s(%i)] [Toy Model ID: %d] [Toy ID]", GetPlayerNameEx(extraid), PlayerInfo[extraid][pId], PlayerToyInfo[extraid][i][ptModelID], PlayerToyInfo[extraid][i][ptID]);
  532. Log("logs/toydebug.log", szLog);
  533. }
  534. else
  535. {
  536. new szQuery[128];
  537. format(szQuery, sizeof(szQuery), "DELETE FROM `` WHERE `id` = '%d'", PlayerToyInfo[extraid][i][ptID]);
  538. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  539. printf("Deleting Toy ID %d for Player %s (%i)", PlayerToyInfo[extraid][i][ptID], GetPlayerNameEx(extraid), GetPlayerSQLId(extraid));
  540. }
  541. i++;
  542. }
  543. }
  544. }
  545. case LOADPVEHICLE_THREAD:
  546. {
  547. if(IsPlayerConnected(extraid))
  548. {
  549. new i = 0;
  550. while(i < rows)
  551. {
  552. if(i >= MAX_PLAYERVEHICLES)
  553. break;
  554.  
  555. new szResult[32];
  556.  
  557. cache_get_field_content(i, "pvModelId", szResult, MainPipeline);
  558. PlayerVehicleInfo[extraid][i][pvModelId] = strval(szResult);
  559.  
  560. cache_get_field_content(i, "id", szResult, MainPipeline);
  561. PlayerVehicleInfo[extraid][i][pvSlotId] = strval(szResult);
  562.  
  563. if(PlayerVehicleInfo[extraid][i][pvModelId] != 0)
  564. {
  565. cache_get_field_content(i, "pvPosX", szResult, MainPipeline);
  566. PlayerVehicleInfo[extraid][i][pvPosX] = floatstr(szResult);
  567.  
  568. cache_get_field_content(i, "pvPosY", szResult, MainPipeline);
  569. PlayerVehicleInfo[extraid][i][pvPosY] = floatstr(szResult);
  570.  
  571. cache_get_field_content(i, "pvPosZ", szResult, MainPipeline);
  572. PlayerVehicleInfo[extraid][i][pvPosZ] = floatstr(szResult);
  573.  
  574. cache_get_field_content(i, "pvPosAngle", szResult, MainPipeline);
  575. PlayerVehicleInfo[extraid][i][pvPosAngle] = floatstr(szResult);
  576.  
  577. cache_get_field_content(i, "pvLock", szResult, MainPipeline);
  578. PlayerVehicleInfo[extraid][i][pvLock] = strval(szResult);
  579.  
  580. cache_get_field_content(i, "pvLocked", szResult, MainPipeline);
  581. PlayerVehicleInfo[extraid][i][pvLocked] = strval(szResult);
  582.  
  583. cache_get_field_content(i, "pvPaintJob", szResult, MainPipeline);
  584. PlayerVehicleInfo[extraid][i][pvPaintJob] = strval(szResult);
  585.  
  586. cache_get_field_content(i, "pvColor1", szResult, MainPipeline);
  587. PlayerVehicleInfo[extraid][i][pvColor1] = strval(szResult);
  588.  
  589. cache_get_field_content(i, "pvColor2", szResult, MainPipeline);
  590. PlayerVehicleInfo[extraid][i][pvColor2] = strval(szResult);
  591.  
  592. cache_get_field_content(i, "pvPrice", szResult, MainPipeline);
  593. PlayerVehicleInfo[extraid][i][pvPrice] = strval(szResult);
  594.  
  595. cache_get_field_content(i, "pvTicket", szResult, MainPipeline);
  596. PlayerVehicleInfo[extraid][i][pvTicket] = strval(szResult);
  597.  
  598. cache_get_field_content(i, "pvRestricted", szResult, MainPipeline);
  599. PlayerVehicleInfo[extraid][i][pvRestricted] = strval(szResult);
  600.  
  601. cache_get_field_content(i, "pvWeapon0", szResult, MainPipeline);
  602. PlayerVehicleInfo[extraid][i][pvWeapons][0] = strval(szResult);
  603.  
  604. cache_get_field_content(i, "pvWeapon1", szResult, MainPipeline);
  605. PlayerVehicleInfo[extraid][i][pvWeapons][1] = strval(szResult);
  606.  
  607. cache_get_field_content(i, "pvWeapon2", szResult, MainPipeline);
  608. PlayerVehicleInfo[extraid][i][pvWeapons][2] = strval(szResult);
  609.  
  610. cache_get_field_content(i, "pvWepUpgrade", szResult, MainPipeline);
  611. PlayerVehicleInfo[extraid][i][pvWepUpgrade] = strval(szResult);
  612.  
  613. cache_get_field_content(i, "pvFuel", szResult, MainPipeline);
  614. PlayerVehicleInfo[extraid][i][pvFuel] = floatstr(szResult);
  615.  
  616. cache_get_field_content(i, "pvImpound", szResult, MainPipeline);
  617. PlayerVehicleInfo[extraid][i][pvImpounded] = strval(szResult);
  618.  
  619. cache_get_field_content(i, "pvPlate", szResult, MainPipeline, 32);
  620. format(PlayerVehicleInfo[extraid][i][pvPlate], 32, "%s", szResult, MainPipeline);
  621.  
  622. cache_get_field_content(i, "pvVW", szResult, MainPipeline);
  623. PlayerVehicleInfo[extraid][i][pvVW] = strval(szResult);
  624.  
  625. cache_get_field_content(i, "pvInt", szResult, MainPipeline);
  626. PlayerVehicleInfo[extraid][i][pvInt] = strval(szResult);
  627.  
  628. for(new m = 0; m < MAX_MODS; m++)
  629. {
  630. new szField[15];
  631. format(szField, sizeof(szField), "pvMod%d", m);
  632. cache_get_field_content(i, szField, szResult, MainPipeline);
  633. PlayerVehicleInfo[extraid][i][pvMods][m] = strval(szResult);
  634. }
  635.  
  636. cache_get_field_content(i, "pvCrashFlag", szResult, MainPipeline);
  637. PlayerVehicleInfo[extraid][i][pvCrashFlag] = strval(szResult);
  638.  
  639. cache_get_field_content(i, "pvCrashVW", szResult, MainPipeline);
  640. PlayerVehicleInfo[extraid][i][pvCrashVW] = strval(szResult);
  641.  
  642. cache_get_field_content(i, "pvCrashX", szResult, MainPipeline);
  643. PlayerVehicleInfo[extraid][i][pvCrashX] = floatstr(szResult);
  644.  
  645. cache_get_field_content(i, "pvCrashY", szResult, MainPipeline);
  646. PlayerVehicleInfo[extraid][i][pvCrashY] = floatstr(szResult);
  647.  
  648. cache_get_field_content(i, "pvCrashZ", szResult, MainPipeline);
  649. PlayerVehicleInfo[extraid][i][pvCrashZ] = floatstr(szResult);
  650.  
  651. cache_get_field_content(i, "pvCrashAngle", szResult, MainPipeline);
  652. PlayerVehicleInfo[extraid][i][pvCrashAngle] = floatstr(szResult);
  653.  
  654. new szLog[128];
  655. format(szLog, sizeof(szLog), "[VEHICLELOAD] [User: %s(%i)] [Model: %d] [Vehicle ID: %d]", GetPlayerNameEx(extraid), PlayerInfo[extraid][pId], PlayerVehicleInfo[extraid][i][pvModelId], PlayerVehicleInfo[extraid][i][pvSlotId]);
  656. Log("logs/vehicledebug.log", szLog);
  657. }
  658. else
  659. {
  660. new query[128];
  661. format(query, sizeof(query), "DELETE FROM `vehicles` WHERE `id` = '%d'", PlayerVehicleInfo[extraid][i][pvSlotId]);
  662. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, extraid);
  663. }
  664. i++;
  665. }
  666. }
  667. }
  668. case LOADPVEHPOS_THREAD:
  669. {
  670. if(IsPlayerConnected(extraid))
  671. {
  672. new bool:bVehRestore;
  673. for(new i;i < rows;i++)
  674. {
  675. bVehRestore = true;
  676. for(new v; v < MAX_PLAYERVEHICLES; v++)
  677. {
  678. new szResult[32], szPrefix[32], tmpVehModelId, Float:tmpVehArray[4];
  679.  
  680. format(szPrefix, sizeof(szPrefix), "pv%dModelId", v);
  681. cache_get_field_content(i, szPrefix, szResult, MainPipeline); tmpVehModelId = strval(szResult);
  682. format(szPrefix, sizeof(szPrefix), "pv%dPosX", v);
  683. cache_get_field_content(i, szPrefix, szResult, MainPipeline); tmpVehArray[0] = floatstr(szResult);
  684. format(szPrefix, sizeof(szPrefix), "pv%dPosY", v);
  685. cache_get_field_content(i, szPrefix, szResult, MainPipeline); tmpVehArray[1] = floatstr(szResult);
  686. format(szPrefix, sizeof(szPrefix), "pv%dPosZ", v);
  687. cache_get_field_content(i, szPrefix, szResult, MainPipeline); tmpVehArray[2] = floatstr(szResult);
  688. format(szPrefix, sizeof(szPrefix), "pv%dPosAngle", v);
  689. cache_get_field_content(i, szPrefix, szResult, MainPipeline); tmpVehArray[3] = floatstr(szResult);
  690.  
  691. if(tmpVehModelId >= 400)
  692. {
  693. printf("Stored %d Vehicle Slot", v);
  694.  
  695. format(szPrefix, sizeof(szPrefix), "tmpVeh%dModelId", v);
  696. SetPVarInt(extraid, szPrefix, tmpVehModelId);
  697.  
  698. format(szPrefix, sizeof(szPrefix), "tmpVeh%dPosX", v);
  699. SetPVarFloat(extraid, szPrefix, tmpVehArray[0]);
  700.  
  701. format(szPrefix, sizeof(szPrefix), "tmpVeh%dPosY", v);
  702. SetPVarFloat(extraid, szPrefix, tmpVehArray[1]);
  703.  
  704. format(szPrefix, sizeof(szPrefix), "tmpVeh%dPosZ", v);
  705. SetPVarFloat(extraid, szPrefix, tmpVehArray[2]);
  706.  
  707. format(szPrefix, sizeof(szPrefix), "tmpVeh%dAngle", v);
  708. SetPVarFloat(extraid, szPrefix, tmpVehArray[3]);
  709. }
  710. }
  711. break;
  712. }
  713.  
  714. if(bVehRestore == true) {
  715. // person Vehicle Position Restore Granted, Now Purge them from the Table.
  716. new query[128];
  717. format(query, sizeof(query), "DELETE FROM `pvehpositions` WHERE `id`='%d'", PlayerInfo[extraid][pId]);
  718. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, extraid);
  719. }
  720.  
  721. OnPlayerLoad(extraid);
  722. }
  723. }
  724. case IPBAN_THREAD:
  725. {
  726. if(rows > 0)
  727. {
  728. SendClientMessage(extraid, COLOR_RED, "Your IP is banned! You may appeal on the forums.");
  729. SetTimerEx("KickEx", 1000, 0, "i", extraid);
  730. }
  731. else
  732. {
  733. g_mysql_AccountAuthCheck(extraid);
  734. }
  735. }
  736. case LOADCRATE_THREAD:
  737. {
  738. for(new i; i < rows; i++)
  739. {
  740. new crateid, szResult[32], string[128];
  741. cache_get_field_content(i, "id", szResult, MainPipeline); crateid = strval(szResult);
  742. if(crateid < MAX_CRATES)
  743. {
  744. cache_get_field_content(i, "Active", szResult, MainPipeline); CrateInfo[crateid][crActive] = strval(szResult);
  745. cache_get_field_content(i, "CrateX", szResult, MainPipeline); CrateInfo[crateid][crX] = floatstr(szResult);
  746. cache_get_field_content(i, "CrateY", szResult, MainPipeline); CrateInfo[crateid][crY] = floatstr(szResult);
  747. cache_get_field_content(i, "CrateZ", szResult, MainPipeline); CrateInfo[crateid][crZ] = floatstr(szResult);
  748. cache_get_field_content(i, "Int", szResult, MainPipeline); CrateInfo[crateid][crInt] = strval(szResult);
  749. cache_get_field_content(i, "VW", szResult, MainPipeline); CrateInfo[crateid][crVW] = strval(szResult);
  750. cache_get_field_content(i, "PlacedBy", szResult, MainPipeline); format(CrateInfo[crateid][crPlacedBy], MAX_PLAYER_NAME, szResult);
  751. cache_get_field_content(i, "GunQuantity", szResult, MainPipeline); CrateInfo[crateid][GunQuantity] = strval(szResult);
  752. cache_get_field_content(i, "InVehicle", szResult, MainPipeline); CrateInfo[crateid][InVehicle] = strval(szResult);
  753. if(CrateInfo[crateid][InVehicle] != INVALID_VEHICLE_ID)
  754. {
  755. CrateInfo[crateid][crActive] = 0;
  756. CrateInfo[crateid][InVehicle] = INVALID_VEHICLE_ID;
  757. }
  758. if(CrateInfo[crateid][crActive])
  759. {
  760. CrateInfo[crateid][InVehicle] = INVALID_VEHICLE_ID;
  761. CrateInfo[crateid][crObject] = CreateDynamicObject(964,CrateInfo[crateid][crX],CrateInfo[crateid][crY],CrateInfo[crateid][crZ],0.00000000,0.00000000,0.00000000,CrateInfo[i][crVW], CrateInfo[i][crInt]);
  762. format(string, sizeof(string), "Serial Number: #%d\n High Grade Materials: %d/50\n (( Dropped by: %s ))", i, CrateInfo[crateid][GunQuantity], CrateInfo[crateid][crPlacedBy]);
  763. CrateInfo[crateid][crLabel] = CreateDynamic3DTextLabel(string, COLOR_ORANGE, CrateInfo[crateid][crX],CrateInfo[crateid][crY],CrateInfo[crateid][crZ]+1, 10.0, _, _, 1, CrateInfo[crateid][crVW], CrateInfo[crateid][crInt], _, 20.0);
  764.  
  765. }
  766. }
  767. }
  768. print("[LoadCrates] Loading Crates Finished");
  769. }
  770. case MAIN_REFERRAL_THREAD:
  771. {
  772. new newrows, newfields, szString[128], szQuery[128];
  773. cache_get_data(newrows, newfields, MainPipeline);
  774.  
  775. if(newrows == 0)
  776. {
  777. format(szString, sizeof(szString), "Nobody");
  778. strmid(PlayerInfo[extraid][pReferredBy], szString, 0, strlen(szString), MAX_PLAYER_NAME);
  779. ShowPlayerDialog(extraid, REGISTERREF, DIALOG_STYLE_INPUT, "{FF0000}Error - Invalid Player", "There is no player registered to our server with such name.\nPlease enter the full name of the player who referred you.\nExample: FirstName_LastName", "Enter", "Cancel");
  780. }
  781. else {
  782. format(szQuery, sizeof(szQuery), "SELECT `IP` FROM `accounts` WHERE `Username` = '%s'", PlayerInfo[extraid][pReferredBy]);
  783. mysql_function_query(MainPipeline, szQuery, true, "ReferralSecurity", "i", extraid);
  784. }
  785. }
  786. case REWARD_REFERRAL_THREAD:
  787. {
  788. new newrows, newfields;
  789. cache_get_data(newrows, newfields, MainPipeline);
  790.  
  791. if(newrows != 0)
  792. {
  793. SendClientMessageEx(extraid, COLOR_YELLOW, "The player who referred you does not have a account on our server anymore, therefore he has not received any credits");
  794. }
  795. }
  796. case OFFLINE_FAMED_THREAD:
  797. {
  798. new newrows, newfields, szQuery[128], string[128], szName[MAX_PLAYER_NAME];
  799. cache_get_data(newrows, newfields, MainPipeline);
  800.  
  801. if(newrows == 0)
  802. {
  803. SendClientMessageEx(extraid, COLOR_RED, "Error - This account does not exist.");
  804. }
  805. else {
  806. new
  807. ilevel = GetPVarInt(extraid, "Offline_Famed");
  808.  
  809. GetPVarString(extraid, "Offline_Name", szName, MAX_PLAYER_NAME);
  810.  
  811. format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `Famed` = %d WHERE `Username` = '%s'", ilevel, szName);
  812. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  813.  
  814. format(string, sizeof(string), "AdmCmd: %s has offline set %s to a level %d famed", GetPlayerNameEx(extraid), szName, ilevel);
  815. SendFamedMessage(COLOR_LIGHTRED, string);
  816. ABroadCast(COLOR_LIGHTRED, string, 2);
  817. Log("logs/setfamed.log", string);
  818. DeletePVar(extraid, "Offline_Famed");
  819. DeletePVar(extraid, "Offline_Name");
  820. }
  821. }
  822. case BUG_LIST_THREAD:
  823. {
  824. if(rows == 0) return 1;
  825. new szResult[MAX_PLAYER_NAME];
  826. for(new i; i < rows; i++)
  827. {
  828. cache_get_field_content(i, "Username", szResult, MainPipeline); SendClientMessageEx(extraid, COLOR_GRAD2, szResult);
  829. }
  830. }
  831. case ADMINWHITELIST_THREAD:
  832. {
  833. new string[128];
  834. for(new i;i < rows;i++)
  835. {
  836. new secureip[16], szResult[32], alevel;
  837. cache_get_field_content(i, "AdminLevel", szResult, MainPipeline); alevel = strval(szResult);
  838. cache_get_field_content(i, "SecureIP", secureip, MainPipeline, 16);
  839.  
  840. if(alevel > 1 && !fexist("NoWhitelist.h")) // Beta server check ( beta server does not require whitelisting)
  841. {
  842. if(isnull(secureip) || strcmp(GetPlayerIpEx(extraid), secureip, false, strlen(secureip)) != 0)
  843. {
  844. if(strcmp(GetPlayerIpEx(extraid), "127.0.0.1", false, 16) != 0)
  845. {
  846. SendClientMessage(extraid, COLOR_WHITE, "SERVER: Your IP does not match the whitelisted IP of that account. Contact a Senior+ Admin to whitelist your current IP.");
  847. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s has been auto kicked for logging in with a non-whitelisted IP.", GetPlayerNameEx(extraid));
  848. ABroadCast(COLOR_YELLOW, string, 2);
  849. SetTimerEx("KickEx", 1000, 0, "i", extraid);
  850. return true;
  851. }
  852. }
  853. }
  854. }
  855. return true;
  856. }
  857. case LOADGIFTBOX_THREAD:
  858. {
  859. for(new i; i < rows; i++)
  860. {
  861. new szResult[32], arraystring[128];
  862. for(new array = 0; array < 4; array++)
  863. {
  864. format(arraystring, sizeof(arraystring), "dgMoney%d", array);
  865. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgMoney[array] = strval(szResult);
  866. format(arraystring, sizeof(arraystring), "dgRimKit%d", array);
  867. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgRimKit[array] = strval(szResult);
  868. format(arraystring, sizeof(arraystring), "dgFirework%d", array);
  869. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgFirework[array] = strval(szResult);
  870. format(arraystring, sizeof(arraystring), "dgGVIP%d", array);
  871. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgGVIP[array] = strval(szResult);
  872. format(arraystring, sizeof(arraystring), "dgSVIP%d", array);
  873. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgSVIP[array] = strval(szResult);
  874. format(arraystring, sizeof(arraystring), "dgGVIPEx%d", array);
  875. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgGVIPEx[array] = strval(szResult);
  876. format(arraystring, sizeof(arraystring), "dgSVIPEx%d", array);
  877. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgSVIPEx[array] = strval(szResult);
  878. format(arraystring, sizeof(arraystring), "dgCarSlot%d", array);
  879. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgCarSlot[array] = strval(szResult);
  880. format(arraystring, sizeof(arraystring), "dgToySlot%d", array);
  881. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgToySlot[array] = strval(szResult);
  882. format(arraystring, sizeof(arraystring), "dgArmor%d", array);
  883. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgArmor[array] = strval(szResult);
  884. format(arraystring, sizeof(arraystring), "dgFirstaid%d", array);
  885. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgFirstaid[array] = strval(szResult);
  886. format(arraystring, sizeof(arraystring), "dgDDFlag%d", array);
  887. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgDDFlag[array] = strval(szResult);
  888. format(arraystring, sizeof(arraystring), "dgGateFlage%d", array);
  889. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgGateFlag[array] = strval(szResult);
  890. format(arraystring, sizeof(arraystring), "dgCredits%d", array);
  891. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgCredits[array] = strval(szResult);
  892. format(arraystring, sizeof(arraystring), "dgPriorityAd%d", array);
  893. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgPriorityAd[array] = strval(szResult);
  894. format(arraystring, sizeof(arraystring), "dgHealthNArmor%d", array);
  895. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgHealthNArmor[array] = strval(szResult);
  896. format(arraystring, sizeof(arraystring), "dgGiftReset%d", array);
  897. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgGiftReset[array] = strval(szResult);
  898. format(arraystring, sizeof(arraystring), "dgMaterial%d", array);
  899. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgMaterial[array] = strval(szResult);
  900. format(arraystring, sizeof(arraystring), "dgWarning%d", array);
  901. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgWarning[array] = strval(szResult);
  902. format(arraystring, sizeof(arraystring), "dgPot%d", array);
  903. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgPot[array] = strval(szResult);
  904. format(arraystring, sizeof(arraystring), "dgCrack%d", array);
  905. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgCrack[array] = strval(szResult);
  906. format(arraystring, sizeof(arraystring), "dgPaintballToken%d", array);
  907. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgPaintballToken[array] = strval(szResult);
  908. format(arraystring, sizeof(arraystring), "dgVIPToken%d", array);
  909. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgVIPToken[array] = strval(szResult);
  910. format(arraystring, sizeof(arraystring), "dgRespectPoint%d", array);
  911. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgRespectPoint[array] = strval(szResult);
  912. format(arraystring, sizeof(arraystring), "dgCarVoucher%d", array);
  913. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgCarVoucher[array] = strval(szResult);
  914. format(arraystring, sizeof(arraystring), "dgBuddyInvite%d", array);
  915. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgBuddyInvite[array] = strval(szResult);
  916. format(arraystring, sizeof(arraystring), "dgLaser%d", array);
  917. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgLaser[array] = strval(szResult);
  918. format(arraystring, sizeof(arraystring), "dgCustomToy%d", array);
  919. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgCustomToy[array] = strval(szResult);
  920. format(arraystring, sizeof(arraystring), "dgAdmuteReset%d", array);
  921. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgAdmuteReset[array] = strval(szResult);
  922. format(arraystring, sizeof(arraystring), "dgNewbieMuteReset%d", array);
  923. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgNewbieMuteReset[array] = strval(szResult);
  924. format(arraystring, sizeof(arraystring), "dgRestrictedCarVoucher%d", array);
  925. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgRestrictedCarVoucher[array] = strval(szResult);
  926. format(arraystring, sizeof(arraystring), "dgPlatinumVIPVoucher%d", array);
  927. cache_get_field_content(i, arraystring, szResult, MainPipeline); dgPlatinumVIPVoucher[array] = strval(szResult);
  928. }
  929. break;
  930. }
  931. print("[Dynamic Giftbox] Successfully loaded the dynamic giftbox.");
  932. }
  933. case LOADCP_STORE:
  934. {
  935. if(IsPlayerConnected(extraid))
  936. {
  937. new szResult[32];
  938. for(new i; i < rows; i++)
  939. {
  940. cache_get_field_content(i, "User_Id", szResult, MainPipeline);
  941.  
  942. if(rows > 0)
  943. {
  944. cache_get_field_content(i, "id", szResult, MainPipeline); CpStore[extraid][cId] = strval(szResult);
  945. cache_get_field_content(i, "XP", szResult, MainPipeline); CpStore[extraid][cXP] = strval(szResult);
  946. // now lets process the data below to give to the player.
  947. ClaimShopItems(extraid);
  948. }
  949. }
  950. if(rows == 0)
  951. {
  952. SendClientMessageEx(extraid, COLOR_RED, "You have no items pending from the user control panel.");
  953. }
  954. }
  955. return 1;
  956. }
  957. }
  958. return 1;
  959. }
  960.  
  961. public OnQueryError(errorid, error[], callback[], query[], connectionHandle)
  962. {
  963. printf("[MySQL] Query Error - (ErrorID: %d) (Handle: %d)", errorid, connectionHandle);
  964. print("[MySQL] Check mysql_log.txt to review the query that threw the error.");
  965. SQL_Log(query, error);
  966.  
  967. if(errorid == 2013 || errorid == 2014 || errorid == 2006 || errorid == 2027 || errorid == 2055)
  968. {
  969. print("[MySQL] Connection Error Detected in Threaded Query");
  970. //mysql_query(query, resultid, extraid, MainPipeline);
  971. }
  972. }
  973.  
  974. //--------------------------------[ CUSTOM STOCK FUNCTIONS ]---------------------------
  975.  
  976. // g_mysql_Check_Store(playerid)
  977. // Description: Checks if the player has any pending items from the ucp.
  978. stock g_mysql_Check_Store(playerid)
  979. {
  980. new string[128];
  981. format(string, sizeof(string), "SELECT * FROM `cp_store` WHERE `User_Id` = %d", GetPlayerSQLId(playerid));
  982. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", LOADCP_STORE, playerid, g_arrQueryHandle{playerid});
  983. return 1;
  984. }
  985.  
  986. // g_mysql_ReturnEscaped(string unEscapedString)
  987. // Description: Takes a unescaped string and returns an escaped one.
  988. stock g_mysql_ReturnEscaped(unEscapedString[], connectionHandle)
  989. {
  990. new EscapedString[256];
  991. mysql_real_escape_string(unEscapedString, EscapedString, connectionHandle);
  992. return EscapedString;
  993. }
  994.  
  995. // g_mysql_AccountLoginCheck(playerid)
  996. stock g_mysql_AccountLoginCheck(playerid)
  997. {
  998. ShowNoticeGUIFrame(playerid, 2);
  999.  
  1000. new string[128];
  1001.  
  1002. format(string, sizeof(string), "SELECT `Username`, `Key` FROM `accounts` WHERE `Username` = '%s'", GetPlayerNameExt(playerid));
  1003. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", LOGIN_THREAD, playerid, g_arrQueryHandle{playerid});
  1004. return 1;
  1005. }
  1006.  
  1007. // g_mysql_AccountAuthCheck(playerid)
  1008. g_mysql_AccountAuthCheck(playerid)
  1009. {
  1010. new string[128];
  1011.  
  1012. format(string, sizeof(string), "SELECT `Username` FROM `accounts` WHERE `Username` = '%s'", GetPlayerNameExt(playerid));
  1013. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", AUTH_THREAD, playerid, g_arrQueryHandle{playerid});
  1014.  
  1015. // Reset the GUI
  1016. SetPlayerJoinCamera(playerid);
  1017. ClearChatbox(playerid);
  1018. SetPlayerVirtualWorld(playerid, 0);
  1019.  
  1020.  
  1021. return 1;
  1022. }
  1023.  
  1024. // g_mysql_AccountOnline(int playerid, int stateid)
  1025. stock g_mysql_AccountOnline(playerid, stateid)
  1026. {
  1027. new string[128];
  1028. format(string, sizeof(string), "UPDATE `accounts` SET `Online`=%d, `LastLogin` = NOW() WHERE `id` = %d", stateid, GetPlayerSQLId(playerid));
  1029. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  1030. return 1;
  1031. }
  1032.  
  1033. stock g_mysql_AccountOnlineReset()
  1034. {
  1035. new string[128];
  1036. format(string, sizeof(string), "UPDATE `accounts` SET `Online` = 0 WHERE `Online` = %d", servernumber);
  1037. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1038. return 1;
  1039. }
  1040.  
  1041. // g_mysql_CreateAccount(int playerid, string accountPassword[])
  1042. // Description: Creates a new account in the database.
  1043. stock g_mysql_CreateAccount(playerid, accountPassword[])
  1044. {
  1045. new string[256];
  1046. new passbuffer[129];
  1047. WP_Hash(passbuffer, sizeof(passbuffer), accountPassword);
  1048.  
  1049. format(string, sizeof(string), "INSERT INTO `accounts` (`RegiDate`, `LastLogin`, `Username`, `Key`) VALUES (NOW(), NOW(), '%s','%s')", GetPlayerNameExt(playerid), passbuffer);
  1050. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "iii", REGISTER_THREAD, playerid, g_arrQueryHandle{playerid});
  1051. return 1;
  1052. }
  1053.  
  1054. stock g_mysql_LoadPVehicles(playerid)
  1055. {
  1056. new string[128];
  1057. format(string, sizeof(string), "SELECT * FROM `vehicles` WHERE `sqlID` = %d", PlayerInfo[playerid][pId]);
  1058. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", LOADPVEHICLE_THREAD, playerid, g_arrQueryHandle{playerid});
  1059. return 1;
  1060. }
  1061.  
  1062. // g_mysql_LoadPVehiclePositions(playerid)
  1063. // Description: Loads vehicle positions if person has timed out.
  1064. stock g_mysql_LoadPVehiclePositions(playerid)
  1065. {
  1066. new string[128];
  1067.  
  1068. format(string, sizeof(string), "SELECT * FROM `pvehpositions` WHERE `id` = %d", PlayerInfo[playerid][pId]);
  1069. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", LOADPVEHPOS_THREAD, playerid, g_arrQueryHandle{playerid});
  1070. return 1;
  1071. }
  1072.  
  1073. // g_mysql_LoadPlayerToys(playerid)
  1074. // Description: Load the player toys
  1075. stock g_mysql_LoadPlayerToys(playerid)
  1076. {
  1077. new szQuery[128];
  1078. format(szQuery, sizeof(szQuery), "SELECT * FROM `toys` WHERE `player` = %d", PlayerInfo[playerid][pId]);
  1079. mysql_function_query(MainPipeline, szQuery, true, "OnQueryFinish", "iii", LOADPTOYS_THREAD, playerid, g_arrQueryHandle{playerid});
  1080. return 1;
  1081. }
  1082.  
  1083. // g_mysql_LoadAccount(playerid)
  1084. // Description: Loads an account from database into memory.
  1085. stock g_mysql_LoadAccount(playerid)
  1086. {
  1087. ShowNoticeGUIFrame(playerid, 3);
  1088.  
  1089. new string[164];
  1090. format(string, sizeof(string), "SELECT * FROM `accounts` WHERE `Username` = '%s'", GetPlayerNameExt(playerid));
  1091. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", LOADUSERDATA_THREAD, playerid, g_arrQueryHandle{playerid});
  1092. return 1;
  1093. }
  1094.  
  1095. // g_mysql_RemoveDumpFile(sqlid)
  1096. // Description: Removes a account's dump file. Helpful upon logoff.
  1097. stock g_mysql_RemoveDumpFile(sqlid)
  1098. {
  1099. new pwnfile[128];
  1100. format(pwnfile, sizeof(pwnfile), "/accdump/%d.dump", sqlid);
  1101.  
  1102. if(fexist(pwnfile))
  1103. {
  1104. fremove(pwnfile);
  1105. return 1;
  1106. }
  1107. return 0;
  1108. }
  1109.  
  1110. GivePlayerCredits(Player, Amount, Shop)
  1111. {
  1112. new szQuery[128];
  1113. PlayerInfo[Player][pCredits] += Amount;
  1114.  
  1115. format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `Credits`=%d WHERE `id` = %d", PlayerInfo[Player][pCredits], GetPlayerSQLId(Player));
  1116. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, Player);
  1117. print(szQuery);
  1118.  
  1119. if(Shop == 1)
  1120. {
  1121. if(Amount < 0) Amount = Amount*-1;
  1122. PlayerInfo[Player][pTotalCredits] += Amount;
  1123. }
  1124.  
  1125. format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `TotalCredits`=%d WHERE `id` = %d", PlayerInfo[Player][pTotalCredits], GetPlayerSQLId(Player));
  1126. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, Player);
  1127. print(szQuery);
  1128. }
  1129.  
  1130. // g_mysql_SaveVehicle(int playerid, int slotid)
  1131. // Description: Saves a account's specified vehicle slot.
  1132. stock g_mysql_SaveVehicle(playerid, slotid)
  1133. {
  1134. new query[2048];
  1135. printf("%s (%i) saving their %d (slot %i) (Model %i)...", GetPlayerNameEx(playerid), playerid, PlayerVehicleInfo[playerid][slotid][pvModelId], slotid, PlayerVehicleInfo[playerid][slotid][pvModelId]);
  1136.  
  1137. format(query, sizeof(query), "UPDATE `vehicles` SET");
  1138. format(query, sizeof(query), "%s `pvPosX` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvPosX]);
  1139. format(query, sizeof(query), "%s `pvPosY` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvPosY]);
  1140. format(query, sizeof(query), "%s `pvPosZ` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvPosZ]);
  1141. format(query, sizeof(query), "%s `pvPosAngle` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvPosAngle]);
  1142. format(query, sizeof(query), "%s `pvLock` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvLock]);
  1143. format(query, sizeof(query), "%s `pvLocked` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvLocked]);
  1144. format(query, sizeof(query), "%s `pvPaintJob` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvPaintJob]);
  1145. format(query, sizeof(query), "%s `pvColor1` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvColor1]);
  1146. format(query, sizeof(query), "%s `pvColor2` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvColor2]);
  1147. format(query, sizeof(query), "%s `pvPrice` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvPrice]);
  1148. format(query, sizeof(query), "%s `pvWeapon0` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvWeapons][0]);
  1149. format(query, sizeof(query), "%s `pvWeapon1` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvWeapons][1]);
  1150. format(query, sizeof(query), "%s `pvWeapon2` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvWeapons][2]);
  1151. format(query, sizeof(query), "%s `pvLock` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvLock]);
  1152. format(query, sizeof(query), "%s `pvWepUpgrade` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvWepUpgrade]);
  1153. format(query, sizeof(query), "%s `pvFuel` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvFuel]);
  1154. format(query, sizeof(query), "%s `pvImpound` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvImpounded]);
  1155. format(query, sizeof(query), "%s `pvDisabled` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvDisabled]);
  1156. format(query, sizeof(query), "%s `pvPlate` = '%s',", query, g_mysql_ReturnEscaped(PlayerVehicleInfo[playerid][slotid][pvPlate], MainPipeline));
  1157. format(query, sizeof(query), "%s `pvTicket` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvTicket]);
  1158. format(query, sizeof(query), "%s `pvRestricted` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvRestricted]);
  1159. format(query, sizeof(query), "%s `pvVW` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvVW]);
  1160. format(query, sizeof(query), "%s `pvInt` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvInt]);
  1161. format(query, sizeof(query), "%s `pvCrashFlag` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvCrashFlag]);
  1162. format(query, sizeof(query), "%s `pvCrashVW` = %d,", query, PlayerVehicleInfo[playerid][slotid][pvCrashVW]);
  1163. format(query, sizeof(query), "%s `pvCrashX` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvCrashX]);
  1164. format(query, sizeof(query), "%s `pvCrashY` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvCrashY]);
  1165. format(query, sizeof(query), "%s `pvCrashZ` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvCrashZ]);
  1166. format(query, sizeof(query), "%s `pvCrashAngle` = %0.5f,", query, PlayerVehicleInfo[playerid][slotid][pvCrashAngle]);
  1167.  
  1168. for(new m = 0; m < MAX_MODS; m++)
  1169. {
  1170. if(m == MAX_MODS-1)
  1171. {
  1172. format(query, sizeof(query), "%s `pvMod%d` = %d WHERE `id` = '%d'", query, m, PlayerVehicleInfo[playerid][slotid][pvMods][m], PlayerVehicleInfo[playerid][slotid][pvSlotId]);
  1173. }
  1174. else
  1175. {
  1176. format(query, sizeof(query), "%s `pvMod%d` = %d,", query, m, PlayerVehicleInfo[playerid][slotid][pvMods][m]);
  1177. }
  1178. }
  1179. //print(query);
  1180.  
  1181. new szLog[128];
  1182. format(szLog, sizeof(szLog), "[VEHICLESAVE] [User: %s(%i)] [Model: %d] [Vehicle ID: %d]", GetPlayerNameEx(playerid), PlayerInfo[playerid][pId], PlayerVehicleInfo[playerid][slotid][pvModelId], PlayerVehicleInfo[playerid][slotid][pvSlotId]);
  1183. Log("logs/vehicledebug.log", szLog);
  1184.  
  1185. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  1186. }
  1187.  
  1188. // native g_mysql_SaveToys(int playerid, int slotid)
  1189. stock g_mysql_SaveToys(playerid, slotid)
  1190. {
  1191. new szQuery[2048];
  1192.  
  1193. if(PlayerToyInfo[playerid][slotid][ptID] >= 1) // Making sure the player actually has a toy so we won't save a empty row
  1194. {
  1195. //printf("%s (%i) saving toy %i...", GetPlayerNameEx(playerid), playerid, slotid);
  1196.  
  1197. format(szQuery, sizeof(szQuery), "UPDATE `toys` SET `modelid` = '%d', `bone` = '%d', `posx` = '%f', `posy` = '%f', `posz` = '%f', `rotx` = '%f', `roty` = '%f', `rotz` = '%f', `scalex` = '%f', `scaley` = '%f', `scalez` = '%f', `tradable` = '%d' WHERE `id` = '%d'",
  1198. PlayerToyInfo[playerid][slotid][ptModelID],
  1199. PlayerToyInfo[playerid][slotid][ptBone],
  1200. PlayerToyInfo[playerid][slotid][ptPosX],
  1201. PlayerToyInfo[playerid][slotid][ptPosY],
  1202. PlayerToyInfo[playerid][slotid][ptPosZ],
  1203. PlayerToyInfo[playerid][slotid][ptRotX],
  1204. PlayerToyInfo[playerid][slotid][ptRotY],
  1205. PlayerToyInfo[playerid][slotid][ptRotZ],
  1206. PlayerToyInfo[playerid][slotid][ptScaleX],
  1207. PlayerToyInfo[playerid][slotid][ptScaleY],
  1208. PlayerToyInfo[playerid][slotid][ptScaleZ],
  1209. PlayerToyInfo[playerid][slotid][ptTradable],
  1210. PlayerToyInfo[playerid][slotid][ptID]);
  1211.  
  1212. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  1213. }
  1214. }
  1215.  
  1216. // native g_mysql_NewToy(int playerid, int slotid)
  1217. stock g_mysql_NewToy(playerid, slotid)
  1218. {
  1219. new szQuery[2048];
  1220. if(PlayerToyInfo[playerid][slotid][ptSpecial] != 1) { PlayerToyInfo[playerid][slotid][ptSpecial] = 0; }
  1221.  
  1222. format(szQuery, sizeof(szQuery), "INSERT INTO `toys` (player, modelid, bone, posx, posy, posz, rotx, roty, rotz, scalex, scaley, scalez, tradable, special) VALUES ('%d', '%d', '%d', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%f', '%d', '%d')",
  1223. PlayerInfo[playerid][pId],
  1224. PlayerToyInfo[playerid][slotid][ptModelID],
  1225. PlayerToyInfo[playerid][slotid][ptBone],
  1226. PlayerToyInfo[playerid][slotid][ptPosX],
  1227. PlayerToyInfo[playerid][slotid][ptPosY],
  1228. PlayerToyInfo[playerid][slotid][ptPosZ],
  1229. PlayerToyInfo[playerid][slotid][ptRotX],
  1230. PlayerToyInfo[playerid][slotid][ptRotY],
  1231. PlayerToyInfo[playerid][slotid][ptRotZ],
  1232. PlayerToyInfo[playerid][slotid][ptScaleX],
  1233. PlayerToyInfo[playerid][slotid][ptScaleY],
  1234. PlayerToyInfo[playerid][slotid][ptScaleZ],
  1235. PlayerToyInfo[playerid][slotid][ptTradable],
  1236. PlayerToyInfo[playerid][slotid][ptSpecial]);
  1237.  
  1238. mysql_function_query(MainPipeline, szQuery, true, "OnQueryCreateToy", "ii", playerid, slotid);
  1239. }
  1240.  
  1241. // g_mysql_LoadMOTD()
  1242. // Description: Loads the MOTDs from the MySQL Database.
  1243. stock g_mysql_LoadMOTD()
  1244. {
  1245. mysql_function_query(MainPipeline, "SELECT `gMOTD`,`aMOTD`,`vMOTD`,`cMOTD`,`pMOTD`,`ShopTechPay`,`GiftCode`,`GiftCodeBypass`,`TotalCitizens`,`TRCitizens`,`SecurityCode`,`ShopClosed`,`RimMod`,`CarVoucher`,`PVIPVoucher`, `GarageVW`, `PumpkinStock`, `HalloweenShop` FROM `misc`", true, "OnQueryFinish", "iii", LOADMOTDDATA_THREAD, INVALID_PLAYER_ID, -1);
  1246. }
  1247.  
  1248. stock g_mysql_LoadSales()
  1249. {
  1250. mysql_function_query(MainPipeline, "SELECT * FROM `sales` WHERE `Month` > NOW() - INTERVAL 1 MONTH", true, "OnQueryFinish", "iii", LOADSALEDATA_THREAD, INVALID_PLAYER_ID, -1);
  1251. //mysql_function_query(MainPipeline, "SELECT `TotalToySales`,`TotalCarSales`,`GoldVIPSales`,`SilverVIPSales`,`BronzeVIPSales` FROM `sales` WHERE `Month` > NOW() - INTERVAL 1 MONTH", true, "OnQueryFinish", "iii", LOADSALEDATA_THREAD, INVALID_PLAYER_ID, -1);
  1252. }
  1253.  
  1254. stock g_mysql_LoadPrices()
  1255. {
  1256. mysql_function_query(MainPipeline, "SELECT * FROM `shopprices`", true, "OnQueryFinish", "iii", LOADSHOPDATA_THREAD, INVALID_PLAYER_ID, -1);
  1257. }
  1258.  
  1259. g_mysql_SavePrices()
  1260. {
  1261. new query[2000];
  1262. format(query, sizeof(query), "UPDATE `shopprices` SET `Price0` = '%d', `Price1` = '%d', `Price2` = '%d', `Price3` = '%d', `Price4` = '%d', `Price5` = '%d', `Price6` = '%d', `Price7` = '%d', `Price8` = '%d', `Price9` = '%d', `Price10` = '%d', \
  1263. `Price11` = '%d', `Price12` = '%d', `Price13` = '%d', `Price14` = '%d', `Price15` = '%d', `Price16` = '%d', `Price17` = '%d',", ShopItems[0][sItemPrice], ShopItems[1][sItemPrice], ShopItems[2][sItemPrice], ShopItems[3][sItemPrice], ShopItems[4][sItemPrice],
  1264. ShopItems[5][sItemPrice], ShopItems[6][sItemPrice], ShopItems[7][sItemPrice], ShopItems[8][sItemPrice], ShopItems[9][sItemPrice], ShopItems[10][sItemPrice], ShopItems[11][sItemPrice], ShopItems[12][sItemPrice], ShopItems[13][sItemPrice], ShopItems[14][sItemPrice], ShopItems[15][sItemPrice],
  1265. ShopItems[16][sItemPrice], ShopItems[17][sItemPrice]);
  1266. format(query, sizeof(query), "%s `Price18` = '%d', `Price19` = '%d', `Price20` = '%d', `Price21` = '%d', `Price22` = '%d', `Price23` = '%d', `Price24` = '%d', `Price25` = '%d', `Price26` = '%d', `Price27` = '%d', `Price28` = '%d'", query, ShopItems[18][sItemPrice], ShopItems[19][sItemPrice], ShopItems[20][sItemPrice], ShopItems[21][sItemPrice],
  1267. ShopItems[22][sItemPrice], ShopItems[23][sItemPrice], ShopItems[24][sItemPrice], ShopItems[25][sItemPrice], ShopItems[26][sItemPrice], ShopItems[27][sItemPrice], ShopItems[28][sItemPrice]);
  1268. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1269. }
  1270.  
  1271. stock g_mysql_SaveMOTD()
  1272. {
  1273. new query[1024];
  1274.  
  1275. format(query, sizeof(query), "UPDATE `misc` SET ");
  1276.  
  1277. format(query, sizeof(query), "%s `gMOTD` = '%s',", query, g_mysql_ReturnEscaped(GlobalMOTD, MainPipeline));
  1278. format(query, sizeof(query), "%s `HalloweenShop` = '%d'", query, HalloweenShop);
  1279.  
  1280. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1281. }
  1282.  
  1283. // g_mysql_LoadMOTD()
  1284. // Description: Loads the Crates from the MySQL Database.
  1285. stock mysql_LoadCrates()
  1286. {
  1287. mysql_function_query(MainPipeline, "SELECT * FROM `crates`", true, "OnQueryFinish", "iii", LOADCRATE_THREAD, INVALID_PLAYER_ID, -1);
  1288. print("[LoadCrates] Load Query Sent");
  1289. }
  1290.  
  1291. stock mysql_SaveCrates()
  1292. {
  1293. new query[1024];
  1294. for(new i; i < MAX_CRATES; i++)
  1295. {
  1296. printf("Saving Crate %d", i);
  1297. format(query, sizeof(query), "UPDATE `crates` SET ");
  1298.  
  1299. format(query, sizeof(query), "%s `Active` = '%d',", query, CrateInfo[i][crActive]);
  1300. format(query, sizeof(query), "%s `CrateX` = '%.2f',", query, CrateInfo[i][crX]);
  1301. format(query, sizeof(query), "%s `CrateY` = '%.2f',", query, CrateInfo[i][crY]);
  1302. format(query, sizeof(query), "%s `CrateZ` = '%.2f',", query, CrateInfo[i][crZ]);
  1303. format(query, sizeof(query), "%s `GunQuantity` = '%d',", query, CrateInfo[i][GunQuantity]);
  1304. format(query, sizeof(query), "%s `InVehicle` = '%d',", query, CrateInfo[i][InVehicle]);
  1305. format(query, sizeof(query), "%s `Int` = '%d',", query, CrateInfo[i][crInt]);
  1306. format(query, sizeof(query), "%s `VW` = '%d',", query, CrateInfo[i][crVW]);
  1307. format(query, sizeof(query), "%s `PlacedBy` = '%s'", query, CrateInfo[i][crPlacedBy]);
  1308. format(query, sizeof(query), "%s WHERE id = %d", query, i);
  1309.  
  1310. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1311. }
  1312. }
  1313.  
  1314. stock RemoveBan(Player, Ip[])
  1315. {
  1316. new string[128];
  1317. SetPVarString(Player, "UnbanIP", Ip);
  1318. format(string, sizeof(string), "SELECT `ip` FROM `ip_bans` WHERE `ip` = '%s'", Ip);
  1319. mysql_function_query(MainPipeline, string, true, "AddingBan", "ii", Player, 2);
  1320. return 1;
  1321. }
  1322.  
  1323. stock CheckBanEx(playerid)
  1324. {
  1325. new string[60];
  1326. format(string, sizeof(string), "SELECT `ip` FROM `ip_bans` WHERE `ip` = '%s'", GetPlayerIpEx(playerid));
  1327. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", IPBAN_THREAD, playerid, g_arrQueryHandle{playerid});
  1328. return 1;
  1329. }
  1330.  
  1331. stock AddBan(Admin, Player, Reason[])
  1332. {
  1333. new string[128];
  1334. SetPVarInt(Admin, "BanningPlayer", Player);
  1335. SetPVarString(Admin, "BanningReason", Reason);
  1336. format(string, sizeof(string), "SELECT `ip` FROM `ip_bans` WHERE `ip` = '%s'", GetPlayerIpEx(Player));
  1337. mysql_function_query(MainPipeline, string, true, "AddingBan", "ii", Admin, 1);
  1338. return 1;
  1339. }
  1340.  
  1341.  
  1342. stock SystemBan(Player, Reason[])
  1343. {
  1344. new string[150];
  1345. format(string, sizeof(string), "INSERT INTO `ip_bans` (`ip`, `date`, `reason`, `admin`) VALUES ('%s', NOW(), '%s', 'System')", GetPlayerIpEx(Player), Reason);
  1346. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1347. return 1;
  1348. }
  1349.  
  1350.  
  1351. stock MySQLBan(userid,ip[],reason[],status,admin[])
  1352. {
  1353. new string[200];
  1354. format(string, sizeof(string), "INSERT INTO `bans` (`user_id`, `ip_address`, `reason`, `date_added`, `status`, `admin`) VALUES ('%d','%s','%s', NOW(), '%d','%s')", userid,ip,reason,status,admin);
  1355. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1356. return 1;
  1357. }
  1358.  
  1359. stock AddCrime(cop, suspect, crime[])
  1360. {
  1361. new query[256];
  1362. format(query, sizeof(query), "INSERT INTO `mdc` (`id` ,`time` ,`issuer` ,`crime`) VALUES ('%d',NOW(),'%s','%s')", GetPlayerSQLId(suspect), g_mysql_ReturnEscaped(GetPlayerNameEx(cop), MainPipeline), g_mysql_ReturnEscaped(crime, MainPipeline));
  1363. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1364. format(query, sizeof(query), "MDC: %s added crime %s to %s.", GetPlayerNameEx(cop), crime, GetPlayerNameEx(suspect));
  1365. Log("logs/crime.log", query);
  1366. return 1;
  1367. }
  1368.  
  1369. stock ClearCrimes(playerid)
  1370. {
  1371. new query[80];
  1372. format(query, sizeof(query), "UPDATE `mdc` SET `active`=0 WHERE `id` = %i AND `active` = 1", GetPlayerSQLId(playerid));
  1373. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1374. return 1;
  1375. }
  1376.  
  1377. stock DisplayCrimes(playerid, suspectid)
  1378. {
  1379. new query[128];
  1380. format(query, sizeof(query), "SELECT issuer, crime, active FROM `mdc` WHERE id=%d ORDER BY `time` AND `active` DESC LIMIT 12", GetPlayerSQLId(suspectid));
  1381. mysql_function_query(MainPipeline, query, true, "MDCQueryFinish", "ii", playerid, suspectid);
  1382. return 1;
  1383. }
  1384.  
  1385. stock DisplayReports(playerid, suspectid)
  1386. {
  1387. new query[812];
  1388. format(query, sizeof(query), "SELECT arrestreports.id, copid, shortreport, datetime, accounts.id, accounts.Username FROM `arrestreports` LEFT JOIN `accounts` ON arrestreports.copid=accounts.id WHERE arrestreports.suspectid=%d ORDER BY arrestreports.datetime DESC LIMIT 12", GetPlayerSQLId(suspectid));
  1389. mysql_function_query(MainPipeline, query, true, "MDCReportsQueryFinish", "ii", playerid, suspectid);
  1390. return 1;
  1391. }
  1392.  
  1393. stock DisplayReport(playerid, reportid)
  1394. {
  1395. new query[812];
  1396. format(query, sizeof(query), "SELECT arrestreports.id, copid, shortreport, datetime, accounts.id, accounts.Username FROM `arrestreports` LEFT JOIN `accounts` ON arrestreports.copid=accounts.id WHERE arrestreports.id=%d ORDER BY arrestreports.datetime DESC LIMIT 12", reportid);
  1397. mysql_function_query(MainPipeline, query, true, "MDCReportQueryFinish", "ii", playerid, reportid);
  1398. return 1;
  1399. }
  1400.  
  1401. stock SetUnreadMailsNotification(playerid)
  1402. {
  1403. new query[128];
  1404. format(query, sizeof(query), "SELECT COUNT(*) AS Unread_Count FROM letters WHERE Receiver_ID = %d AND `Read` = 0", GetPlayerSQLId(playerid));
  1405. mysql_function_query(MainPipeline, query, true, "UnreadMailsNotificationQueryFin", "i", playerid);
  1406. return 1;
  1407. }
  1408.  
  1409. stock DisplayMails(playerid)
  1410. {
  1411. new query[150];
  1412. format(query, sizeof(query), "SELECT `Id`, `Message`, `Read` FROM `letters` WHERE `Receiver_Id` = %d AND `Delivery_Min` = 0 ORDER BY `Id` DESC LIMIT 50", GetPlayerSQLId(playerid));
  1413. mysql_function_query(MainPipeline, query, true, "MailsQueryFinish", "i", playerid);
  1414. }
  1415.  
  1416. stock DisplayMailDetails(playerid, letterid)
  1417. {
  1418. new query[256];
  1419. format(query, sizeof(query), "SELECT `Id`, `Date`, `Sender_Id`, `Read`, `Notify`, `Message`, (SELECT `Username` FROM `accounts` WHERE `id` = letters.Sender_Id) AS `SenderUser` FROM `letters` WHERE id = %d", letterid);
  1420. mysql_function_query(MainPipeline, query, true, "MailDetailsQueryFinish", "i", playerid);
  1421. }
  1422.  
  1423. stock CountFlags(playerid)
  1424. {
  1425. new query[80];
  1426. format(query, sizeof(query), "SELECT * FROM `flags` WHERE id=%d", GetPlayerSQLId(playerid));
  1427. mysql_function_query(MainPipeline, query, true, "FlagQueryFinish", "iii", playerid, INVALID_PLAYER_ID, Flag_Query_Count);
  1428. return 1;
  1429. }
  1430.  
  1431. stock AddFlag(playerid, adminid, flag[])
  1432. {
  1433. new query[300];
  1434. new admin[24];
  1435. if(adminid != INVALID_PLAYER_ID) {
  1436. format(admin, sizeof(admin), "%s", GetPlayerNameEx(adminid));
  1437. }
  1438. else {
  1439. format(admin, sizeof(admin), "Gifted/Script Added");
  1440. }
  1441. PlayerInfo[playerid][pFlagged]++;
  1442. format(query, sizeof(query), "INSERT INTO `flags` (`id` ,`time` ,`issuer` ,`flag`) VALUES ('%d',NOW(),'%s','%s')", GetPlayerSQLId(playerid), g_mysql_ReturnEscaped(admin, MainPipeline), g_mysql_ReturnEscaped(flag, MainPipeline));
  1443. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1444. format(query, sizeof(query), "FLAG: %s added flag %s to %s.", admin, flag, GetPlayerNameEx(playerid));
  1445. Log("logs/flags.log", query);
  1446. return 1;
  1447. }
  1448.  
  1449. stock AddOFlag(sqlid, adminid, flag[]) // offline add
  1450. {
  1451. new query[300];
  1452. new admin[24], name[24];
  1453. if(adminid != INVALID_PLAYER_ID) {
  1454. format(admin, sizeof(admin), "%s", GetPlayerNameEx(adminid));
  1455. }
  1456. else {
  1457. format(admin, sizeof(admin), "Gifted/Script Added");
  1458. }
  1459. GetPVarString(adminid, "OnAddFlag", name, sizeof(name));
  1460. format(query, sizeof(query), "INSERT INTO `flags` (`id` ,`time` ,`issuer` ,`flag`) VALUES ('%d',NOW(),'%s','%s')", sqlid, g_mysql_ReturnEscaped(admin, MainPipeline), g_mysql_ReturnEscaped(flag, MainPipeline));
  1461. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1462. format(query, sizeof(query), "FLAG: %s added flag %s to %s.", admin, flag, name);
  1463. Log("logs/flags.log", query);
  1464. DeletePVar(adminid, "OnAddFlag");
  1465. return 1;
  1466. }
  1467.  
  1468. stock DeleteFlag(flagid, adminid)
  1469. {
  1470. new query[80];
  1471. format(query, sizeof(query), "FLAG: Flag %d was deleted by %s.", flagid, GetPlayerNameEx(adminid));
  1472. Log("logs/flags.log", query);
  1473. format(query, sizeof(query), "DELETE FROM `flags` WHERE `fid` = %i", flagid);
  1474. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1475. return 1;
  1476. }
  1477.  
  1478. stock DisplayFlags(playerid, targetid)
  1479. {
  1480. new query[128];
  1481. CountFlags(targetid);
  1482. format(query, sizeof(query), "SELECT fid, issuer, flag, time FROM `flags` WHERE id=%d ORDER BY `time` LIMIT 15", GetPlayerSQLId(targetid));
  1483. mysql_function_query(MainPipeline, query, true, "FlagQueryFinish", "iii", playerid, targetid, Flag_Query_Display);
  1484. return 1;
  1485. }
  1486.  
  1487. stock CountSkins(playerid)
  1488. {
  1489. new query[80];
  1490. format(query, sizeof(query), "SELECT NULL FROM `house_closet` WHERE playerid = %d", GetPlayerSQLId(playerid));
  1491. mysql_function_query(MainPipeline, query, true, "SkinQueryFinish", "ii", playerid, Skin_Query_Count);
  1492. return 1;
  1493. }
  1494.  
  1495. stock AddSkin(playerid, skinid)
  1496. {
  1497. new query[300];
  1498. PlayerInfo[playerid][pSkins]++;
  1499. format(query, sizeof(query), "INSERT INTO `house_closet` (`id`, `playerid`, `skinid`) VALUES (NULL, '%d', '%d')", GetPlayerSQLId(playerid), skinid);
  1500. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1501. return 1;
  1502. }
  1503.  
  1504. stock DeleteSkin(skinid)
  1505. {
  1506. new query[80];
  1507. format(query, sizeof(query), "DELETE FROM `house_closet` WHERE `id` = %i", skinid);
  1508. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1509. return 1;
  1510. }
  1511.  
  1512. stock DisplaySkins(playerid)
  1513. {
  1514. new query[128];
  1515. CountSkins(playerid);
  1516. format(query, sizeof(query), "SELECT `skinid` FROM `house_closet` WHERE playerid = %d ORDER BY `skinid` ASC", GetPlayerSQLId(playerid));
  1517. mysql_function_query(MainPipeline, query, true, "SkinQueryFinish", "ii", playerid, Skin_Query_Display);
  1518. return 1;
  1519. }
  1520.  
  1521. stock CountCitizens()
  1522. {
  1523. mysql_function_query(MainPipeline, "SELECT NULL FROM `accounts` WHERE `Nation` = 1 && `UpdateDate` > NOW() - INTERVAL 1 WEEK", true, "CitizenQueryFinish", "i", TR_Citizen_Count);
  1524. mysql_function_query(MainPipeline, "SELECT NULL FROM `accounts` WHERE `UpdateDate` > NOW() - INTERVAL 1 WEEK", true, "CitizenQueryFinish", "i", Total_Count);
  1525. return 1;
  1526. }
  1527.  
  1528. stock CheckNationQueue(playerid, nation)
  1529. {
  1530. new query[300];
  1531. format(query, sizeof(query), "SELECT NULL FROM `nation_queue` WHERE `playerid` = %d AND `status` = 1", GetPlayerSQLId(playerid));
  1532. mysql_function_query(MainPipeline, query, true, "NationQueueQueryFinish", "iii", playerid, nation, CheckQueue);
  1533. }
  1534.  
  1535. stock AddNationQueue(playerid, nation, status)
  1536. {
  1537. new query[300];
  1538. if(nation == 0)
  1539. {
  1540. format(query, sizeof(query), "INSERT INTO `nation_queue` (`id`, `playerid`, `name`, `date`, `nation`, `status`) VALUES (NULL, %d, '%s', NOW(), 0, %d)", GetPlayerSQLId(playerid), GetPlayerNameExt(playerid), status);
  1541. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1542. }
  1543. if(nation == 1)
  1544. {
  1545. if(status == 1)
  1546. {
  1547. format(query, sizeof(query), "SELECT NULL FROM `nation_queue` WHERE `playerid` = %d AND `nation` = 1", GetPlayerSQLId(playerid));
  1548. mysql_function_query(MainPipeline, query, true, "NationQueueQueryFinish", "iii", playerid, nation, AddQueue);
  1549. }
  1550. else if(status == 2)
  1551. {
  1552. format(query, sizeof(query), "INSERT INTO `nation_queue` (`id`, `playerid`, `name`, `date`, `nation`, `status`) VALUES (NULL, %d, '%s', NOW(), 1, %d)", GetPlayerSQLId(playerid), GetPlayerNameExt(playerid), status);
  1553. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1554. PlayerInfo[playerid][pNation] = 1;
  1555. }
  1556. }
  1557. return 1;
  1558. }
  1559.  
  1560. stock UpdateCitizenApp(playerid, nation)
  1561. {
  1562. new query[300];
  1563. format(query, sizeof(query), "SELECT NULL FROM `nation_queue` WHERE `playerid` = %d AND `status` = 1", GetPlayerSQLId(playerid));
  1564. mysql_function_query(MainPipeline, query, true, "NationQueueQueryFinish", "iii", playerid, nation, UpdateQueue);
  1565. }
  1566.  
  1567. stock AddTicket(playerid, number)
  1568. {
  1569. new query[80];
  1570. PlayerInfo[playerid][pLottoNr]++;
  1571. format(query, sizeof(query), "INSERT INTO `lotto` (`id` ,`number`) VALUES ('%d', '%d')", GetPlayerSQLId(playerid), number);
  1572. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1573. return 1;
  1574. }
  1575.  
  1576. stock DeleteTickets(playerid)
  1577. {
  1578. new query[80];
  1579. format(query, sizeof(query), "DELETE FROM `lotto` WHERE `id` = %i", GetPlayerSQLId(playerid));
  1580. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1581. return 1;
  1582. }
  1583.  
  1584. stock LoadTickets(playerid)
  1585. {
  1586. new query[128];
  1587. format(query, sizeof(query), "SELECT `tid`, `number` FROM `lotto` WHERE `id` = %d LIMIT 5", GetPlayerSQLId(playerid));
  1588. mysql_function_query(MainPipeline, query, true, "LoadTicket", "i", playerid);
  1589. return 1;
  1590. }
  1591.  
  1592. stock CountTickets(playerid)
  1593. {
  1594. new query[80];
  1595. format(query, sizeof(query), "SELECT * FROM `lotto` WHERE `id` = %i", GetPlayerSQLId(playerid));
  1596. mysql_function_query(MainPipeline, query, true, "CountAmount", "i", playerid);
  1597. return 1;
  1598. }
  1599.  
  1600. stock LoadTreasureInventory(playerid)
  1601. {
  1602. new query[175];
  1603. format(query, sizeof(query), "SELECT `junkmetal`, `newcoin`, `oldcoin`, `brokenwatch`, `oldkey`, `treasure`, `goldwatch`, `silvernugget`, `goldnugget` FROM `jobstuff` WHERE `pId` = %d", GetPlayerSQLId(playerid));
  1604. mysql_function_query(MainPipeline, query, true, "LoadTreasureInvent", "i", playerid);
  1605. return 1;
  1606. }
  1607.  
  1608. stock SaveTreasureInventory(playerid)
  1609. {
  1610. new string[220];
  1611. format(string, sizeof(string), "UPDATE `jobstuff` SET `junkmetal` = %d, `newcoin` = %d, `oldcoin` = %d, `brokenwatch` = %d, `oldkey` = %d, \
  1612. `treasure` = %d, `goldwatch` = %d, `silvernugget` = %d, `goldnugget` =%d WHERE `pId` = %d", GetPVarInt(playerid, "junkmetal"), GetPVarInt(playerid, "newcoin"), GetPVarInt(playerid, "oldcoin"),
  1613. GetPVarInt(playerid, "brokenwatch"), GetPVarInt(playerid, "oldkey"), GetPVarInt(playerid, "treasure"), GetPVarInt(playerid, "goldwatch"), GetPVarInt(playerid, "silvernugget"), GetPVarInt(playerid, "goldnugget"), GetPlayerSQLId(playerid));
  1614. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1615. return 1;
  1616. }
  1617.  
  1618. stock SQL_Log(szQuery[], szDesc[] = "none", iExtraID = 0) {
  1619. new i_dateTime[2][3];
  1620. gettime(i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2]);
  1621. getdate(i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2]);
  1622.  
  1623. printf("Dumping query from %i/%i/%i (%i:%i:%i)\r\nDescription: %s (index %i). Query:\r\n", i_dateTime[1][0], i_dateTime[1][1], i_dateTime[1][2], i_dateTime[0][0], i_dateTime[0][1], i_dateTime[0][2], szDesc, iExtraID);
  1624. if(strlen(szQuery) > 1023)
  1625. {
  1626. new sz_print[1024];
  1627. new Float:maxfloat = strlen(szQuery)/1023;
  1628. for(new x;x<=floatround(maxfloat, floatround_ceil);x++)
  1629. {
  1630. strmid(sz_print, szQuery, 0+(x*1023), 1023+(x*1023));
  1631. print(sz_print);
  1632. }
  1633. }
  1634. else
  1635. {
  1636. print(szQuery);
  1637. }
  1638. return 1;
  1639. }
  1640.  
  1641. stock LoadFamilies()
  1642. {
  1643. printf("[LoadFamilies] Loading data from database...");
  1644. mysql_function_query(MainPipeline, "SELECT * FROM `families`", true, "OnLoadFamilies", "");
  1645. }
  1646.  
  1647. stock FamilyMemberCount(famid)
  1648. {
  1649. new query[56];
  1650. format(query, sizeof(query), "SELECT NULL FROM `accounts` WHERE `FMember` = '%d'", famid);
  1651. mysql_function_query(MainPipeline, query, true, "OnFamilyMemberCount", "i", famid);
  1652. return 1;
  1653. }
  1654.  
  1655. stock SaveFamily(id) {
  1656.  
  1657. new string[2048];
  1658.  
  1659. format(string, sizeof(string), "UPDATE `families` SET \
  1660. `Taken`=%d, \
  1661. `Name`='%s', \
  1662. `Leader`='%s', \
  1663. `Bank`=%d, \
  1664. `Cash`=%d, \
  1665. `FamilyUSafe`=%d, \
  1666. `FamilySafeX`=%f, \
  1667. `FamilySafeY`=%f, \
  1668. `FamilySafeZ`=%f, \
  1669. `FamilySafeVW`=%d, \
  1670. `FamilySafeInt`=%d, \
  1671. `Pot`=%d, \
  1672. `Crack`=%d, \
  1673. `Mats`=%d, \
  1674. `Heroin`=%d, \
  1675. `Rank0`='%s', \
  1676. `Rank1`='%s', \
  1677. `Rank2`='%s', \
  1678. `Rank3`='%s', \
  1679. `Rank4`='%s', \
  1680. `Rank5`='%s', \
  1681. `Rank6`='%s', \
  1682. `Division0`='%s', \
  1683. `Division1`='%s', \
  1684. `Division2`='%s', \
  1685. `Division3`='%s', \
  1686. `Division4`='%s', ",
  1687. FamilyInfo[id][FamilyTaken],
  1688. g_mysql_ReturnEscaped(FamilyInfo[id][FamilyName], MainPipeline),
  1689. FamilyInfo[id][FamilyLeader],
  1690. FamilyInfo[id][FamilyBank],
  1691. FamilyInfo[id][FamilyCash],
  1692. FamilyInfo[id][FamilyUSafe],
  1693. FamilyInfo[id][FamilySafe][0],
  1694. FamilyInfo[id][FamilySafe][1],
  1695. FamilyInfo[id][FamilySafe][2],
  1696. FamilyInfo[id][FamilySafeVW],
  1697. FamilyInfo[id][FamilySafeInt],
  1698. FamilyInfo[id][FamilyPot],
  1699. FamilyInfo[id][FamilyCrack],
  1700. FamilyInfo[id][FamilyMats],
  1701. FamilyInfo[id][FamilyHeroin],
  1702. g_mysql_ReturnEscaped(FamilyRankInfo[id][0], MainPipeline),
  1703. g_mysql_ReturnEscaped(FamilyRankInfo[id][1], MainPipeline),
  1704. g_mysql_ReturnEscaped(FamilyRankInfo[id][2], MainPipeline),
  1705. g_mysql_ReturnEscaped(FamilyRankInfo[id][3], MainPipeline),
  1706. g_mysql_ReturnEscaped(FamilyRankInfo[id][4], MainPipeline),
  1707. g_mysql_ReturnEscaped(FamilyRankInfo[id][5], MainPipeline),
  1708. g_mysql_ReturnEscaped(FamilyRankInfo[id][6], MainPipeline),
  1709. g_mysql_ReturnEscaped(FamilyDivisionInfo[id][0], MainPipeline),
  1710. g_mysql_ReturnEscaped(FamilyDivisionInfo[id][1], MainPipeline),
  1711. g_mysql_ReturnEscaped(FamilyDivisionInfo[id][2], MainPipeline),
  1712. g_mysql_ReturnEscaped(FamilyDivisionInfo[id][3], MainPipeline),
  1713. g_mysql_ReturnEscaped(FamilyDivisionInfo[id][4], MainPipeline)
  1714. );
  1715.  
  1716. format(string, sizeof(string), "%s\
  1717. `fontface`='%s', \
  1718. `fontsize`=%d, \
  1719. `bold`=%d, \
  1720. `fontcolor`=%d, \
  1721. `gtUsed`=%d, \
  1722. `text`='%s', ",
  1723. string,
  1724. FamilyInfo[id][gt_FontFace],
  1725. FamilyInfo[id][gt_FontSize],
  1726. FamilyInfo[id][gt_Bold],
  1727. FamilyInfo[id][gt_FontColor],
  1728. FamilyInfo[id][gt_SPUsed],
  1729. g_mysql_ReturnEscaped(FamilyInfo[id][gt_Text], MainPipeline)
  1730. );
  1731.  
  1732. format(string, sizeof(string), "%s \
  1733. `MaxSkins`=%d, \
  1734. `Skin1`=%d, \
  1735. `Skin2`=%d, \
  1736. `Skin3`=%d, \
  1737. `Skin4`=%d, \
  1738. `Skin5`=%d, \
  1739. `Skin6`=%d, \
  1740. `Skin7`=%d, \
  1741. `Skin8`=%d, \
  1742. `Color`=%d, \
  1743. `TurfTokens`=%d, \
  1744. `Gun1`=%d, \
  1745. `Gun2`=%d, \
  1746. `Gun3`=%d, \
  1747. `Gun4`=%d, \
  1748. `Gun5`=%d, \
  1749. `Gun6`=%d, \
  1750. `Gun7`=%d, \
  1751. `Gun8`=%d, \
  1752. `Gun9`=%d, \
  1753. `Gun10`=%d, \
  1754. `GtObject`=%d, \
  1755. `MOTD1`='%s', \
  1756. `MOTD2`='%s', \
  1757. `MOTD3`='%s' \
  1758. WHERE `ID` = %d",
  1759. string,
  1760. FamilyInfo[id][FamilyMaxSkins],
  1761. FamilyInfo[id][gtObject],
  1762. g_mysql_ReturnEscaped(FamilyMOTD[id][0], MainPipeline),
  1763. g_mysql_ReturnEscaped(FamilyMOTD[id][1], MainPipeline),
  1764. g_mysql_ReturnEscaped(FamilyMOTD[id][2], MainPipeline),
  1765. id
  1766. );
  1767.  
  1768. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1769.  
  1770. return 1;
  1771. }
  1772.  
  1773. stock SaveFamiliesHQ(id)
  1774. {
  1775. if(!( 1 <= id < MAX_FAMILY))
  1776. return 0;
  1777.  
  1778. new query[300];
  1779. format(query, sizeof(query), "UPDATE `families` SET `ExteriorX` = %f, `ExteriorY` = %f, `ExteriorZ` = %f, `ExteriorA` = %f, `InteriorX` = %f, `InteriorY` = %f, `InteriorZ` = %f, `InteriorA` = %f, \
  1780. `INT` = %d, `VW` = %d, `CustomInterior` = %d WHERE ID = %d", FamilyInfo[id][FamilyEntrance][0], FamilyInfo[id][FamilyEntrance][1], FamilyInfo[id][FamilyEntrance][2], FamilyInfo[id][FamilyEntrance][3],
  1781. FamilyInfo[id][FamilyExit][0], FamilyInfo[id][FamilyExit][1], FamilyInfo[id][FamilyExit][2], FamilyInfo[id][FamilyExit][3], FamilyInfo[id][FamilyInterior], FamilyInfo[id][FamilyVirtualWorld],
  1782. FamilyInfo[id][FamilyCustomMap], id);
  1783. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  1784. return 1;
  1785. }
  1786.  
  1787. stock LoadGates()
  1788. {
  1789. printf("[LoadGates] Loading data from database...");
  1790. mysql_function_query(MainPipeline, "SELECT * FROM `gates`", true, "OnLoadGates", "");
  1791. }
  1792.  
  1793. stock SaveDynamicMapIcon(mapiconid)
  1794. {
  1795. new string[512];
  1796.  
  1797. format(string, sizeof(string), "UPDATE `dmapicons` SET \
  1798. `MarkerType`=%d, \
  1799. `Color`=%d, \
  1800. `VW`=%d, \
  1801. `Int`=%d, \
  1802. `PosX`=%f, \
  1803. `PosY`=%f, \
  1804. `PosZ`=%f WHERE `id`=%d",
  1805. DMPInfo[mapiconid][dmpMarkerType],
  1806. DMPInfo[mapiconid][dmpColor],
  1807. DMPInfo[mapiconid][dmpVW],
  1808. DMPInfo[mapiconid][dmpInt],
  1809. DMPInfo[mapiconid][dmpPosX],
  1810. DMPInfo[mapiconid][dmpPosY],
  1811. DMPInfo[mapiconid][dmpPosZ],
  1812. mapiconid
  1813. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  1814.  
  1815. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1816. }
  1817.  
  1818. stock LoadDynamicMapIcon(mapiconid)
  1819. {
  1820. new string[128];
  1821. format(string, sizeof(string), "SELECT * FROM `dmapicons` WHERE `id`=%d", mapiconid);
  1822. mysql_function_query(MainPipeline, string, true, "OnLoadDynamicMapIcon", "i", mapiconid);
  1823. }
  1824.  
  1825. stock LoadDynamicMapIcons()
  1826. {
  1827. printf("[LoadDynamicMapIcons] Loading data from database...");
  1828. mysql_function_query(MainPipeline, "SELECT * FROM `dmapicons`", true, "OnLoadDynamicMapIcons", "");
  1829. }
  1830.  
  1831. stock SaveDynamicDoor(doorid)
  1832. {
  1833. new string[1024];
  1834. format(string, sizeof(string), "UPDATE `ddoors` SET \
  1835. `Description`='%s', \
  1836. `Owner`=%d, \
  1837. `OwnerName`='%s', \
  1838. `CustomInterior`=%d, \
  1839. `ExteriorVW`=%d, \
  1840. `ExteriorInt`=%d, \
  1841. `InteriorVW`=%d, \
  1842. `InteriorInt`=%d, \
  1843. `ExteriorX`=%f, \
  1844. `ExteriorY`=%f, \
  1845. `ExteriorZ`=%f, \
  1846. `ExteriorA`=%f, \
  1847. `InteriorX`=%f, \
  1848. `InteriorY`=%f, \
  1849. `InteriorZ`=%f, \
  1850. `InteriorA`=%f,",
  1851. g_mysql_ReturnEscaped(DDoorsInfo[doorid][ddDescription], MainPipeline),
  1852. DDoorsInfo[doorid][ddOwner],
  1853. g_mysql_ReturnEscaped(DDoorsInfo[doorid][ddOwnerName], MainPipeline),
  1854. DDoorsInfo[doorid][ddCustomInterior],
  1855. DDoorsInfo[doorid][ddExteriorVW],
  1856. DDoorsInfo[doorid][ddExteriorInt],
  1857. DDoorsInfo[doorid][ddInteriorVW],
  1858. DDoorsInfo[doorid][ddInteriorInt],
  1859. DDoorsInfo[doorid][ddExteriorX],
  1860. DDoorsInfo[doorid][ddExteriorY],
  1861. DDoorsInfo[doorid][ddExteriorZ],
  1862. DDoorsInfo[doorid][ddExteriorA],
  1863. DDoorsInfo[doorid][ddInteriorX],
  1864. DDoorsInfo[doorid][ddInteriorY],
  1865. DDoorsInfo[doorid][ddInteriorZ],
  1866. DDoorsInfo[doorid][ddInteriorA]
  1867. );
  1868.  
  1869. format(string, sizeof(string), "%s \
  1870. `CustomExterior`=%d, \
  1871. `Type`=%d, \
  1872. `Rank`=%d, \
  1873. `VIP`=%d, \
  1874. `Famed`=%d, \
  1875. `DPC`=%d, \
  1876. `Allegiance`=%d, \
  1877. `GroupType`=%d, \
  1878. `Family`=%d, \
  1879. `Faction`=%d, \
  1880. `Admin`=%d, \
  1881. `Wanted`=%d, \
  1882. `VehicleAble`=%d, \
  1883. `Color`=%d, \
  1884. `PickupModel`=%d, \
  1885. `Pass`='%s', \
  1886. `Locked`=%d WHERE `id`=%d",
  1887. string,
  1888. DDoorsInfo[doorid][ddCustomExterior],
  1889. DDoorsInfo[doorid][ddType],
  1890. DDoorsInfo[doorid][ddRank],
  1891. DDoorsInfo[doorid][ddVIP],
  1892. DDoorsInfo[doorid][ddFamed],
  1893. DDoorsInfo[doorid][ddDPC],
  1894. DDoorsInfo[doorid][ddAllegiance],
  1895. DDoorsInfo[doorid][ddGroupType],
  1896. DDoorsInfo[doorid][ddFamily],
  1897. DDoorsInfo[doorid][ddFaction],
  1898. DDoorsInfo[doorid][ddAdmin],
  1899. DDoorsInfo[doorid][ddWanted],
  1900. DDoorsInfo[doorid][ddVehicleAble],
  1901. DDoorsInfo[doorid][ddColor],
  1902. DDoorsInfo[doorid][ddPickupModel],
  1903. g_mysql_ReturnEscaped(DDoorsInfo[doorid][ddPass], MainPipeline),
  1904. DDoorsInfo[doorid][ddLocked],
  1905. doorid+1
  1906. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  1907.  
  1908. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  1909. }
  1910.  
  1911. stock LoadDynamicDoor(doorid)
  1912. {
  1913. new string[128];
  1914. format(string, sizeof(string), "SELECT * FROM `ddoors` WHERE `id`=%d", doorid+1); // Array starts at zero, MySQL starts at 1.
  1915. mysql_function_query(MainPipeline, string, true, "OnLoadDynamicDoor", "i", doorid);
  1916. }
  1917.  
  1918. stock LoadDynamicDoors()
  1919. {
  1920. printf("[LoadDynamicDoors] Loading data from database...");
  1921. mysql_function_query(MainPipeline, "SELECT * FROM `ddoors`", true, "OnLoadDynamicDoors", "");
  1922. }
  1923.  
  1924. stock SaveHouse(houseid)
  1925. {
  1926. new string[2048];
  1927. printf("Saving House ID %d", houseid);
  1928. format(string, sizeof(string), "UPDATE `houses` SET \
  1929. `Owned`=%d, \
  1930. `Level`=%d, \
  1931. `Description`='%s', \
  1932. `OwnerID`=%d, \
  1933. `ExteriorX`=%f, \
  1934. `ExteriorY`=%f, \
  1935. `ExteriorZ`=%f, \
  1936. `ExteriorR`=%f, \
  1937. `InteriorX`=%f, \
  1938. `InteriorY`=%f, \
  1939. `InteriorZ`=%f, \
  1940. `InteriorR`=%f, \
  1941. `ExtIW`=%d, \
  1942. `ExtVW`=%d, \
  1943. `IntIW`=%d, \
  1944. `IntVW`=%d,",
  1945. HouseInfo[houseid][hOwned],
  1946. HouseInfo[houseid][hLevel],
  1947. g_mysql_ReturnEscaped(HouseInfo[houseid][hDescription], MainPipeline),
  1948. HouseInfo[houseid][hOwnerID],
  1949. HouseInfo[houseid][hExteriorX],
  1950. HouseInfo[houseid][hExteriorY],
  1951. HouseInfo[houseid][hExteriorZ],
  1952. HouseInfo[houseid][hExteriorR],
  1953. HouseInfo[houseid][hInteriorX],
  1954. HouseInfo[houseid][hInteriorY],
  1955. HouseInfo[houseid][hInteriorZ],
  1956. HouseInfo[houseid][hInteriorR],
  1957. HouseInfo[houseid][hExtIW],
  1958. HouseInfo[houseid][hExtVW],
  1959. HouseInfo[houseid][hIntIW],
  1960. HouseInfo[houseid][hIntVW]
  1961. );
  1962.  
  1963. format(string, sizeof(string), "%s \
  1964. `Lock`=%d, \
  1965. `Rentable`=%d, \
  1966. `RentFee`=%d, \
  1967. `Value`=%d, \
  1968. `SafeMoney`=%d, \
  1969. `Pot`=%d, \
  1970. `Crack`=%d, \
  1971. `Materials`=%d, \
  1972. `Heroin`=%d, \
  1973. `Weapons0`=%d, \
  1974. `Weapons1`=%d, \
  1975. `Weapons2`=%d, \
  1976. `Weapons3`=%d, \
  1977. `Weapons4`=%d, \
  1978. `GLUpgrade`=%d, \
  1979. `CustomInterior`=%d, \
  1980. `CustomExterior`=%d, \
  1981. `ExteriorA`=%f, \
  1982. `InteriorA`=%f, \
  1983. `MailX`=%f, \
  1984. `MailY`=%f, \
  1985. `MailZ`=%f, \
  1986. `MailA`=%f, \
  1987. `MailType`=%d, \
  1988. `ClosetX`=%f, \
  1989. `ClosetY`=%f, \
  1990. `ClosetZ`=%f WHERE `id`=%d",
  1991. string,
  1992. HouseInfo[houseid][hLock],
  1993. HouseInfo[houseid][hRentable],
  1994. HouseInfo[houseid][hRentFee],
  1995. HouseInfo[houseid][hValue],
  1996. HouseInfo[houseid][hSafeMoney],
  1997. HouseInfo[houseid][hPot],
  1998. HouseInfo[houseid][hCrack],
  1999. HouseInfo[houseid][hMaterials],
  2000. HouseInfo[houseid][hHeroin],
  2001. HouseInfo[houseid][hWeapons][0],
  2002. HouseInfo[houseid][hWeapons][1],
  2003. HouseInfo[houseid][hWeapons][2],
  2004. HouseInfo[houseid][hWeapons][3],
  2005. HouseInfo[houseid][hWeapons][4],
  2006. HouseInfo[houseid][hGLUpgrade],
  2007. HouseInfo[houseid][hCustomInterior],
  2008. HouseInfo[houseid][hCustomExterior],
  2009. HouseInfo[houseid][hExteriorA],
  2010. HouseInfo[houseid][hInteriorA],
  2011. HouseInfo[houseid][hMailX],
  2012. HouseInfo[houseid][hMailY],
  2013. HouseInfo[houseid][hMailZ],
  2014. HouseInfo[houseid][hMailA],
  2015. HouseInfo[houseid][hMailType],
  2016. HouseInfo[houseid][hClosetX],
  2017. HouseInfo[houseid][hClosetY],
  2018. HouseInfo[houseid][hClosetZ],
  2019. houseid+1
  2020. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  2021.  
  2022. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2023. }
  2024.  
  2025. stock LoadHouse(houseid)
  2026. {
  2027. new string[128];
  2028. printf("[LoadHouse] Loading HouseID %d's data from database...", houseid);
  2029. format(string, sizeof(string), "SELECT OwnerName.Username, h.* FROM houses h LEFT JOIN accounts OwnerName ON h.OwnerID = OwnerName.id WHERE `id` = %d", houseid+1); // Array starts at zero, MySQL starts at one.
  2030. mysql_function_query(MainPipeline, string, true, "OnLoadHouse", "i", houseid);
  2031. }
  2032.  
  2033. stock LoadHouses()
  2034. {
  2035. printf("[LoadHouses] Loading data from database...");
  2036. mysql_function_query(MainPipeline, "SELECT OwnerName.Username, h.* FROM houses h LEFT JOIN accounts OwnerName ON h.OwnerID = OwnerName.id", true, "OnLoadHouses", "");
  2037. }
  2038.  
  2039. stock LoadMailboxes()
  2040. {
  2041. printf("[LoadMailboxes] Loading data from database...");
  2042. mysql_function_query(MainPipeline, "SELECT * FROM `mailboxes`", true, "OnLoadMailboxes", "");
  2043. }
  2044.  
  2045. stock LoadPoints()
  2046. {
  2047. printf("[LoadFamilyPoints] Loading Family Points from the database, please wait...");
  2048. mysql_function_query(MainPipeline, "SELECT * FROM `points`", true, "OnLoadPoints", "");
  2049. }
  2050.  
  2051. stock LoadHGBackpacks()
  2052. {
  2053. printf("[Loading Hunger Games] Loading Hunger Games Backpacks from the database, please wait...");
  2054. mysql_function_query(MainPipeline, "SELECT * FROM `hgbackpacks`", true, "OnLoadHGBackpacks", "");
  2055. }
  2056.  
  2057. stock SaveMailbox(id)
  2058. {
  2059. new string[512];
  2060.  
  2061. format(string, sizeof(string), "UPDATE `mailboxes` SET \
  2062. `VW`=%d, \
  2063. `Int`=%d, \
  2064. `Model`=%d, \
  2065. `PosX`=%f, \
  2066. `PosY`=%f, \
  2067. `PosZ`=%f, \
  2068. `Angle`=%f WHERE `id`=%d",
  2069. MailBoxes[id][mbVW],
  2070. MailBoxes[id][mbInt],
  2071. MailBoxes[id][mbModel],
  2072. MailBoxes[id][mbPosX],
  2073. MailBoxes[id][mbPosY],
  2074. MailBoxes[id][mbPosZ],
  2075. MailBoxes[id][mbAngle],
  2076. id+1
  2077. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  2078.  
  2079. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2080. }
  2081.  
  2082. stock SaveSpeedCamera(i)
  2083. {
  2084. if (SpeedCameras[i][_scActive] != true)
  2085. return;
  2086.  
  2087. new query[1024];
  2088. format(query, sizeof(query), "UPDATE speed_cameras SET pos_x=%f, pos_y=%f, pos_z=%f, rotation=%f, `range`=%f, speed_limit=%f WHERE id=%i",
  2089. SpeedCameras[i][_scPosX], SpeedCameras[i][_scPosY], SpeedCameras[i][_scPosZ], SpeedCameras[i][_scRotation], SpeedCameras[i][_scRange], SpeedCameras[i][_scLimit],
  2090. SpeedCameras[i][_scDatabase]);
  2091.  
  2092. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2093. }
  2094.  
  2095. stock LoadSpeedCameras()
  2096. {
  2097. printf("[SpeedCameras] Loading data from database...");
  2098. mysql_function_query(MainPipeline, "SELECT * FROM speed_cameras", true, "OnLoadSpeedCameras", "");
  2099.  
  2100. return 1;
  2101. }
  2102.  
  2103. stock StoreNewSpeedCameraInMySQL(index)
  2104. {
  2105. new string[512];
  2106. format(string, sizeof(string), "INSERT INTO speed_cameras (pos_x, pos_y, pos_z, rotation, `range`, speed_limit) VALUES (%f, %f, %f, %f, %f, %f)",
  2107. SpeedCameras[index][_scPosX], SpeedCameras[index][_scPosY], SpeedCameras[index][_scPosZ], SpeedCameras[index][_scRotation], SpeedCameras[index][_scRange], SpeedCameras[index][_scLimit]);
  2108.  
  2109. mysql_function_query(MainPipeline, string, true, "OnNewSpeedCamera", "i", index);
  2110. return 1;
  2111. }
  2112.  
  2113. stock SaveTxtLabel(labelid)
  2114. {
  2115. new string[1024];
  2116. format(string, sizeof(string), "UPDATE `text_labels` SET \
  2117. `Text`='%s', \
  2118. `PosX`=%f, \
  2119. `PosY`=%f, \
  2120. `PosZ`=%f, \
  2121. `VW`=%d, \
  2122. `Int`=%d, \
  2123. `Color`=%d, \
  2124. `PickupModel`=%d WHERE `id`=%d",
  2125. g_mysql_ReturnEscaped(TxtLabels[labelid][tlText], MainPipeline),
  2126. TxtLabels[labelid][tlPosX],
  2127. TxtLabels[labelid][tlPosY],
  2128. TxtLabels[labelid][tlPosZ],
  2129. TxtLabels[labelid][tlVW],
  2130. TxtLabels[labelid][tlInt],
  2131. TxtLabels[labelid][tlColor],
  2132. TxtLabels[labelid][tlPickupModel],
  2133. labelid+1
  2134. ); // Array starts from zero, MySQL starts at 1 (this is why we are adding one).
  2135.  
  2136. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2137. }
  2138.  
  2139. stock LoadTxtLabel(labelid)
  2140. {
  2141. new string[128];
  2142. format(string, sizeof(string), "SELECT * FROM `text_labels` WHERE `id`=%d", labelid+1); // Array starts at zero, MySQL starts at 1.
  2143. mysql_function_query(MainPipeline, string, true, "OnLoadTxtLabel", "i", labelid);
  2144. }
  2145.  
  2146. stock LoadTxtLabels()
  2147. {
  2148. printf("[LoadTxtLabels] Loading data from database...");
  2149. mysql_function_query(MainPipeline, "SELECT * FROM `text_labels`", true, "OnLoadTxtLabels", "");
  2150. }
  2151.  
  2152. stock SavePayNSpray(id)
  2153. {
  2154. new string[1024];
  2155. format(string, sizeof(string), "UPDATE `paynsprays` SET \
  2156. `Status`=%d, \
  2157. `PosX`=%f, \
  2158. `PosY`=%f, \
  2159. `PosZ`=%f, \
  2160. `VW`=%d, \
  2161. `Int`=%d, \
  2162. `GroupCost`=%d, \
  2163. `RegCost`=%d WHERE `id`=%d",
  2164. PayNSprays[id][pnsStatus],
  2165. PayNSprays[id][pnsPosX],
  2166. PayNSprays[id][pnsPosY],
  2167. PayNSprays[id][pnsPosZ],
  2168. PayNSprays[id][pnsVW],
  2169. PayNSprays[id][pnsInt],
  2170. PayNSprays[id][pnsGroupCost],
  2171. PayNSprays[id][pnsRegCost],
  2172. id
  2173. );
  2174.  
  2175. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2176. }
  2177.  
  2178. stock SavePayNSprays()
  2179. {
  2180. for(new i = 0; i < MAX_PAYNSPRAYS; i++)
  2181. {
  2182. SavePayNSpray(i);
  2183. }
  2184. return 1;
  2185. }
  2186.  
  2187. stock RehashPayNSpray(id)
  2188. {
  2189. DestroyDynamicPickup(PayNSprays[id][pnsPickupID]);
  2190. DestroyDynamic3DTextLabel(PayNSprays[id][pnsTextID]);
  2191. DestroyDynamicMapIcon(PayNSprays[id][pnsMapIconID]);
  2192. PayNSprays[id][pnsSQLId] = -1;
  2193. PayNSprays[id][pnsStatus] = 0;
  2194. PayNSprays[id][pnsPosX] = 0.0;
  2195. PayNSprays[id][pnsPosY] = 0.0;
  2196. PayNSprays[id][pnsPosZ] = 0.0;
  2197. PayNSprays[id][pnsVW] = 0;
  2198. PayNSprays[id][pnsInt] = 0;
  2199. PayNSprays[id][pnsGroupCost] = 0;
  2200. PayNSprays[id][pnsRegCost] = 0;
  2201. LoadPayNSpray(id);
  2202. }
  2203.  
  2204. stock RehashPayNSprays()
  2205. {
  2206. printf("[RehashPayNSprays] Deleting Pay N' Sprays from server...");
  2207. for(new i = 0; i < MAX_PAYNSPRAYS; i++)
  2208. {
  2209. RehashPayNSpray(i);
  2210. }
  2211. LoadPayNSprays();
  2212. }
  2213.  
  2214. stock LoadPayNSpray(id)
  2215. {
  2216. new string[128];
  2217. format(string, sizeof(string), "SELECT * FROM `paynsprays` WHERE `id`=%d", id);
  2218. mysql_function_query(MainPipeline, string, true, "OnLoadPayNSprays", "i", id);
  2219. }
  2220.  
  2221. stock IsAdminSpawnedVehicle(vehicleid)
  2222. {
  2223. for(new i = 0; i < sizeof(CreatedCars); ++i) {
  2224. if(CreatedCars[i] == vehicleid) return 1;
  2225. }
  2226. return 0;
  2227. }
  2228.  
  2229. forward OnLoadPayNSpray(index);
  2230. public OnLoadPayNSpray(index)
  2231. {
  2232. new rows, fields, tmp[128], string[128];
  2233. cache_get_data(rows, fields, MainPipeline);
  2234.  
  2235. for(new row; row < rows; row++)
  2236. {
  2237. cache_get_field_content(row, "id", tmp, MainPipeline); PayNSprays[index][pnsSQLId] = strval(tmp);
  2238. cache_get_field_content(row, "Status", tmp, MainPipeline); PayNSprays[index][pnsStatus] = strval(tmp);
  2239. cache_get_field_content(row, "PosX", tmp, MainPipeline); PayNSprays[index][pnsPosX] = floatstr(tmp);
  2240. cache_get_field_content(row, "PosY", tmp, MainPipeline); PayNSprays[index][pnsPosY] = floatstr(tmp);
  2241. cache_get_field_content(row, "PosZ", tmp, MainPipeline); PayNSprays[index][pnsPosZ] = floatstr(tmp);
  2242. cache_get_field_content(row, "VW", tmp, MainPipeline); PayNSprays[index][pnsVW] = strval(tmp);
  2243. cache_get_field_content(row, "Int", tmp, MainPipeline); PayNSprays[index][pnsInt] = strval(tmp);
  2244. cache_get_field_content(row, "GroupCost", tmp, MainPipeline); PayNSprays[index][pnsGroupCost] = strval(tmp);
  2245. cache_get_field_content(row, "RegCost", tmp, MainPipeline); PayNSprays[index][pnsRegCost] = strval(tmp);
  2246. if(PayNSprays[index][pnsStatus] > 0)
  2247. {
  2248. format(string, sizeof(string), "/repaircar\nRepair Cost -- Regular: $%s | Faction: $%s\nID: %d", number_format(PayNSprays[index][pnsRegCost]), number_format(PayNSprays[index][pnsGroupCost]), index);
  2249. PayNSprays[index][pnsTextID] = CreateDynamic3DTextLabel(string, COLOR_RED, PayNSprays[index][pnsPosX], PayNSprays[index][pnsPosY], PayNSprays[index][pnsPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, PayNSprays[index][pnsVW], PayNSprays[index][pnsInt], -1);
  2250. PayNSprays[index][pnsPickupID] = CreateDynamicPickup(1239, 23, PayNSprays[index][pnsPosX], PayNSprays[index][pnsPosY], PayNSprays[index][pnsPosZ], PayNSprays[index][pnsVW]);
  2251. PayNSprays[index][pnsMapIconID] = CreateDynamicMapIcon(PayNSprays[index][pnsPosX], PayNSprays[index][pnsPosY], PayNSprays[index][pnsPosZ], 63, 0, PayNSprays[index][pnsVW], PayNSprays[index][pnsInt], -1, 500.0);
  2252. }
  2253. }
  2254. return 1;
  2255. }
  2256.  
  2257. stock LoadPayNSprays()
  2258. {
  2259. printf("[LoadPayNSprays] Loading data from database...");
  2260. mysql_function_query(MainPipeline, "SELECT * FROM `paynsprays`", true, "OnLoadPayNSprays", "");
  2261. }
  2262.  
  2263. stock SaveArrestPoint(id)
  2264. {
  2265. new string[1024];
  2266. format(string, sizeof(string), "UPDATE `arrestpoints` SET \
  2267. `PosX`=%f, \
  2268. `PosY`=%f, \
  2269. `PosZ`=%f, \
  2270. `VW`=%d, \
  2271. `Int`=%d, \
  2272. `Type`=%d WHERE `id`=%d",
  2273. ArrestPoints[id][arrestPosX],
  2274. ArrestPoints[id][arrestPosY],
  2275. ArrestPoints[id][arrestPosZ],
  2276. ArrestPoints[id][arrestVW],
  2277. ArrestPoints[id][arrestInt],
  2278. ArrestPoints[id][arrestType],
  2279. id
  2280. );
  2281.  
  2282. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2283. }
  2284.  
  2285. stock SaveArrestPoints()
  2286. {
  2287. for(new i = 0; i < MAX_ARRESTPOINTS; i++)
  2288. {
  2289. SaveArrestPoint(i);
  2290. }
  2291. return 1;
  2292. }
  2293.  
  2294. stock RehashArrestPoint(id)
  2295. {
  2296. DestroyDynamic3DTextLabel(ArrestPoints[id][arrestTextID]);
  2297. DestroyDynamicPickup(ArrestPoints[id][arrestPickupID]);
  2298. ArrestPoints[id][arrestSQLId] = -1;
  2299. ArrestPoints[id][arrestPosX] = 0.0;
  2300. ArrestPoints[id][arrestPosY] = 0.0;
  2301. ArrestPoints[id][arrestPosZ] = 0.0;
  2302. ArrestPoints[id][arrestVW] = 0;
  2303. ArrestPoints[id][arrestInt] = 0;
  2304. ArrestPoints[id][arrestType] = 0;
  2305. LoadArrestPoint(id);
  2306. }
  2307.  
  2308. stock RehashArrestPoints()
  2309. {
  2310. printf("[RehashArrestPoints] Deleting Arrest Points from server...");
  2311. for(new i = 0; i < MAX_ARRESTPOINTS; i++)
  2312. {
  2313. RehashArrestPoint(i);
  2314. }
  2315. LoadArrestPoints();
  2316. }
  2317.  
  2318. stock LoadArrestPoint(id)
  2319. {
  2320. new string[128];
  2321. format(string, sizeof(string), "SELECT * FROM `arrestpoints` WHERE `id`=%d", id);
  2322. mysql_function_query(MainPipeline, string, true, "OnLoadArrestPoints", "i", id);
  2323. }
  2324.  
  2325. stock LoadArrestPoints()
  2326. {
  2327. printf("[LoadArrestPoints] Loading data from database...");
  2328. mysql_function_query(MainPipeline, "SELECT * FROM `arrestpoints`", true, "OnLoadArrestPoints", "");
  2329. }
  2330.  
  2331. stock SaveImpoundPoint(id)
  2332. {
  2333. new string[1024];
  2334. format(string, sizeof(string), "UPDATE `impoundpoints` SET \
  2335. `PosX`=%f, \
  2336. `PosY`=%f, \
  2337. `PosZ`=%f, \
  2338. `VW`=%d, \
  2339. `Int`=%d WHERE `id`=%d",
  2340. ImpoundPoints[id][impoundPosX],
  2341. ImpoundPoints[id][impoundPosY],
  2342. ImpoundPoints[id][impoundPosZ],
  2343. ImpoundPoints[id][impoundVW],
  2344. ImpoundPoints[id][impoundInt],
  2345. id
  2346. );
  2347.  
  2348. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2349. }
  2350.  
  2351. stock SaveImpoundPoints()
  2352. {
  2353. for(new i = 0; i < MAX_ImpoundPoints; i++)
  2354. {
  2355. SaveImpoundPoint(i);
  2356. }
  2357. return 1;
  2358. }
  2359.  
  2360. stock RehashImpoundPoint(id)
  2361. {
  2362. DestroyDynamic3DTextLabel(ImpoundPoints[id][impoundTextID]);
  2363. ImpoundPoints[id][impoundSQLId] = -1;
  2364. ImpoundPoints[id][impoundPosX] = 0.0;
  2365. ImpoundPoints[id][impoundPosY] = 0.0;
  2366. ImpoundPoints[id][impoundPosZ] = 0.0;
  2367. ImpoundPoints[id][impoundVW] = 0;
  2368. ImpoundPoints[id][impoundInt] = 0;
  2369. LoadImpoundPoint(id);
  2370. }
  2371.  
  2372. stock RehashImpoundPoints()
  2373. {
  2374. printf("[RehashImpoundPoints] Deleting impound Points from server...");
  2375. for(new i = 0; i < MAX_ImpoundPoints; i++)
  2376. {
  2377. RehashImpoundPoint(i);
  2378. }
  2379. LoadImpoundPoints();
  2380. }
  2381.  
  2382. stock LoadImpoundPoint(id)
  2383. {
  2384. new string[128];
  2385. format(string, sizeof(string), "SELECT * FROM `impoundpoints` WHERE `id`=%d", id);
  2386. mysql_function_query(MainPipeline, string, true, "OnLoadImpoundPoints", "i", id);
  2387. }
  2388.  
  2389. stock LoadImpoundPoints()
  2390. {
  2391. printf("[LoadImpoundPoints] Loading data from database...");
  2392. mysql_function_query(MainPipeline, "SELECT * FROM `impoundpoints`", true, "OnLoadImpoundPoints", "");
  2393. }
  2394.  
  2395. // credits to Luk0r
  2396. stock MySQLUpdateBuild(query[], sqlplayerid)
  2397. {
  2398. new querylen = strlen(query);
  2399. if (!query[0]) {
  2400. format(query, 2048, "UPDATE `accounts` SET ");
  2401. }
  2402. else if (2048-querylen < 200)
  2403. {
  2404. new whereclause[32];
  2405. format(whereclause, sizeof(whereclause), " WHERE `id`=%d", sqlplayerid);
  2406. strcat(query, whereclause, 2048);
  2407. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2408. format(query, 2048, "UPDATE `accounts` SET ");
  2409. }
  2410. else if (strfind(query, "=", true) != -1) strcat(query, ",", 2048);
  2411. return 1;
  2412. }
  2413.  
  2414. stock MySQLUpdateFinish(query[], sqlplayerid)
  2415. {
  2416. if (strcmp(query, "WHERE id=", false) == 0) mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2417. else
  2418. {
  2419. new whereclause[32];
  2420. format(whereclause, sizeof(whereclause), " WHERE id=%d", sqlplayerid);
  2421. strcat(query, whereclause, 2048);
  2422. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2423. format(query, 2048, "UPDATE `accounts` SET ");
  2424. }
  2425. return 1;
  2426. }
  2427.  
  2428. stock SavePlayerInteger(query[], sqlid, Value[], Integer)
  2429. {
  2430. MySQLUpdateBuild(query, sqlid);
  2431. new updval[64];
  2432. format(updval, sizeof(updval), "`%s`=%d", Value, Integer);
  2433. strcat(query, updval, 2048);
  2434. return 1;
  2435. }
  2436.  
  2437.  
  2438. stock SavePlayerString(query[], sqlid, Value[], String[])
  2439. {
  2440. MySQLUpdateBuild(query, sqlid);
  2441. new escapedstring[160], string[160];
  2442. mysql_real_escape_string(String, escapedstring);
  2443. format(string, sizeof(string), "`%s`='%s'", Value, escapedstring);
  2444. strcat(query, string, 2048);
  2445. return 1;
  2446. }
  2447.  
  2448. stock SavePlayerFloat(query[], sqlid, Value[], Float:Number)
  2449. {
  2450. new flotostr[32];
  2451. format(flotostr, sizeof(flotostr), "%0.2f", Number);
  2452. SavePlayerString(query, sqlid, Value, flotostr);
  2453. return 1;
  2454. }
  2455.  
  2456. stock g_mysql_SaveAccount(playerid)
  2457. {
  2458. new query[2048];
  2459.  
  2460. format(query, 2048, "UPDATE `accounts` SET `SPos_x` = '%0.2f', `SPos_y` = '%0.2f', `SPos_z` = '%0.2f', `SPos_r` = '%0.2f' WHERE id = '%d'",PlayerInfo[playerid][pPos_x], PlayerInfo[playerid][pPos_y], PlayerInfo[playerid][pPos_z], PlayerInfo[playerid][pPos_r], GetPlayerSQLId(playerid));
  2461. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2462.  
  2463. format(query, 2048, "UPDATE `accounts` SET ");
  2464. SavePlayerString(query, GetPlayerSQLId(playerid), "IP", PlayerInfo[playerid][pIP]);
  2465. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Registered", PlayerInfo[playerid][pReg]);
  2466. SavePlayerInteger(query, GetPlayerSQLId(playerid), "ConnectedTime", PlayerInfo[playerid][pConnectHours]);
  2467. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Sex", PlayerInfo[playerid][pSex]);
  2468. SavePlayerString(query, GetPlayerSQLId(playerid), "BirthDate", PlayerInfo[playerid][pBirthDate]);
  2469. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Band", PlayerInfo[playerid][pBanned]);
  2470. SavePlayerInteger(query, GetPlayerSQLId(playerid), "PermBand", PlayerInfo[playerid][pPermaBanned]);
  2471. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Warnings", PlayerInfo[playerid][pWarns]);
  2472. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Disabled", PlayerInfo[playerid][pDisabled]);
  2473. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Level", PlayerInfo[playerid][pLevel]);
  2474. SavePlayerInteger(query, GetPlayerSQLId(playerid), "AdminLevel", PlayerInfo[playerid][pAdmin]);
  2475. SavePlayerInteger(query, GetPlayerSQLId(playerid), "SeniorModerator", PlayerInfo[playerid][pSMod]);
  2476. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Helper", PlayerInfo[playerid][pHelper]);
  2477. SavePlayerInteger(query, GetPlayerSQLId(playerid), "DonateRank", PlayerInfo[playerid][pDonateRank]);
  2478. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Respect", PlayerInfo[playerid][pExp]);
  2479. SavePlayerInteger(query, GetPlayerSQLId(playerid), "XP", PlayerInfo[playerid][pXP]);
  2480. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Money", GetPlayerCash(playerid));
  2481.  
  2482. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Bank", PlayerInfo[playerid][pAccount]);
  2483. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Job2", PlayerInfo[playerid][pJob2]);
  2484.  
  2485. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Checks", PlayerInfo[playerid][pChecks]);
  2486. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Bombs", PlayerInfo[playerid][pBombs]);
  2487. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Wins", PlayerInfo[playerid][pWins]);
  2488.  
  2489. SavePlayerInteger(query, GetPlayerSQLId(playerid), "911Muted", PlayerInfo[playerid][p911Muted]);
  2490. SavePlayerInteger(query, GetPlayerSQLId(playerid), "NewMuted", PlayerInfo[playerid][pNMute]);
  2491. SavePlayerInteger(query, GetPlayerSQLId(playerid), "NewMutedTotal", PlayerInfo[playerid][pNMuteTotal]);
  2492. SavePlayerInteger(query, GetPlayerSQLId(playerid), "AdMuted", PlayerInfo[playerid][pADMute]);
  2493. SavePlayerInteger(query, GetPlayerSQLId(playerid), "AdMutedTotal", PlayerInfo[playerid][pADMuteTotal]);
  2494.  
  2495. SavePlayerInteger(query, GetPlayerSQLId(playerid), "CSFBanned", PlayerInfo[playerid][pCSFBanned]);
  2496. SavePlayerInteger(query, GetPlayerSQLId(playerid), "VIPInviteDay", PlayerInfo[playerid][pVIPInviteDay]);
  2497.  
  2498. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Wristwatch", PlayerInfo[playerid][pWristwatch]);
  2499. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Surveillance", PlayerInfo[playerid][pSurveillance]);
  2500. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Tire", PlayerInfo[playerid][pTire]);
  2501. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Firstaid", PlayerInfo[playerid][pFirstaid]);
  2502. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Rccam", PlayerInfo[playerid][pRccam]);
  2503. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Receiver", PlayerInfo[playerid][pReceiver]);
  2504. SavePlayerInteger(query, GetPlayerSQLId(playerid), "GPS", PlayerInfo[playerid][pGPS]);
  2505. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Sweep", PlayerInfo[playerid][pSweep]);
  2506. SavePlayerInteger(query, GetPlayerSQLId(playerid), "SweepLeft", PlayerInfo[playerid][pSweepLeft]);
  2507. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Bugged", PlayerInfo[playerid][pBugged]);
  2508.  
  2509. SavePlayerInteger(query, GetPlayerSQLId(playerid), "pWExists", PlayerInfo[playerid][pWeedObject]);
  2510. SavePlayerInteger(query, GetPlayerSQLId(playerid), "pWSeeds", PlayerInfo[playerid][pWSeeds]);
  2511.  
  2512. SavePlayerInteger(query, GetPlayerSQLId(playerid), "OrderConfirmed", PlayerInfo[playerid][pOrderConfirmed]);
  2513. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Ringtone", PlayerInfo[playerid][pRingtone]);
  2514. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Flagged", PlayerInfo[playerid][pFlagged]);
  2515.  
  2516. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Paper", PlayerInfo[playerid][pPaper]);
  2517.  
  2518. SavePlayerInteger(query, GetPlayerSQLId(playerid), "HungerDeathTimer", PlayerInfo[playerid][pHungerDeathTimer]);
  2519. SavePlayerInteger(query, GetPlayerSQLId(playerid), "Fitness", PlayerInfo[playerid][pFitness]);
  2520. SavePlayerInteger(query, GetPlayerSQLId(playerid), "HealthCare", PlayerInfo[playerid][pHealthCare]);
  2521. SavePlayerInteger(query, GetPlayerSQLId(playerid), "ReceivedCredits", PlayerInfo[playerid][pReceivedCredits]);
  2522. SavePlayerInteger(query, GetPlayerSQLId(playerid), "RimMod", PlayerInfo[playerid][pRimMod]);
  2523. SavePlayerInteger(query, GetPlayerSQLId(playerid), "VehVoucher", PlayerInfo[playerid][pVehVoucher]);
  2524. SavePlayerInteger(query, GetPlayerSQLId(playerid), "SVIPVoucher", PlayerInfo[playerid][pSVIPVoucher]);
  2525. SavePlayerInteger(query, GetPlayerSQLId(playerid), "ReceivedPrize", PlayerInfo[playerid][pReceivedPrize]);
  2526.  
  2527. MySQLUpdateFinish(query, GetPlayerSQLId(playerid));
  2528. return 1;
  2529. }
  2530.  
  2531. stock SaveGate(id) {
  2532. new string[512];
  2533. format(string, sizeof(string), "UPDATE `gates` SET \
  2534. `HID`=%d, \
  2535. `Automate`=%d, \
  2536. `Locked`=%d \
  2537. WHERE `ID` = %d",
  2538. GateInfo[id][gHID],
  2539. GateInfo[id][gSpeed],
  2540. GateInfo[id][gRange],
  2541. GateInfo[id][gModel],
  2542. GateInfo[id][gVW],
  2543. GateInfo[id][gInt],
  2544. g_mysql_ReturnEscaped(GateInfo[id][gPass], MainPipeline),
  2545. GateInfo[id][gPosX],
  2546. GateInfo[id][gPosY],
  2547. GateInfo[id][gPosZ],
  2548. GateInfo[id][gRotX],
  2549. GateInfo[id][gRotY],
  2550. GateInfo[id][gRotZ],
  2551. GateInfo[id][gPosXM],
  2552. GateInfo[id][gPosYM],
  2553. GateInfo[id][gPosZM],
  2554. GateInfo[id][gRotXM],
  2555. GateInfo[id][gRotYM],
  2556. GateInfo[id][gRotZM],
  2557. GateInfo[id][gAllegiance],
  2558. GateInfo[id][gGroupType],
  2559. GateInfo[id][gGroupID],
  2560. GateInfo[id][gFamilyID],
  2561. GateInfo[id][gRenderHQ],
  2562. GateInfo[id][gTimer],
  2563. GateInfo[id][gAutomate],
  2564. GateInfo[id][gLocked],
  2565. id+1
  2566. );
  2567. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2568. return 0;
  2569. }
  2570.  
  2571. stock SaveAuction(auction) {
  2572. new query[200];
  2573. format(query, sizeof(query), "UPDATE `auctions` SET");
  2574. format(query, sizeof(query), "%s `BiddingFor` = '%s', `InProgress` = %d, `Bid` = %d, `Bidder` = %d, `Expires` = %d, `Wining` = '%s', `Increment` = %d", query, g_mysql_ReturnEscaped(Auctions[auction][BiddingFor], MainPipeline), Auctions[auction][InProgress], Auctions[auction][Bid], Auctions[auction][Bidder], Auctions[auction][Expires], g_mysql_ReturnEscaped(Auctions[auction][Wining], MainPipeline), Auctions[auction][Increment]);
  2575. format(query, sizeof(query), "%s WHERE `id` = %d", query, auction+1);
  2576. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  2577. }
  2578.  
  2579. stock SaveDealershipSpawn(businessid) {
  2580. new query[200];
  2581. format(query, sizeof(query), "UPDATE `businesses` SET");
  2582. format(query, sizeof(query), "%s `PurchaseX` = %0.5f, `PurchaseY` = %0.5f, `PurchaseZ` = %0.5f, `PurchaseAngle` = %0.5f", query, Businesses[businessid][bPurchaseX], Businesses[businessid][bPurchaseY], Businesses[businessid][bPurchaseZ], Businesses[businessid][bPurchaseAngle]);
  2583. format(query, sizeof(query), "%s WHERE `Id` = %d", query, businessid+1);
  2584. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  2585. }
  2586.  
  2587. stock SaveDealershipVehicle(businessid, slotid)
  2588. {
  2589. new query[256];
  2590. //slotid++;
  2591. format(query, sizeof(query), "UPDATE `businesses` SET");
  2592. format(query, sizeof(query), "%s WHERE `Id` = %d", query, businessid+1);
  2593. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "ii", SENDDATA_THREAD, INVALID_PLAYER_ID);
  2594. }
  2595.  
  2596. stock GetLatestKills(playerid, giveplayerid)
  2597. {
  2598. new query[256];
  2599. format(query, sizeof(query), "SELECT Killer.Username, Killed.Username, k.* FROM kills k LEFT JOIN accounts Killed ON k.killedid = Killed.id LEFT JOIN accounts Killer ON Killer.id = k.killerid WHERE k.killerid = %d OR k.killedid = %d ORDER BY `date` DESC LIMIT 10", GetPlayerSQLId(giveplayerid), GetPlayerSQLId(giveplayerid));
  2600. mysql_function_query(MainPipeline, query, true, "OnGetLatestKills", "ii", playerid, giveplayerid);
  2601. }
  2602.  
  2603. stock GetSMSLog(playerid)
  2604. {
  2605. new query[256];
  2606. format(query, sizeof(query), "SELECT `sender`, `sendernumber`, `message`, `date` FROM `sms` WHERE `receiverid` = %d ORDER BY `date` DESC LIMIT 10", GetPlayerSQLId(playerid));
  2607. mysql_function_query(MainPipeline, query, true, "OnGetSMSLog", "i", playerid);
  2608. }
  2609.  
  2610. stock LoadBusinessSales() {
  2611.  
  2612. print("[LoadBusinessSales] Loading data from database...");
  2613. mysql_function_query(MainPipeline, "SELECT * FROM `businesssales`", true, "LoadBusinessesSaless", "");
  2614. }
  2615.  
  2616. stock LoadBusinesses() {
  2617. printf("[LoadBusinesses] Loading data from database...");
  2618. mysql_function_query(MainPipeline, "SELECT OwnerName.Username, b.* FROM businesses b LEFT JOIN accounts OwnerName ON b.OwnerID = OwnerName.id", true, "BusinessesLoadQueryFinish", "");
  2619. }
  2620.  
  2621. stock LoadAuctions() {
  2622. printf("[LoadAuctions] Loading data from database...");
  2623. mysql_function_query(MainPipeline, "SELECT * FROM `auctions`", true, "AuctionLoadQuery", "");
  2624. }
  2625.  
  2626. stock LoadPlants() {
  2627. printf("[LoadPlants] Loading data from database...");
  2628. mysql_function_query(MainPipeline, "SELECT * FROM `plants`", true, "PlantsLoadQuery", "");
  2629. }
  2630.  
  2631. stock SaveBusinessSale(id)
  2632. {
  2633. new query[200];
  2634. format(query, 200, "UPDATE `businesssales` SET `BusinessID` = '%d', `Text` = '%s', `Price` = '%d', `Available` = '%d', `Purchased` = '%d', `Type` = '%d' WHERE `bID` = '%d'", BusinessSales[id][bBusinessID], BusinessSales[id][bText],
  2635. BusinessSales[id][bPrice], BusinessSales[id][bAvailable], BusinessSales[id][bPurchased], BusinessSales[id][bType], BusinessSales[id][bID]);
  2636. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2637. printf("[BusinessSale] saved %i", id);
  2638. return 1;
  2639. }
  2640.  
  2641. stock SavePlant(plant)
  2642. {
  2643. new query[300];
  2644. format(query, sizeof(query), "UPDATE `plants` SET `Owner` = %d, `Object` = %d, `PlantType` = %d, `PositionX` = %f, `PositionY` = %f, `PositionZ` = %f, `Virtual` = %d, \
  2645. `Interior` = %d, `Growth` = %d, `Expires` = %d, `DrugsSkill` = %d WHERE `PlantID` = %d",Plants[plant][pOwner], Plants[plant][pObject], Plants[plant][pPlantType], Plants[plant][pPos][0], Plants[plant][pPos][1], Plants[plant][pPos][2],
  2646. Plants[plant][pVirtual], Plants[plant][pInterior], Plants[plant][pGrowth], Plants[plant][pExpires], Plants[plant][pDrugsSkill], plant+1);
  2647. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2648. return 1;
  2649. }
  2650.  
  2651. stock SaveBusiness(id)
  2652. {
  2653. new query[4019];
  2654.  
  2655. format(query, sizeof(query), "UPDATE `businesses` SET ");
  2656.  
  2657. format(query, sizeof(query), "%s \
  2658. `Name` = '%s', `Type` = %d, `Value` = %d, `OwnerID` = %d, `Months` = %d, `SafeBalance` = %d, `Inventory` = %d, `InventoryCapacity` = %d, `Status` = %d, `Level` = %d, \
  2659. `LevelProgress` = %d, `AutoSale` = %d, `OrderDate` = '%s', `OrderAmount` = %d, `OrderBy` = '%s', `OrderState` = %d, `TotalSales` = %d, ",
  2660. query,
  2661. g_mysql_ReturnEscaped(Businesses[id][bName], MainPipeline), Businesses[id][bType], Businesses[id][bValue], Businesses[id][bOwner], Businesses[id][bMonths], Businesses[id][bSafeBalance], Businesses[id][bInventory], Businesses[id][bInventoryCapacity], Businesses[id][bStatus], Businesses[id][bLevel],
  2662. Businesses[id][bLevelProgress], Businesses[id][bAutoSale], Businesses[id][bOrderDate], Businesses[id][bOrderAmount], g_mysql_ReturnEscaped(Businesses[id][bOrderBy], MainPipeline), Businesses[id][bOrderState], Businesses[id][bTotalSales]);
  2663.  
  2664. format(query, sizeof(query), "%s \
  2665. `ExteriorX` = %f, `ExteriorY` = %f, `ExteriorZ` = %f, `ExteriorA` = %f, \
  2666. `InteriorX` = %f, `InteriorY` = %f, `InteriorZ` = %f, `InteriorA` = %f, \
  2667. `Interior` = %d, `CustomExterior` = %d, `CustomInterior` = %d, `Grade` = %d, `CustomVW` = %d, `SupplyPointX` = %f, `SupplyPointY` = %f, `SupplyPointZ` = %f, ",
  2668. query,
  2669. Businesses[id][bExtPos][0], Businesses[id][bExtPos][1], Businesses[id][bExtPos][2], Businesses[id][bExtPos][3],
  2670. Businesses[id][bIntPos][0], Businesses[id][bIntPos][1], Businesses[id][bIntPos][2], Businesses[id][bIntPos][3],
  2671. Businesses[id][bInt], Businesses[id][bCustomExterior], Businesses[id][bCustomInterior], Businesses[id][bGrade], Businesses[id][bVW], Businesses[id][bSupplyPos][0],Businesses[id][bSupplyPos][1], Businesses[id][bSupplyPos][2]);
  2672.  
  2673. for (new i; i < 17; i++) format(query, sizeof(query), "%s`Item%dPrice` = %d, ", query, i+1, Businesses[id][bItemPrices][i]);
  2674. for (new i; i < 5; i++) format(query, sizeof(query), "%s`Rank%dPay` = %d, ", query, i, Businesses[id][bRankPay][i], id);
  2675. for (new i; i < MAX_BUSINESS_GAS_PUMPS; i++) format(query, sizeof(query), "%s `GasPump%dPosX` = %f, `GasPump%dPosY` = %f, `GasPump%dPosZ` = %f, `GasPump%dAngle` = %f, `GasPump%dModel` = %d, `GasPump%dCapacity` = %f, `GasPump%dGas` = %f, ", query, i+1, Businesses[id][GasPumpPosX][i], i+1, Businesses[id][GasPumpPosY][i], i+1, Businesses[id][GasPumpPosZ][i], i+1, Businesses[id][GasPumpAngle][i], i+1, 1646,i+1, Businesses[id][GasPumpCapacity], i+1, Businesses[id][GasPumpGallons]);
  2676.  
  2677. format(query, sizeof(query), "%s \
  2678. `Pay` = %d, `GasPrice` = %f, `MinInviteRank` = %d, `MinSupplyRank` = %d, `MinGiveRankRank` = %d, `MinSafeRank` = %d, `GymEntryFee` = %d, `GymType` = %d, `TotalProfits` = %d WHERE `Id` = %d",
  2679. query,
  2680. Businesses[id][bAutoPay], Businesses[id][bGasPrice], Businesses[id][bMinInviteRank], Businesses[id][bMinSupplyRank], Businesses[id][bMinGiveRankRank], Businesses[id][bMinSafeRank], Businesses[id][bGymEntryFee], Businesses[id][bGymType], Businesses[id][bTotalProfits], id+1);
  2681.  
  2682. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2683.  
  2684. //printf("Len :%d", strlen(query));
  2685. printf("[business] saved %i", id);
  2686.  
  2687. return 1;
  2688. }
  2689.  
  2690. //--------------------------------[ CUSTOM PUBLIC FUNCTIONS ]---------------------------
  2691.  
  2692. forward OnPhoneNumberCheck(index, extraid);
  2693. public OnPhoneNumberCheck(index, extraid)
  2694. {
  2695. if(IsPlayerConnected(index))
  2696. {
  2697. new string[128];
  2698. new rows, fields;
  2699. cache_get_data(rows, fields, MainPipeline);
  2700.  
  2701. switch(extraid)
  2702. {
  2703. case 1: {
  2704. if(rows)
  2705. {
  2706. SendClientMessageEx(index, COLOR_WHITE, "That phone number has already been taken.");
  2707. DeletePVar(index, "PhChangerId");
  2708. DeletePVar(index, "WantedPh");
  2709. DeletePVar(index, "PhChangeCost");
  2710. DeletePVar(index, "CurrentPh");
  2711. }
  2712. else
  2713. {
  2714. format(string,sizeof(string),"The phone number requested, %d, will cost a total of $%s.\n\nTo confirm, press OK.", GetPVarInt(index, "WantedPh"), number_format(GetPVarInt(index, "PhChangeCost")));
  2715. ShowPlayerDialog(index, VIPNUMMENU2, DIALOG_STYLE_MSGBOX, "Confirmation", string, "OK", "Cancel");
  2716. }
  2717. }
  2718. case 2: {
  2719. if(rows)
  2720. {
  2721. SendClientMessageEx(index, COLOR_WHITE, "That phone number has already been taken.");
  2722. }
  2723. else
  2724. {
  2725. PlayerInfo[index][pPnumber] = GetPVarInt(index, "WantedPh");
  2726. GivePlayerCash(index, -GetPVarInt(index, "PhChangeCost"));
  2727. format(string, sizeof(string), "Cellphone purchased, your new phone number is %d.", GetPVarInt(index, "WantedPh"));
  2728. SendClientMessageEx(index, COLOR_GRAD4, string);
  2729. SendClientMessageEx(index, COLOR_GRAD5, "You can check this any time you wish by typing /stats.");
  2730. SendClientMessageEx(index, COLOR_WHITE, "HINT: You can now type /cellphonehelp to see your cellphone commands.");
  2731. format(string, sizeof(string), "UPDATE `accounts` SET `PhoneNr` = %d WHERE `id` = '%d'", PlayerInfo[index][pPnumber], GetPlayerSQLId(index));
  2732. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, index);
  2733. DeletePVar(index, "PhChangerId");
  2734. DeletePVar(index, "WantedPh");
  2735. DeletePVar(index, "PhChangeCost");
  2736. DeletePVar(index, "CurrentPh");
  2737. }
  2738. }
  2739. case 3: {
  2740. if(rows && GetPVarInt(index, "WantedPh") != 0)
  2741. {
  2742. SendClientMessageEx(index, COLOR_WHITE, "That phone number has already been taken.");
  2743. }
  2744. else
  2745. {
  2746. PlayerInfo[index][pPnumber] = GetPVarInt(index, "WantedPh");
  2747. format(string, sizeof(string), " %s's Phone Number has been set to %d.", GetPlayerNameEx(index), GetPVarInt(index, "WantedPh"));
  2748.  
  2749. format(string, sizeof(string), "%s by %s", string, GetPlayerNameEx(index));
  2750. Log("logs/undercover.log", string);
  2751. SendClientMessageEx(index, COLOR_GRAD1, string);
  2752. format(string, sizeof(string), "UPDATE `accounts` SET `PhoneNr` = %d WHERE `id` = '%d'", PlayerInfo[index][pPnumber], GetPlayerSQLId(index));
  2753. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, index);
  2754. DeletePVar(index, "PhChangerId");
  2755. DeletePVar(index, "WantedPh");
  2756. DeletePVar(index, "PhChangeCost");
  2757. DeletePVar(index, "CurrentPh");
  2758. }
  2759. }
  2760. case 4: {
  2761. if(IsPlayerConnected(GetPVarInt(index, "PhChangerId")))
  2762. {
  2763. if(rows)
  2764. {
  2765. SendClientMessageEx(GetPVarInt(index, "PhChangerId"), COLOR_WHITE, "That phone number has already been taken.");
  2766. }
  2767. else
  2768. {
  2769. PlayerInfo[index][pPnumber] = GetPVarInt(index, "WantedPh");
  2770. format(string, sizeof(string), " %s's Phone Number has been set to %d.", GetPlayerNameEx(index), GetPVarInt(index, "WantedPh"));
  2771.  
  2772. format(string, sizeof(string), "%s by %s", string, GetPlayerNameEx(GetPVarInt(index, "PhChangerId")));
  2773. Log("logs/stats.log", string);
  2774. SendClientMessageEx(GetPVarInt(index, "PhChangerId"), COLOR_GRAD1, string);
  2775. format(string, sizeof(string), "UPDATE `accounts` SET `PhoneNr` = %d WHERE `id` = '%d'", PlayerInfo[index][pPnumber], GetPlayerSQLId(index));
  2776. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, index);
  2777. DeletePVar(index, "PhChangerId");
  2778. DeletePVar(index, "WantedPh");
  2779. DeletePVar(index, "PhChangeCost");
  2780. DeletePVar(index, "CurrentPh");
  2781. }
  2782. }
  2783. }
  2784. }
  2785. }
  2786. return 1;
  2787. }
  2788.  
  2789. forward AddingBan(index, type);
  2790. public AddingBan(index, type)
  2791. {
  2792. if(IsPlayerConnected(index))
  2793. {
  2794. if(type == 1) // Add Ban
  2795. {
  2796. new rows, fields;
  2797. cache_get_data(rows, fields, MainPipeline);
  2798. if(rows)
  2799. {
  2800. DeletePVar(index, "BanningPlayer");
  2801. DeletePVar(index, "BanningReason");
  2802. SendClientMessageEx(index, COLOR_GREY, "That player is already banned.");
  2803. }
  2804. else
  2805. {
  2806. if(IsPlayerConnected(GetPVarInt(index, "BanningPlayer")))
  2807. {
  2808. new string[150], reason[64];
  2809. GetPVarString(index, "BanningReason", reason, sizeof(reason));
  2810.  
  2811. format(string, sizeof(string), "INSERT INTO `ip_bans` (`ip`, `date`, `reason`, `admin`) VALUES ('%s', NOW(), '%s', '%s')", GetPlayerIpEx(GetPVarInt(index, "BanningPlayer")), reason, GetPlayerNameEx(index));
  2812. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2813.  
  2814. DeletePVar(index, "BanningPlayer");
  2815. DeletePVar(index, "BanningReason");
  2816. }
  2817. }
  2818. }
  2819. else if(type == 2) // Unban IP
  2820. {
  2821. new rows, fields;
  2822. cache_get_data(rows, fields, MainPipeline);
  2823. if(rows)
  2824. {
  2825. new string[128], ip[32];
  2826. GetPVarString(index, "UnbanIP", ip, sizeof(ip));
  2827.  
  2828. format(string, sizeof(string), "DELETE FROM `ip_bans` WHERE `ip` = '%s'", ip);
  2829. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2830.  
  2831. DeletePVar(index, "UnbanIP");
  2832. }
  2833. else
  2834. {
  2835. SendClientMessageEx(index, COLOR_GREY, "That IP address was not found in the ban database.");
  2836. DeletePVar(index, "UnbanIP");
  2837. }
  2838. }
  2839. else if(type == 3) // Ban IP
  2840. {
  2841. new rows, fields;
  2842. cache_get_data(rows, fields, MainPipeline);
  2843. if(rows)
  2844. {
  2845. SendClientMessageEx(index, COLOR_GREY, "That IP address is already banned.");
  2846. DeletePVar(index, "BanIP");
  2847. }
  2848. else
  2849. {
  2850. new string[128], ip[32];
  2851. GetPVarString(index, "BanIP", ip, sizeof(ip));
  2852. format(string, sizeof(string), "INSERT INTO `ip_bans` (`ip`, `date`, `reason`, `admin`) VALUES ('%s', NOW(), '%s', '%s')", ip, "/banip", GetPlayerNameEx(index));
  2853. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2854.  
  2855. SendClientMessageEx(index, COLOR_WHITE, "That IP address was successfully banned.");
  2856. DeletePVar(index, "BanIP");
  2857. }
  2858. }
  2859. }
  2860. return 1;
  2861. }
  2862.  
  2863. forward MailsQueryFinish(playerid);
  2864. public MailsQueryFinish(playerid)
  2865. {
  2866.  
  2867. new rows, fields;
  2868. cache_get_data(rows, fields, MainPipeline);
  2869.  
  2870. if (rows == 0) {
  2871. ShowPlayerDialog(playerid, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, " ", "Your mailbox is empty.", "OK", "");
  2872. return 1;
  2873. }
  2874.  
  2875. new id, string[2000], message[129], tmp[128], read;
  2876. for(new i; i < rows;i++)
  2877. {
  2878. cache_get_field_content(i, "Id", tmp, MainPipeline); id = strval(tmp);
  2879. cache_get_field_content(i, "Read", tmp, MainPipeline); read= strval(tmp);
  2880. cache_get_field_content(i, "Message", message, MainPipeline, 129);
  2881. strmid(message,message,0,30);
  2882. if (strlen(message) > 30) strcat(message,"...");
  2883. strcat(string, (read) ? ("{BBBBBB}") : ("{FFFFFF}"));
  2884. strcat(string, message);
  2885. if (i != rows - 1) strcat(string, "\n");
  2886. ListItemTrackId[playerid][i] = id;
  2887. }
  2888.  
  2889. ShowPlayerDialog(playerid, DIALOG_POMAILS, DIALOG_STYLE_LIST, "Your mails", string, "Read", "Close");
  2890.  
  2891. return 1;
  2892. }
  2893.  
  2894. forward MailDetailsQueryFinish(playerid);
  2895. public MailDetailsQueryFinish(playerid)
  2896. {
  2897. new string[256];
  2898. new rows, fields;
  2899. cache_get_data(rows, fields, MainPipeline);
  2900.  
  2901. new senderid, sender[MAX_PLAYER_NAME], message[131], notify, szTmp[128], Date[32], read, id;
  2902. cache_get_field_content(0, "Id", szTmp, MainPipeline); id = strval(szTmp);
  2903. cache_get_field_content(0, "Notify", szTmp, MainPipeline); notify = strval(szTmp);
  2904. cache_get_field_content(0, "Sender_Id", szTmp, MainPipeline); senderid = strval(szTmp);
  2905. cache_get_field_content(0, "Read", szTmp, MainPipeline); read = strval(szTmp);
  2906. cache_get_field_content(0, "Message", message, MainPipeline, 131);
  2907. cache_get_field_content(0, "SenderUser", sender, MainPipeline, MAX_PLAYER_NAME);
  2908. cache_get_field_content(0, "Date", Date, MainPipeline, 32);
  2909.  
  2910. if (strlen(message) > 80) strins(message, "\n", 70);
  2911.  
  2912. format(string, sizeof(string), "{EEEEEE}%s\n\n{BBBBBB}Sender: {FFFFFF}%s\n{BBBBBB}Date: {EEEEEE}%s", message, sender,Date);
  2913. ShowPlayerDialog(playerid, DIALOG_PODETAIL, DIALOG_STYLE_MSGBOX, "Mail Content", string, "Back", "Trash");
  2914.  
  2915. if (notify && !read) {
  2916. foreach(new i: Player)
  2917. {
  2918. if (GetPlayerSQLId(i) == senderid) {
  2919. format(string, sizeof(string), "Your message has just been read by %s!", GetPlayerNameEx(playerid));
  2920. SendClientMessageEx(i, COLOR_YELLOW, string);
  2921. break;
  2922. }
  2923. }
  2924. }
  2925.  
  2926. format(string, sizeof(string), "UPDATE `letters` SET `Read` = 1 WHERE `id` = %d", id);
  2927. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  2928.  
  2929. return 1;
  2930. }
  2931.  
  2932.  
  2933. forward MailDeliveryQueryFinish();
  2934. public MailDeliveryQueryFinish()
  2935. {
  2936.  
  2937. new rows, fields, id, tmp[128], i;
  2938. cache_get_data(rows, fields, MainPipeline);
  2939.  
  2940. for(; i < rows;i++)
  2941. {
  2942. cache_get_field_content(i, "Receiver_Id", tmp, MainPipeline);
  2943. id = strval(tmp);
  2944. foreach(new j: Player)
  2945. {
  2946. if (GetPlayerSQLId(j) == id) {
  2947. if (PlayerInfo[j][pDonateRank] >= 4 && HasMailbox(j)) {
  2948. SendClientMessageEx(j, COLOR_YELLOW, "Mail has just been delivered to your mailbox.");
  2949. SetPVarInt(j, "UnreadMails", 1);
  2950. break;
  2951. }
  2952.  
  2953. }
  2954. }
  2955. }
  2956.  
  2957. return 1;
  2958.  
  2959. }
  2960.  
  2961.  
  2962. forward MDCQueryFinish(playerid, suspectid);
  2963. public MDCQueryFinish(playerid, suspectid)
  2964. {
  2965. new rows, fields;
  2966. cache_get_data(rows, fields, MainPipeline);
  2967. new resultline[1424];
  2968. new crimes = PlayerInfo[suspectid][pCrimes];
  2969. new arrests = PlayerInfo[suspectid][pArrested];
  2970. format(resultline, sizeof(resultline), "{FF6347}Name:{BFC0C2} %s\t{FF6347}Phone Number:{BFC0C2} %d\n{FF6347}Total Previous Crimes: {BFC0C2}%d\t {FF6347}Total Arrests: {BFC0C2}%d \n{FF6347}Crime Key: {FF7D7D}Currently Wanted/{BFC0C2}Past Crime\n\n", GetPlayerNameEx(suspectid),PlayerInfo[suspectid][pPnumber], crimes, arrests);
  2971.  
  2972. for(new i; i < rows; i++)
  2973. {
  2974. cache_get_field_content(i, "issuer", MDCInfo[i][mdcIssuer], MainPipeline, MAX_PLAYER_NAME);
  2975. cache_get_field_content(i, "crime", MDCInfo[i][mdcCrime], MainPipeline, 64);
  2976. cache_get_field_content(i, "active", MDCInfo[i][mdcActive], MainPipeline, 2);
  2977. if(strval(MDCInfo[i][mdcActive]) == 1)
  2978. {
  2979. format(resultline, sizeof(resultline),"%s{FF6347}Crime: {FF7D7D}%s \t{FF6347}Charged by:{BFC0C2} %s\n",resultline, MDCInfo[i][mdcCrime], MDCInfo[i][mdcIssuer]);
  2980. } else {
  2981. format(resultline, sizeof(resultline),"%s{FF6347}Crime: {BFC0C2}%s \t{FF6347}Charged by:{BFC0C2} %s\n",resultline, MDCInfo[i][mdcCrime], MDCInfo[i][mdcIssuer]);
  2982. }
  2983. }
  2984. ShowPlayerDialog(playerid, MDC_SHOWCRIMES, DIALOG_STYLE_MSGBOX, "SA-MDC - Criminal History", resultline, "Back", "");
  2985. return 1;
  2986. }
  2987.  
  2988. forward MDCReportsQueryFinish(playerid, suspectid);
  2989. public MDCReportsQueryFinish(playerid, suspectid)
  2990. {
  2991. new rows, fields;
  2992. cache_get_data(rows, fields, MainPipeline);
  2993. new resultline[1424], str[12];
  2994. new copname[MAX_PLAYER_NAME], datetime[64], reportsid;
  2995. for(new i; i < rows; i++)
  2996. {
  2997. cache_get_field_content(i, "id", str, MainPipeline, 12); reportsid = strval(str);
  2998. cache_get_field_content(i, "Username", copname, MainPipeline, MAX_PLAYER_NAME);
  2999. cache_get_field_content(i, "datetime", datetime, MainPipeline, 64);
  3000. format(resultline, sizeof(resultline),"%s{FF6347}Report (%d) {FF7D7D}Arrested by: %s on %s\n",resultline, reportsid, copname,datetime);
  3001. }
  3002. ShowPlayerDialog(playerid, MDC_SHOWREPORTS, DIALOG_STYLE_LIST, "SA-MDC - Criminal History", resultline, "Back", "");
  3003. return 1;
  3004. }
  3005.  
  3006. forward MDCReportQueryFinish(playerid, reportid);
  3007. public MDCReportQueryFinish(playerid, reportid)
  3008. {
  3009. new rows, fields;
  3010. cache_get_data(rows, fields, MainPipeline);
  3011. new resultline[1424];
  3012. new copname[MAX_PLAYER_NAME], datetime[64], shortreport[200];
  3013. for(new i; i < rows; i++)
  3014. {
  3015. cache_get_field_content(i, "Username", copname, MainPipeline, MAX_PLAYER_NAME);
  3016. cache_get_field_content(i, "datetime", datetime, MainPipeline, 64);
  3017. cache_get_field_content(i, "shortreport", shortreport, MainPipeline, 200);
  3018. format(resultline, sizeof(resultline),"{FF6347}Report #%d\n{FF7D7D}Arrested by: %s on %s\n{FF6347}Report:{BFC0C2} %s\n",reportid, copname,datetime, shortreport);
  3019. }
  3020. ShowPlayerDialog(playerid, MDC_SHOWCRIMES, DIALOG_STYLE_MSGBOX, "SA-MDC - Arrest Report", resultline, "Back", "");
  3021. return 1;
  3022. }
  3023.  
  3024. forward FlagQueryFinish(playerid, suspectid, queryid);
  3025. public FlagQueryFinish(playerid, suspectid, queryid)
  3026. {
  3027. new rows, fields;
  3028. cache_get_data(rows, fields, MainPipeline);
  3029. new resultline[2000];
  3030. new header[64], sResult[64];
  3031. new FlagID, FlagIssuer[MAX_PLAYER_NAME], FlagText[64], FlagDate[24];
  3032. switch(queryid)
  3033. {
  3034. case Flag_Query_Display:
  3035. {
  3036. format(header, sizeof(header), "{FF6347}Flag History for{BFC0C2} %s", GetPlayerNameEx(suspectid));
  3037.  
  3038. for(new i; i < rows; i++)
  3039. {
  3040. cache_get_field_content(i, "fid", sResult, MainPipeline); FlagID = strval(sResult);
  3041. cache_get_field_content(i, "issuer", FlagIssuer, MainPipeline, MAX_PLAYER_NAME);
  3042. cache_get_field_content(i, "flag", FlagText, MainPipeline, 64);
  3043. cache_get_field_content(i, "time", FlagDate, MainPipeline, 24);
  3044. format(resultline, sizeof(resultline),"%s{FF6347}Flag (ID: %d): {BFC0C2} %s \t{FF6347}Issued by:{BFC0C2} %s \t{FF6347}Date: {BFC0C2}%s\n",resultline, FlagID, FlagText, FlagIssuer, FlagDate);
  3045. }
  3046. if(rows == 0)
  3047. {
  3048. format(resultline, sizeof(resultline),"{FF6347}No Flags on this account");
  3049. }
  3050. ShowPlayerDialog(playerid, FLAG_LIST, DIALOG_STYLE_MSGBOX, header, resultline, "Delete Flag", "Close");
  3051. }
  3052. case Flag_Query_Offline:
  3053. {
  3054. new string[128], name[24], reason[64], psqlid[12];
  3055. GetPVarString(playerid, "OnAddFlag", name, 24);
  3056. GetPVarString(playerid, "OnAddFlagReason", reason, 64);
  3057. SendClientMessage(playerid, COLOR_YELLOW, string);
  3058. if(rows > 0) {
  3059. format(string, sizeof(string), "You have appended %s's flag.", name);
  3060. SendClientMessageEx(playerid, COLOR_WHITE, string);
  3061.  
  3062. format(string, sizeof(string), "AdmCmd: %s was offline flagged by %s, reason: %s.", name, GetPlayerNameEx(playerid), reason);
  3063. ABroadCast(COLOR_LIGHTRED, string, 2);
  3064.  
  3065. format(string, sizeof(string), "%s was offline flagged by %s (%s).", name, GetPlayerNameEx(playerid), reason);
  3066. Log("logs/flags.log", string);
  3067.  
  3068. cache_get_field_content(0, "id", psqlid, MainPipeline);
  3069.  
  3070. AddOFlag(strval(psqlid), playerid, reason);
  3071. }
  3072. else {
  3073. format(string, sizeof(string), "There was a problem with appending %s's flag.", name);
  3074. SendClientMessageEx(playerid, COLOR_WHITE, string);
  3075. }
  3076. DeletePVar(playerid, "OnAddFlagReason");
  3077. }
  3078. case Flag_Query_Count:
  3079. {
  3080. PlayerInfo[playerid][pFlagged] = rows;
  3081. }
  3082. }
  3083. return 1;
  3084. }
  3085.  
  3086. forward SkinQueryFinish(playerid, queryid);
  3087. public SkinQueryFinish(playerid, queryid)
  3088. {
  3089. new rows, fields;
  3090. cache_get_data(rows, fields, MainPipeline);
  3091. new resultline[2000], header[32], sResult[64], skinid;
  3092. switch(queryid)
  3093. {
  3094. case Skin_Query_Display:
  3095. {
  3096. if(PlayerInfo[playerid][pDonateRank] <= 0) format(header, sizeof(header), "Closet -- Space: %d/10", PlayerInfo[playerid][pSkins]);
  3097. else if(PlayerInfo[playerid][pDonateRank] > 0) format(header, sizeof(header), "Closet -- Space: %d/25", PlayerInfo[playerid][pSkins]);
  3098.  
  3099. if(rows == 0) return SendClientMessageEx(playerid, COLOR_GREY, "There are no clothes in this closet!");
  3100. for(new i; i < rows; i++)
  3101. {
  3102. cache_get_field_content(i, "skinid", sResult, MainPipeline); skinid = strval(sResult);
  3103. format(resultline, sizeof(resultline),"%sSkin ID: %d\n",resultline, skinid);
  3104. }
  3105. ShowPlayerDialog(playerid, SKIN_LIST, DIALOG_STYLE_LIST, header, resultline, "Select", "Cancel");
  3106. }
  3107. case Skin_Query_Count:
  3108. {
  3109. PlayerInfo[playerid][pSkins] = rows;
  3110. }
  3111. case Skin_Query_ID:
  3112. {
  3113. for(new i; i < rows; i++)
  3114. {
  3115. cache_get_field_content(i, "skinid", sResult, MainPipeline); skinid = strval(sResult);
  3116. if(i == GetPVarInt(playerid, "closetchoiceid"))
  3117. {
  3118. SetPVarInt(playerid, "closetskinid", skinid);
  3119. SetPlayerSkin(playerid, skinid);
  3120. ShowPlayerDialog(playerid, SKIN_CONFIRM, DIALOG_STYLE_MSGBOX, "Closet", "Do you want to wear these clothes?", "Yes", "Go Back");
  3121. }
  3122. }
  3123. }
  3124. case Skin_Query_Delete:
  3125. {
  3126. if(PlayerInfo[playerid][pDonateRank] <= 0) format(header, sizeof(header), "Closet -- Space: %d/10", PlayerInfo[playerid][pSkins]);
  3127. else if(PlayerInfo[playerid][pDonateRank] > 0) format(header, sizeof(header), "Closet -- Space: %d/25", PlayerInfo[playerid][pSkins]);
  3128.  
  3129. if(rows == 0) return SendClientMessageEx(playerid, COLOR_GREY, "There are no clothes in this closet!");
  3130. for(new i; i < rows; i++)
  3131. {
  3132. cache_get_field_content(i, "skinid", sResult, MainPipeline); skinid = strval(sResult);
  3133. format(resultline, sizeof(resultline),"%sSkin ID: %d\n",resultline, skinid);
  3134. }
  3135. ShowPlayerDialog(playerid, SKIN_DELETE, DIALOG_STYLE_LIST, header, resultline, "Select", "Cancel");
  3136. }
  3137. case Skin_Query_Delete_ID:
  3138. {
  3139. for(new i; i < rows; i++)
  3140. {
  3141. cache_get_field_content(i, "id", sResult, MainPipeline); skinid = strval(sResult);
  3142. if(i == GetPVarInt(playerid, "closetchoiceid"))
  3143. {
  3144. SetPVarInt(playerid, "closetskinid", skinid);
  3145. ShowPlayerDialog(playerid, SKIN_DELETE2, DIALOG_STYLE_MSGBOX, "Closet", "Are you sure you want to remove these clothes?", "Yes", "Cancel");
  3146. }
  3147. }
  3148. }
  3149. }
  3150. return 1;
  3151. }
  3152.  
  3153.  
  3154. forward CitizenQueryFinish(playerid, queryid);
  3155. public CitizenQueryFinish(playerid, queryid)
  3156. {
  3157. new rows, fields;
  3158. cache_get_data(rows, fields, MainPipeline);
  3159. switch(queryid)
  3160. {
  3161. case TR_Citizen_Count:
  3162. {
  3163. TRCitizens = rows;
  3164. }
  3165. case Total_Count:
  3166. {
  3167. TotalCitizens = rows;
  3168. }
  3169. }
  3170. return 1;
  3171. }
  3172.  
  3173. forward NationQueueQueryFinish(playerid, nation, queryid);
  3174. public NationQueueQueryFinish(playerid, nation, queryid)
  3175. {
  3176. new query[300], resultline[2000], sResult[64], rows, fields;
  3177. cache_get_data(rows, fields, MainPipeline);
  3178. switch(queryid)
  3179. {
  3180. case CheckQueue:
  3181. {
  3182. if(rows == 0)
  3183. {
  3184. format(query, sizeof(query), "INSERT INTO `nation_queue` (`id`, `playerid`, `name`, `date`, `nation`, `status`) VALUES (NULL, %d, '%s', NOW(), %d, 1)", GetPlayerSQLId(playerid), GetPlayerNameEx(playerid), nation);
  3185. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3186. SendClientMessageEx(playerid, COLOR_GREY, "You have been added to the nation's application queue. The nation's leader can now choose to accept or deny your application.");
  3187. }
  3188. else
  3189. {
  3190. SendClientMessageEx(playerid, COLOR_GREY, "You are already in queue to join a nation.");
  3191. }
  3192. }
  3193. case UpdateQueue:
  3194. {
  3195. if(rows > 0)
  3196. {
  3197. format(query, sizeof(query), "UPDATE `nation_queue` SET `name` = '%s' WHERE `playerid` = %d", GetPlayerNameEx(playerid), GetPlayerSQLId(playerid));
  3198. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3199. }
  3200. }
  3201. case AppQueue:
  3202. {
  3203. new sDate[32];
  3204. if(rows == 0) return SendClientMessageEx(playerid, COLOR_GREY, "There are currently no pending applications.");
  3205. for(new i; i < rows; i++)
  3206. {
  3207. cache_get_field_content(i, "name", sResult, MainPipeline, MAX_PLAYER_NAME);
  3208. cache_get_field_content(i, "date", sDate, MainPipeline, 32);
  3209. format(resultline, sizeof(resultline), "%s%s -- Date Submitted: %s\n", resultline, sResult, sDate);
  3210. }
  3211. ShowPlayerDialog(playerid, NATION_APP_LIST, DIALOG_STYLE_LIST, "Nation Applications", resultline, "Select", "Cancel");
  3212. }
  3213. case AddQueue:
  3214. {
  3215. if(rows == 0)
  3216. {
  3217. format(query, sizeof(query), "INSERT INTO `nation_queue` (`id`, `playerid`, `name`, `date`, `nation`, `status`) VALUES (NULL, %d, '%s', NOW(), %d, 2)", GetPlayerSQLId(playerid), GetPlayerNameEx(playerid), nation);
  3218. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3219. PlayerInfo[playerid][pNation] = 1;
  3220. }
  3221. else
  3222. {
  3223. format(query, sizeof(query), "INSERT INTO `nation_queue` (`id`, `playerid`, `name`, `date`, `nation`, `status`) VALUES (NULL, %d, NOW(), %d, 1)", GetPlayerSQLId(playerid), GetPlayerNameEx(playerid), nation);
  3224. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3225. }
  3226. }
  3227. }
  3228. return 1;
  3229. }
  3230.  
  3231. forward NationAppFinish(playerid, queryid);
  3232. public NationAppFinish(playerid, queryid)
  3233. {
  3234. new query[300], string[128], sResult[64], rows, fields;
  3235. cache_get_data(rows, fields, MainPipeline);
  3236. switch(queryid)
  3237. {
  3238. case AcceptApp:
  3239. {
  3240. for(new i; i < rows; i++)
  3241. {
  3242. cache_get_field_content(i, "id", sResult, MainPipeline); new AppID = strval(sResult);
  3243. cache_get_field_content(i, "playerid", sResult, MainPipeline); new UserID = strval(sResult);
  3244. cache_get_field_content(i, "name", sResult, MainPipeline, MAX_PLAYER_NAME);
  3245. if(GetPVarInt(playerid, "Nation_App_ID") == i)
  3246. {
  3247. format(query, sizeof(query), "UPDATE `nation_queue` SET `status` = 2 WHERE `id` = %d", AppID);
  3248. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3249.  
  3250. new giveplayerid = ReturnUser(sResult);
  3251. switch(arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance])
  3252. {
  3253. case 1:
  3254. {
  3255. if(IsPlayerConnected(giveplayerid))
  3256. {
  3257. PlayerInfo[giveplayerid][pNation] = 0;
  3258. SendClientMessageEx(giveplayerid, COLOR_WHITE, "Your application for San Andreas citizenship has been approved!");
  3259. }
  3260. else
  3261. {
  3262. format(query, sizeof(query), "UPDATE `accounts` SET `Nation` = 0 WHERE `id` = %d", UserID);
  3263. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3264. }
  3265. format(string, sizeof(string), "%s has approved %s's application for San Andreas citizenship", GetPlayerNameEx(playerid), sResult);
  3266. }
  3267. case 2:
  3268. {
  3269. if(IsPlayerConnected(giveplayerid))
  3270. {
  3271. PlayerInfo[giveplayerid][pNation] = 1;
  3272. SendClientMessageEx(giveplayerid, COLOR_WHITE, "Your application for Tierra Robada citizenship has been approved!");
  3273. }
  3274. else
  3275. {
  3276. format(query, sizeof(query), "UPDATE `accounts` SET `Nation` = 1 WHERE `id` = %d", UserID);
  3277. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3278. }
  3279. format(string, sizeof(string), "%s has approved %s's application for Tierra Robada citizenship", GetPlayerNameEx(playerid), sResult);
  3280. }
  3281. }
  3282. Log("logs/gov.log", string);
  3283. format(string, sizeof(string), "You have successfully approved %s's application.", sResult);
  3284. SendClientMessageEx(playerid, COLOR_WHITE, string);
  3285. DeletePVar(playerid, "Nation_App_ID");
  3286. }
  3287. }
  3288. }
  3289. case DenyApp:
  3290. {
  3291. for(new i; i < rows; i++)
  3292. {
  3293. cache_get_field_content(i, "id", sResult, MainPipeline, 32); new AppID = strval(sResult);
  3294. cache_get_field_content(i, "name", sResult, MainPipeline, MAX_PLAYER_NAME);
  3295. if(GetPVarInt(playerid, "Nation_App_ID") == i)
  3296. {
  3297. format(query, sizeof(query), "UPDATE `nation_queue` SET `status` = 3 WHERE `id` = %d", AppID);
  3298. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3299. new giveplayerid = ReturnUser(sResult);
  3300. switch(arrGroupData[PlayerInfo[playerid][pMember]][g_iAllegiance])
  3301. {
  3302. case 1:
  3303. {
  3304. if(IsPlayerConnected(giveplayerid)) SendClientMessageEx(giveplayerid, COLOR_GREY, "Your application for San Andreas citizenship has been denied.");
  3305. format(string, sizeof(string), "%s has denied %s's application for San Andreas citizenship", GetPlayerNameEx(playerid), sResult);
  3306. }
  3307. case 2:
  3308. {
  3309. if(IsPlayerConnected(giveplayerid)) SendClientMessageEx(giveplayerid, COLOR_GREY, "Your application for San Andreas citizenship has been denied.");
  3310. format(string, sizeof(string), "%s has denied %s's application for Tierra Robada citizenship", GetPlayerNameEx(playerid), sResult);
  3311. }
  3312. }
  3313. Log("logs/gov.log", string);
  3314. format(string, sizeof(string), "You have successfully denied %s's application.", sResult);
  3315. SendClientMessageEx(playerid, COLOR_WHITE, string);
  3316. DeletePVar(playerid, "Nation_App_ID");
  3317. }
  3318. }
  3319. }
  3320. }
  3321. return 1;
  3322. }
  3323.  
  3324. forward CountAmount(playerid);
  3325. public CountAmount(playerid)
  3326. {
  3327. new rows, fields;
  3328. cache_get_data(rows, fields, MainPipeline);
  3329. PlayerInfo[playerid][pLottoNr] = rows;
  3330. return 1;
  3331. }
  3332.  
  3333. forward UnreadMailsNotificationQueryFin(playerid);
  3334. public UnreadMailsNotificationQueryFin(playerid)
  3335. {
  3336. new szResult[8];
  3337. cache_get_field_content(0, "Unread_Count", szResult, MainPipeline);
  3338. if (strval(szResult) > 0) {
  3339. SetPVarInt(playerid, "UnreadMails", 1);
  3340. SendClientMessageEx(playerid, COLOR_YELLOW, "You have unread items in your mailbox.");
  3341. }
  3342. return 1;
  3343. }
  3344.  
  3345.  
  3346. forward RecipientLookupFinish(playerid);
  3347. public RecipientLookupFinish(playerid)
  3348. {
  3349. new rows,fields,szResult[16], admin, undercover, id;
  3350. cache_get_data(rows, fields, MainPipeline);
  3351.  
  3352. if (!rows) return ShowPlayerDialog(playerid, DIALOG_PORECEIVER, DIALOG_STYLE_INPUT, "Recipient", "{FF3333}Error: {FFFFFF}Invalid Recipient - Account does not exist!\n\nPlease type the name of the recipient (online or offline)", "Next", "Cancel");
  3353.  
  3354. cache_get_field_content(0, "AdminLevel", szResult, MainPipeline); admin = strval(szResult);
  3355. cache_get_field_content(0, "TogReports", szResult, MainPipeline); undercover = strval(szResult);
  3356. cache_get_field_content(0, "id", szResult, MainPipeline); id = strval(szResult);
  3357.  
  3358. if (admin >= 2 && undercover == 0) return ShowPlayerDialog(playerid, DIALOG_PORECEIVER, DIALOG_STYLE_INPUT, "Recipient", "{FF3333}Error: {FFFFFF}You can't send a letter to admins!\n\nPlease type the name of the recipient (online or offline)", "Next", "Cancel");
  3359.  
  3360. SetPVarInt(playerid, "LetterRecipient", id);
  3361. ShowPlayerDialog(playerid, DIALOG_POMESSAGE, DIALOG_STYLE_INPUT, "Send Letter", "{FFFFFF}Please type the message.", "Send", "Cancel");
  3362.  
  3363. return 1;
  3364.  
  3365. }
  3366.  
  3367. forward CheckSales(index);
  3368. public CheckSales(index)
  3369. {
  3370. if(IsPlayerConnected(index))
  3371. {
  3372. new rows, fields, szDialog[128];
  3373. cache_get_data(rows, fields, MainPipeline);
  3374. if(rows > 0)
  3375. {
  3376. for(new i;i < rows;i++)
  3377. {
  3378. new szResult[32], id;
  3379. cache_get_field_content(i, "id", szResult, MainPipeline); id = strval(szResult);
  3380. cache_get_field_content(i, "Month", szResult, MainPipeline, 25);
  3381. format(szDialog, sizeof(szDialog), "%s\n%s ", szDialog, szResult);
  3382. Selected[index][i] = id;
  3383. }
  3384. ShowPlayerDialog(index, DIALOG_VIEWSALE, DIALOG_STYLE_LIST, "Select a time frame", szDialog, "View", "Exit");
  3385. }
  3386. else
  3387. {
  3388. SendClientMessageEx(index, COLOR_WHITE, "There was an issue with checking the table.");
  3389. }
  3390. }
  3391. }
  3392.  
  3393. forward CheckSales2(index);
  3394. public CheckSales2(index)
  3395. {
  3396. if(IsPlayerConnected(index))
  3397. {
  3398. new rows, fields, szDialog[2500];
  3399. cache_get_data(rows, fields, MainPipeline);
  3400. if(rows)
  3401. {
  3402. new szResult[32], szField[15], Solds[MAX_ITEMS], Amount[MAX_ITEMS];
  3403. for(new z = 0; z < MAX_ITEMS; z++)
  3404. {
  3405. format(szField, sizeof(szField), "TotalSold%d", z);
  3406. cache_get_field_content(0, szField, szResult, MainPipeline);
  3407. Solds[z] = strval(szResult);
  3408.  
  3409. format(szField, sizeof(szField), "AmountMade%d", z);
  3410. cache_get_field_content(0, szField, szResult, MainPipeline);
  3411. Amount[z] = strval(szResult);
  3412. }
  3413.  
  3414. format(szDialog, sizeof(szDialog),"\
  3415. Gold VIP Sold: %d | Total Credits: %s\n\
  3416. Gold VIP Renew Sold: %d | Total Credits: %s\n\
  3417. Silver VIP Sold: %d | Total Credits: %s\n\
  3418. Bronze VIP Sold: %d | Total Credits: %s\n\
  3419. Toys Sold: %d | Total Credits: %s\n\
  3420. Cars Sold: %d | Total Credits: %s\n", Solds[0], number_format(Amount[0]), Solds[1], number_format(Amount[1]), Solds[2], number_format(Amount[2]), Solds[3], number_format(Amount[3]), Solds[4], number_format(Amount[4]),
  3421. Solds[5], number_format(Amount[5]));
  3422.  
  3423. format(szDialog, sizeof(szDialog), "%s\
  3424. Pokertables Sold: %d | Total Credits: %s\n\
  3425. Boomboxes Sold: %d | Total Credits: %s\n\
  3426. Paintball Tokens Sold: %d | Total Credits: %s\n\
  3427. EXP Tokens Sold: %d | Total Credits: %s\n\
  3428. Fireworks Sold: %d | Total Credits: %s\n", szDialog, Solds[6], number_format(Amount[6]), Solds[7], number_format(Amount[7]), Solds[8], number_format(Amount[8]), Solds[9], number_format(Amount[9]), Solds[10], number_format(Amount[10]));
  3429.  
  3430. format(szDialog, sizeof(szDialog), "%sBusiness Renew Regular Sold: %d | Total Credits: %s\n\
  3431. Business Renew Standard Sold: %d | Total Credits: %s\n\
  3432. Business Renew Premium Sold: %d | Total Credits: %s\n\
  3433. Houses Sold: %d | Total Credits: %s\n", szDialog, Solds[11], number_format(Amount[11]), Solds[12], number_format(Amount[12]), Solds[13], number_format(Amount[13]), Solds[14], number_format(Amount[14]));
  3434.  
  3435. format(szDialog, sizeof(szDialog), "%sHouse Moves Sold: %d | Total Credits: %s\n\
  3436. House Interiors Sold: %d | Total Credits: %s\n\
  3437. Reset Gift Timer Sold: %d | Total Credits: %s\n\
  3438. Advanced Health Care Sold: %d | Total Credits: %s\n",szDialog, Solds[15], number_format(Amount[15]), Solds[16], number_format(Amount[16]), Solds[17], number_format(Amount[17]), Solds[18], number_format(Amount[18]));
  3439.  
  3440. format(szDialog, sizeof(szDialog), "%sSuper Health Car Sold: %d | Total Credits: %s\n\
  3441. Rented Cars Sold: %d | Total Credits: %s\n\
  3442. Custom License Sold: %d | Total Credits: %s\n\
  3443. Additional Vehicle Slot Sold: %d | Total Credits: %s\n",szDialog, Solds[19], number_format(Amount[19]), Solds[20], number_format(Amount[20]),Solds[22], number_format(Amount[22]), Solds[23], number_format(Amount[23]));
  3444.  
  3445. format(szDialog, sizeof(szDialog), "%sGarage - Small Sold: %d | Total Credits: %s\n\
  3446. Garage - Medium Sold: %d | Total Credits: %s\n\
  3447. Garage - Large Sold: %d | Total Credits: %s\n\
  3448. Garage - Extra Large Sold: %d | Total Credits: %s\n", szDialog, Solds[24], number_format(Amount[24]), Solds[25], number_format(Amount[25]), Solds[26], number_format(Amount[26]), Solds[27], number_format(Amount[27]));
  3449.  
  3450. format(szDialog, sizeof(szDialog), "%sAdditional Toy Slot Sold: %d | Total Credits: %s\n\
  3451. Hunger Voucher: %d | Total Credits: %s\n\
  3452. Credits Transactions: %d | Total Credits %s\n", szDialog, Solds[28], number_format(Amount[28]), Solds[29], number_format(Amount[29]), Solds[21], number_format(Amount[21]));
  3453.  
  3454. format(szDialog, sizeof(szDialog), "%sTotal Amount of Credits spent: %s", szDialog,
  3455. number_format(Amount[0]+Amount[1]+Amount[2]+Amount[3]+Amount[4]+Amount[5]+Amount[6]+Amount[7]+Amount[8]+Amount[9]+Amount[10]+Amount[11]+Amount[12]+Amount[13]+Amount[14]+Amount[15]+Amount[16]+Amount[17]+Amount[18]+Amount[19]+Amount[20]+Amount[21]+Amount[22]+Amount[23]
  3456. +Amount[24]+Amount[25]+Amount[26]+Amount[27]+Amount[28]+Amount[29]));
  3457. ShowPlayerDialog(index, DIALOG_NOTHING, DIALOG_STYLE_MSGBOX, "Shop Statistics", szDialog, "Exit", "");
  3458. }
  3459. else
  3460. {
  3461. SendClientMessageEx(index, COLOR_GREY, "There was an issue with checking the table.");
  3462. }
  3463. }
  3464. }
  3465.  
  3466. forward LoadRentedCar(index);
  3467. public LoadRentedCar(index)
  3468. {
  3469. if(IsPlayerConnected(index))
  3470. {
  3471. new rows, fields;
  3472. cache_get_data(rows, fields, MainPipeline);
  3473. if(rows)
  3474. {
  3475. //`sqlid`, `modelid`, `posx`, `posy`, `posz`, `posa`, `spawned`, `hours`
  3476.  
  3477. new szResult[32], Info[2], Float: pos[4], string[128];
  3478. cache_get_field_content(0, "modelid", szResult, MainPipeline); Info[0] = strval(szResult);
  3479. cache_get_field_content(0, "posx", szResult, MainPipeline); pos[0] = strval(szResult);
  3480. cache_get_field_content(0, "posy", szResult, MainPipeline); pos[1] = strval(szResult);
  3481. cache_get_field_content(0, "posz", szResult, MainPipeline); pos[2] = strval(szResult);
  3482. cache_get_field_content(0, "posa", szResult, MainPipeline); pos[3] = strval(szResult);
  3483. cache_get_field_content(0, "hours", szResult, MainPipeline); Info[1] = strval(szResult);
  3484.  
  3485. SetPVarInt(index, "RentedHours", Info[1]);
  3486. SetPVarInt(index, "RentedVehicle", CreateVehicle(Info[0],pos[0],pos[1], pos[2], pos[3], random(128), random(128), 2000000));
  3487.  
  3488. format(string, sizeof(string), "Your rented vehicle has been spawned and has %d minute(s) left.", Info[1]);
  3489. SendClientMessageEx(index, COLOR_CYAN, string);
  3490. }
  3491. }
  3492. }
  3493.  
  3494. forward LoadTicket(playerid);
  3495. public LoadTicket(playerid) {
  3496. new rows, fields;
  3497. cache_get_data(rows, fields, MainPipeline);
  3498.  
  3499. if (rows == 0) {
  3500. return 1;
  3501. }
  3502.  
  3503. new number, result[10];
  3504. for(new i; i < rows; i++)
  3505. {
  3506. cache_get_field_content(i, "number", result, MainPipeline);
  3507. number = strval(result);
  3508. LottoNumbers[playerid][i] = number;
  3509. }
  3510. return 1;
  3511. }
  3512.  
  3513. forward LoadTreasureInvent(playerid);
  3514. public LoadTreasureInvent(playerid)
  3515. {
  3516. new rows, fields, szResult[10];
  3517. cache_get_data(rows, fields, MainPipeline);
  3518.  
  3519. if(IsPlayerConnected(playerid))
  3520. {
  3521. if(!rows)
  3522. {
  3523. new query[60];
  3524. format(query, sizeof(query), "INSERT INTO `jobstuff` (`pId`) VALUES ('%d')", GetPlayerSQLId(playerid));
  3525. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3526. }
  3527. else
  3528. {
  3529. for(new row;row < rows;row++)
  3530. {
  3531. cache_get_field_content(row, "junkmetal", szResult, MainPipeline); SetPVarInt(playerid, "JunkMetal", strval(szResult));
  3532. cache_get_field_content(row, "newcoin", szResult, MainPipeline); SetPVarInt(playerid, "newcoin", strval(szResult));
  3533. cache_get_field_content(row, "oldcoin", szResult, MainPipeline); SetPVarInt(playerid, "oldcoin", strval(szResult));
  3534. cache_get_field_content(row, "brokenwatch", szResult, MainPipeline); SetPVarInt(playerid, "brokenwatch", strval(szResult));
  3535. cache_get_field_content(row, "oldkey", szResult, MainPipeline); SetPVarInt(playerid, "oldkey", strval(szResult));
  3536. cache_get_field_content(row, "treasure", szResult, MainPipeline); SetPVarInt(playerid, "treasure", strval(szResult));
  3537. cache_get_field_content(row, "goldwatch", szResult, MainPipeline); SetPVarInt(playerid, "goldwatch", strval(szResult));
  3538. cache_get_field_content(row, "silvernugget", szResult, MainPipeline); SetPVarInt(playerid, "silvernugget", strval(szResult));
  3539. cache_get_field_content(row, "goldnugget", szResult, MainPipeline); SetPVarInt(playerid, "goldnugget", strval(szResult));
  3540. }
  3541. }
  3542. }
  3543. return 1;
  3544. }
  3545.  
  3546. forward GetHomeCount(playerid);
  3547. public GetHomeCount(playerid)
  3548. {
  3549. new string[128];
  3550. format(string, sizeof(string), "SELECT NULL FROM `houses` WHERE `OwnerID` = %d", GetPlayerSQLId(playerid));
  3551. return mysql_function_query(MainPipeline, string, true, "QueryGetCountFinish", "ii", playerid, 2);
  3552. }
  3553.  
  3554. forward AddReportToken(playerid);
  3555. public AddReportToken(playerid)
  3556. {
  3557. new
  3558. sz_playerName[MAX_PLAYER_NAME],
  3559. i_timestamp[3],
  3560. tdate[11],
  3561. thour[9],
  3562. query[128];
  3563.  
  3564. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  3565. getdate(i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3566. format(tdate, sizeof(tdate), "%d-%02d-%02d", i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3567. format(thour, sizeof(thour), "%02d:00:00", hour);
  3568.  
  3569. format(query, sizeof(query), "SELECT NULL FROM `tokens_report` WHERE `playerid` = %d AND `date` = '%s' AND `hour` = '%s'", GetPlayerSQLId(playerid), tdate, thour);
  3570. mysql_function_query(MainPipeline, query, true, "QueryTokenFinish", "ii", playerid, 1);
  3571. return 1;
  3572. }
  3573.  
  3574. forward AddCAReportToken(playerid);
  3575. public AddCAReportToken(playerid)
  3576. {
  3577. new
  3578. sz_playerName[MAX_PLAYER_NAME],
  3579. i_timestamp[3],
  3580. tdate[11],
  3581. thour[9],
  3582. query[128];
  3583.  
  3584. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  3585. getdate(i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3586. format(tdate, sizeof(tdate), "%d-%02d-%02d", i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3587. format(thour, sizeof(thour), "%02d:00:00", hour);
  3588.  
  3589. format(query, sizeof(query), "SELECT NULL FROM `tokens_request` WHERE `playerid` = %d AND `date` = '%s' AND `hour` = '%s'", GetPlayerSQLId(playerid), tdate, thour);
  3590. mysql_function_query(MainPipeline, query, true, "QueryTokenFinish", "ii", playerid, 2);
  3591. return 1;
  3592. }
  3593.  
  3594. forward AddCallToken(playerid);
  3595. public AddCallToken(playerid)
  3596. {
  3597. new
  3598. sz_playerName[MAX_PLAYER_NAME],
  3599. i_timestamp[3],
  3600. tdate[11],
  3601. query[128];
  3602.  
  3603. GetPlayerName(playerid, sz_playerName, MAX_PLAYER_NAME);
  3604. getdate(i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3605. format(tdate, sizeof(tdate), "%d-%02d-%02d", i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3606.  
  3607. format(query, sizeof(query), "SELECT NULL FROM `tokens_call` WHERE `playerid` = %d AND `date` = '%s' AND `hour` = %d", GetPlayerSQLId(playerid), tdate, hour);
  3608. mysql_function_query(MainPipeline, query, true, "QueryTokenFinish", "ii", playerid, 3);
  3609. return 1;
  3610. }
  3611.  
  3612. forward QueryTokenFinish(playerid, type);
  3613. public QueryTokenFinish(playerid, type)
  3614. {
  3615. new rows, fields, string[128], i_timestamp[3], tdate[11], thour[9];
  3616. cache_get_data(rows, fields, MainPipeline);
  3617. getdate(i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3618. format(tdate, sizeof(tdate), "%d-%02d-%02d", i_timestamp[0], i_timestamp[1], i_timestamp[2]);
  3619. format(thour, sizeof(thour), "%02d:00:00", hour);
  3620.  
  3621. switch(type)
  3622. {
  3623. case 1:
  3624. {
  3625. if(rows == 0)
  3626. {
  3627. format(string, sizeof(string), "INSERT INTO `tokens_report` (`id`, `playerid`, `date`, `hour`, `count`) VALUES (NULL, %d, '%s', '%s', 1)", GetPlayerSQLId(playerid), tdate, thour);
  3628. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3629. }
  3630. else
  3631. {
  3632. format(string, sizeof(string), "UPDATE `tokens_report` SET `count` = count+1 WHERE `playerid` = %d AND `date` = '%s' AND `hour` = '%s'", GetPlayerSQLId(playerid), tdate, thour);
  3633. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3634. }
  3635. }
  3636. case 2:
  3637. {
  3638. if(rows == 0)
  3639. {
  3640. format(string, sizeof(string), "INSERT INTO `tokens_request` (`id`, `playerid`, `date`, `hour`, `count`) VALUES (NULL, %d, '%s', '%s', 1)", GetPlayerSQLId(playerid), tdate, thour);
  3641. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3642. }
  3643. else
  3644. {
  3645. format(string, sizeof(string), "UPDATE `tokens_request` SET `count` = count+1 WHERE `playerid` = %d AND `date` = '%s' AND `hour` = '%s'", GetPlayerSQLId(playerid), tdate, thour);
  3646. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3647. }
  3648. }
  3649. case 3:
  3650. {
  3651. if(rows == 0)
  3652. {
  3653. format(string, sizeof(string), "INSERT INTO `tokens_call` (`id`, `playerid`, `date`, `hour`, `count`) VALUES (NULL, %d, '%s', %d, 1)", GetPlayerSQLId(playerid), tdate, hour);
  3654. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3655. }
  3656. else
  3657. {
  3658. format(string, sizeof(string), "UPDATE `tokens_call` SET `count` = count+1 WHERE `playerid` = %d AND `date` = '%s' AND `hour` = %d", GetPlayerSQLId(playerid), tdate, hour);
  3659. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3660. }
  3661. }
  3662. }
  3663. return 1;
  3664. }
  3665.  
  3666. forward GetReportCount(userid, tdate[]);
  3667. public GetReportCount(userid, tdate[])
  3668. {
  3669. new string[128];
  3670. format(string, sizeof(string), "SELECT SUM(count) FROM `tokens_report` WHERE `playerid` = %d AND `date` = '%s'", GetPlayerSQLId(userid), tdate);
  3671. return mysql_function_query(MainPipeline, string, true, "QueryGetCountFinish", "ii", userid, 0);
  3672. }
  3673.  
  3674. forward GetHourReportCount(userid, thour[], tdate[]);
  3675. public GetHourReportCount(userid, thour[], tdate[])
  3676. {
  3677. new string[128];
  3678. format(string, sizeof(string), "SELECT `count` FROM `tokens_report` WHERE `playerid` = %d AND `date` = '%s' AND `hour` = '%s'", GetPlayerSQLId(userid), tdate, thour);
  3679. return mysql_function_query(MainPipeline, string, true, "QueryGetCountFinish", "ii", userid, 1);
  3680. }
  3681.  
  3682. forward GetRequestCount(userid, tdate[]);
  3683. public GetRequestCount(userid, tdate[])
  3684. {
  3685. new string[128];
  3686. format(string, sizeof(string), "SELECT SUM(count) FROM `tokens_request` WHERE `playerid` = %d AND `date` = '%s'", GetPlayerSQLId(userid), tdate);
  3687. return mysql_function_query(MainPipeline, string, true, "QueryGetCountFinish", "ii", userid, 0);
  3688. }
  3689.  
  3690. forward GetHourRequestCount(userid, thour[], tdate[]);
  3691. public GetHourRequestCount(userid, thour[], tdate[])
  3692. {
  3693. new string[128];
  3694. format(string, sizeof(string), "SELECT `count` FROM `tokens_request` WHERE `playerid` = %d AND `date` = '%s' AND `hour` = '%s'", GetPlayerSQLId(userid), tdate, thour);
  3695. return mysql_function_query(MainPipeline, string, true, "QueryGetCountFinish", "ii", userid, 1);
  3696. }
  3697.  
  3698. forward QueryGetCountFinish(userid, type);
  3699. public QueryGetCountFinish(userid, type)
  3700. {
  3701. new rows, fields, sResult[24];
  3702. cache_get_data(rows, fields, MainPipeline);
  3703.  
  3704. switch(type)
  3705. {
  3706. case 0:
  3707. {
  3708. if(rows > 0)
  3709. {
  3710. cache_get_field_content(0, "SUM(count)", sResult, MainPipeline);
  3711. ReportCount[userid] = strval(sResult);
  3712. }
  3713. else ReportCount[userid] = 0;
  3714. }
  3715. case 1:
  3716. {
  3717. if(rows > 0)
  3718. {
  3719. cache_get_field_content(0, "count", sResult, MainPipeline);
  3720. ReportHourCount[userid] = strval(sResult);
  3721. }
  3722. else ReportHourCount[userid] = 0;
  3723. }
  3724. case 2:
  3725. {
  3726. Homes[userid] = rows;
  3727. }
  3728. }
  3729. return 1;
  3730. }
  3731.  
  3732. forward OnLoadFamilies();
  3733. public OnLoadFamilies()
  3734. {
  3735. new i, rows, fields, tmp[128], famid;
  3736. cache_get_data(rows, fields, MainPipeline);
  3737.  
  3738. new column[32];
  3739. while(i < rows)
  3740. {
  3741. FamilyMemberCount(i);
  3742. cache_get_field_content(i, "ID", tmp, MainPipeline); famid = strval(tmp);
  3743. cache_get_field_content(i, "Taken", tmp, MainPipeline); FamilyInfo[famid][FamilyTaken] = strval(tmp);
  3744. cache_get_field_content(i, "fontface", tmp, MainPipeline); format(FamilyInfo[famid][gt_FontFace], 32, "%s", tmp);
  3745. cache_get_field_content(i, "fontsize", tmp, MainPipeline); FamilyInfo[famid][gt_FontSize] = strval(tmp);
  3746. cache_get_field_content(i, "bold", tmp, MainPipeline); FamilyInfo[famid][gt_Bold] = strval(tmp);
  3747. cache_get_field_content(i, "fontcolor", tmp, MainPipeline); FamilyInfo[famid][gt_FontColor] = strval(tmp);
  3748. cache_get_field_content(i, "text", FamilyInfo[famid][gt_Text], MainPipeline, 32);
  3749. cache_get_field_content(i, "gtUsed", tmp, MainPipeline); FamilyInfo[famid][gt_SPUsed] = strval(tmp);
  3750. if(strcmp(FamilyInfo[famid][gt_Text], "Preview", true) == 0)
  3751. {
  3752. FamilyInfo[famid][gtObject] = 1490;
  3753. FamilyInfo[famid][gt_SPUsed] = 1;
  3754. }
  3755. for (new j; j <= 6; j++) {
  3756. format(column,sizeof(column), "Rank%d", j);
  3757. cache_get_field_content(i, column, tmp, MainPipeline); format(FamilyRankInfo[famid][j], 20, "%s", tmp);
  3758. }
  3759.  
  3760. for (new j = 0; j < 5 ;j++) {
  3761. format(column, sizeof(column), "Division%d", j);
  3762. cache_get_field_content(i, column, tmp, MainPipeline); format(FamilyDivisionInfo[famid][j], 20, "%s", tmp);
  3763. }
  3764. for (new j; j < 8; j++) {
  3765. format(column,sizeof(column), "Skin%d", j+1);
  3766. cache_get_field_content(i, column, tmp, MainPipeline); FamilyInfo[famid][FamilySkins][j] = strval(tmp);
  3767. }
  3768. for (new j; j < 10; j++) {
  3769. format(column,sizeof(column), "Gun%d", j+1);
  3770. cache_get_field_content(i, column, tmp, MainPipeline); FamilyInfo[famid][FamilyGuns][j] = strval(tmp);
  3771. }
  3772. if(FamilyInfo[famid][FamilyUSafe] > 0)
  3773. {
  3774. FamilyInfo[famid][FamilyPickup] = CreateDynamicPickup(1239, 23, FamilyInfo[famid][FamilySafe][0], FamilyInfo[famid][FamilySafe][1], FamilyInfo[famid][FamilySafe][2], .worldid = FamilyInfo[famid][FamilySafeVW], .interiorid = FamilyInfo[famid][FamilySafeInt]);
  3775. }
  3776. if(FamilyInfo[famid][FamilyEntrance][0] != 0.0 && FamilyInfo[famid][FamilyEntrance][1] != 0.0)
  3777. {
  3778. new string[42];
  3779. FamilyInfo[famid][FamilyEntrancePickup] = CreateDynamicPickup(1318, 23, FamilyInfo[famid][FamilyEntrance][0], FamilyInfo[famid][FamilyEntrance][1], FamilyInfo[famid][FamilyEntrance][2]);
  3780. format(string, sizeof(string), "%s", FamilyInfo[famid][FamilyName]);
  3781. FamilyInfo[famid][FamilyEntranceText] = CreateDynamic3DTextLabel(string,COLOR_YELLOW,FamilyInfo[famid][FamilyEntrance][0], FamilyInfo[famid][FamilyEntrance][1], FamilyInfo[famid][FamilyEntrance][2]+0.6,4.0);
  3782. }
  3783. i++;
  3784. }
  3785. //LoadGangTags();
  3786. }
  3787.  
  3788. forward OnFamilyMemberCount(famid);
  3789. public OnFamilyMemberCount(famid)
  3790. {
  3791. new rows, fields;
  3792. cache_get_data(rows, fields, MainPipeline);
  3793. FamilyInfo[famid][FamilyMembers] = rows;
  3794. }
  3795.  
  3796. forward MailDeliveryTimer();
  3797. public MailDeliveryTimer()
  3798. {
  3799. mysql_function_query(MainPipeline, "UPDATE `letters` SET `Delivery_Min` = `Delivery_Min` - 1 WHERE `Delivery_Min` > 0", false, "OnQueryFinish", "i", SENDDATA_THREAD);
  3800. mysql_function_query(MainPipeline, "SELECT `Receiver_Id` FROM `letters` WHERE `Delivery_Min` = 1", true, "MailDeliveryQueryFinish", "");
  3801. return 1;
  3802. }
  3803.  
  3804. forward OnLoadGates();
  3805. public OnLoadGates()
  3806. {
  3807. new i, rows, fields, tmp[128];
  3808. cache_get_data(rows, fields, MainPipeline);
  3809.  
  3810. while(i < rows)
  3811. {
  3812. cache_get_field_content(i, "HID", tmp, MainPipeline); GateInfo[i][gHID] = strval(tmp);
  3813. cache_get_field_content(i, "Speed", tmp, MainPipeline); GateInfo[i][gSpeed] = floatstr(tmp);
  3814. CreateGate(i);
  3815. i++;
  3816. }
  3817. }
  3818.  
  3819. forward OnLoadDynamicMapIcon(index);
  3820. public OnLoadDynamicMapIcon(index)
  3821. {
  3822. new rows, fields, tmp[128];
  3823. cache_get_data(rows, fields, MainPipeline);
  3824.  
  3825. for(new row; row < rows; row++)
  3826. {
  3827. cache_get_field_content(row, "id", tmp, MainPipeline); DMPInfo[index][dmpSQLId] = strval(tmp);
  3828. if(DMPInfo[index][dmpMarkerType] != 0) DMPInfo[index][dmpMapIconID] = CreateDynamicMapIcon(DMPInfo[index][dmpPosX], DMPInfo[index][dmpPosY], DMPInfo[index][dmpPosZ], DMPInfo[index][dmpMarkerType], DMPInfo[index][dmpColor], DMPInfo[index][dmpVW], DMPInfo[index][dmpInt], -1, 500.0);
  3829. }
  3830. return 1;
  3831. }
  3832.  
  3833. forward OnLoadDynamicMapIcons();
  3834. public OnLoadDynamicMapIcons()
  3835. {
  3836. new i, rows, fields, tmp[128];
  3837. cache_get_data(rows, fields, MainPipeline);
  3838.  
  3839. while(i < rows)
  3840. {
  3841. cache_get_field_content(i, "id", tmp, MainPipeline); DMPInfo[i][dmpSQLId] = strval(tmp);
  3842. cache_get_field_content(i, "MarkerType", tmp, MainPipeline); DMPInfo[i][dmpMarkerType] = strval(tmp);
  3843. cache_get_field_content(i, "Color", tmp, MainPipeline); DMPInfo[i][dmpColor] = strval(tmp);
  3844. cache_get_field_content(i, "VW", tmp, MainPipeline); DMPInfo[i][dmpVW] = strval(tmp);
  3845. cache_get_field_content(i, "Int", tmp, MainPipeline); DMPInfo[i][dmpInt] = strval(tmp);
  3846. cache_get_field_content(i, "PosX", tmp, MainPipeline); DMPInfo[i][dmpPosX] = floatstr(tmp);
  3847. cache_get_field_content(i, "PosY", tmp, MainPipeline); DMPInfo[i][dmpPosY] = floatstr(tmp);
  3848. cache_get_field_content(i, "PosZ", tmp, MainPipeline); DMPInfo[i][dmpPosZ] = floatstr(tmp);
  3849. if(DMPInfo[i][dmpMarkerType] != 0) DMPInfo[i][dmpMapIconID] = CreateDynamicMapIcon(DMPInfo[i][dmpPosX], DMPInfo[i][dmpPosY], DMPInfo[i][dmpPosZ], DMPInfo[i][dmpMarkerType], DMPInfo[i][dmpColor], DMPInfo[i][dmpVW], DMPInfo[i][dmpInt], -1, 500.0);
  3850. i++;
  3851. }
  3852. if(i > 0) printf("[LoadDynamicMapIcons] %d map icons rehashed/loaded.", i);
  3853. else printf("[LoadDynamicMapIcons] Failed to load any map icons.");
  3854. return 1;
  3855. }
  3856.  
  3857. forward OnLoadDynamicDoor(index);
  3858. public OnLoadDynamicDoor(index)
  3859. {
  3860. new rows, fields, tmp[128];
  3861. cache_get_data(rows, fields, MainPipeline);
  3862.  
  3863. for(new row; row < rows; row++)
  3864. {
  3865. cache_get_field_content(rows, "id", tmp, MainPipeline); DDoorsInfo[index][ddSQLId] = strval(tmp);
  3866. cache_get_field_content(rows, "Description", DDoorsInfo[index][ddDescription], MainPipeline, 128);
  3867. cache_get_field_content(rows, "Owner", tmp, MainPipeline); DDoorsInfo[index][ddOwner] = strval(tmp);
  3868. cache_get_field_content(rows, "Locked", tmp, MainPipeline); DDoorsInfo[index][ddLocked] = strval(tmp);
  3869. if(strcmp(DDoorsInfo[index][ddDescription], "None", true) != 0) CreateDynamicDoor(index);
  3870. }
  3871. return 1;
  3872. }
  3873.  
  3874.  
  3875. forward OnLoadDynamicDoors();
  3876. public OnLoadDynamicDoors()
  3877. {
  3878. new i, rows, fields, tmp[128];
  3879. cache_get_data(rows, fields, MainPipeline);
  3880.  
  3881. while(i < rows)
  3882. {
  3883. cache_get_field_content(i, "id", tmp, MainPipeline); DDoorsInfo[i][ddSQLId] = strval(tmp);
  3884. cache_get_field_content(i, "Pass", DDoorsInfo[i][ddPass], MainPipeline, 24);
  3885. cache_get_field_content(i, "Locked", tmp, MainPipeline); DDoorsInfo[i][ddLocked] = strval(tmp);
  3886. if(strcmp(DDoorsInfo[i][ddDescription], "None", true) != 0) CreateDynamicDoor(i);
  3887. i++;
  3888. }
  3889. if(i > 0) printf("[LoadDynamicDoors] %d doors rehashed/loaded.", i);
  3890. else printf("[LoadDynamicDoors] Failed to load any doors.");
  3891. return 1;
  3892. }
  3893.  
  3894. forward OnLoadHouse(index);
  3895. public OnLoadHouse(index)
  3896. {
  3897. new rows, fields, szField[24], tmp[128];
  3898. cache_get_data(rows, fields, MainPipeline);
  3899.  
  3900. for(new row; row < rows; row++)
  3901. {
  3902. cache_get_field_content(row, "id", tmp, MainPipeline); HouseInfo[index][hSQLId] = strval(tmp);
  3903. cache_get_field_content(row, "Owned", tmp, MainPipeline); HouseInfo[index][hOwned] = strval(tmp);
  3904. cache_get_field_content(row, "Level", tmp, MainPipeline); HouseInfo[index][hLevel] = strval(tmp);
  3905. cache_get_field_content(row, "Value", tmp, MainPipeline); HouseInfo[index][hValue] = strval(tmp);
  3906. cache_get_field_content(row, "SafeMoney", tmp, MainPipeline); HouseInfo[index][hSafeMoney] = strval(tmp);
  3907. cache_get_field_content(row, "Pot", tmp, MainPipeline); HouseInfo[index][hPot] = strval(tmp);
  3908. cache_get_field_content(row, "Crack", tmp, MainPipeline); HouseInfo[index][hCrack] = strval(tmp);
  3909. cache_get_field_content(row, "Materials", tmp, MainPipeline); HouseInfo[index][hMaterials] = strval(tmp);
  3910. cache_get_field_content(row, "Heroin", tmp, MainPipeline); HouseInfo[index][hHeroin] = strval(tmp);
  3911. for(new i; i < 5; i++)
  3912. {
  3913. format(szField, sizeof(szField), "Weapons%d", i);
  3914. cache_get_field_content(row, szField, tmp, MainPipeline);
  3915. HouseInfo[index][hWeapons][i] = strval(tmp);
  3916. }
  3917. cache_get_field_content(row, "GLUpgrade", tmp, MainPipeline); HouseInfo[index][hGLUpgrade] = strval(tmp);
  3918. cache_get_field_content(row, "ClosetZ", tmp, MainPipeline); HouseInfo[index][hClosetZ] = floatstr(tmp);
  3919.  
  3920. ReloadHousePickup(index);
  3921. if(HouseInfo[index][hClosetX] != 0.0) HouseInfo[index][hClosetTextID] = CreateDynamic3DTextLabel("Closet\n/closet to use", 0xFFFFFF88, HouseInfo[index][hClosetX], HouseInfo[index][hClosetY], HouseInfo[index][hClosetZ]+0.5,10.0, .testlos = 1, .worldid = HouseInfo[index][hIntVW], .interiorid = HouseInfo[index][hIntIW], .streamdistance = 10.0);
  3922. if(HouseInfo[index][hMailX] != 0.0) RenderHouseMailbox(index);
  3923. }
  3924. return 1;
  3925. }
  3926.  
  3927. forward OnLoadHouses();
  3928. public OnLoadHouses()
  3929. {
  3930. new i, rows, fields, szField[24], tmp[128];
  3931. cache_get_data(rows, fields, MainPipeline);
  3932.  
  3933. while(i < rows)
  3934. {
  3935. cache_get_field_content(i, "id", tmp, MainPipeline); HouseInfo[i][hSQLId] = strval(tmp);
  3936. cache_get_field_content(i, "Owned", tmp, MainPipeline); HouseInfo[i][hOwned] = strval(tmp);
  3937. cache_get_field_content(i, "Level", tmp, MainPipeline); HouseInfo[i][hLevel] = strval(tmp);
  3938. cache_get_field_content(i, "Pot", tmp, MainPipeline); HouseInfo[i][hPot] = strval(tmp);
  3939. cache_get_field_content(i, "Crack", tmp, MainPipeline); HouseInfo[i][hCrack] = strval(tmp);
  3940. cache_get_field_content(i, "Materials", tmp, MainPipeline); HouseInfo[i][hMaterials] = strval(tmp);
  3941. cache_get_field_content(i, "Heroin", tmp, MainPipeline); HouseInfo[i][hHeroin] = strval(tmp);
  3942. for(new j; j < 5; j++)
  3943. {
  3944. format(szField, sizeof(szField), "Weapons%d", j);
  3945. cache_get_field_content(i, szField, tmp, MainPipeline);
  3946. HouseInfo[i][hWeapons][j] = strval(tmp);
  3947. }
  3948. cache_get_field_content(i, "GLUpgrade", tmp, MainPipeline); HouseInfo[i][hGLUpgrade] = strval(tmp);
  3949. cache_get_field_content(i, "ClosetZ", tmp, MainPipeline); HouseInfo[i][hClosetZ] = floatstr(tmp);
  3950.  
  3951. ReloadHousePickup(i);
  3952. if(HouseInfo[i][hClosetX] != 0.0) HouseInfo[i][hClosetTextID] = CreateDynamic3DTextLabel("Closet\n/closet to use", 0xFFFFFF88, HouseInfo[i][hClosetX], HouseInfo[i][hClosetY], HouseInfo[i][hClosetZ]+0.5,10.0, .testlos = 1, .worldid = HouseInfo[i][hIntVW], .interiorid = HouseInfo[i][hIntIW], .streamdistance = 10.0);
  3953. if(HouseInfo[i][hMailX] != 0.0) RenderHouseMailbox(i);
  3954. i++;
  3955. }
  3956. if(i > 0) printf("[LoadHouses] %d houses rehashed/loaded.", i);
  3957. else printf("[LoadHouses] Failed to load any houses.");
  3958. }
  3959.  
  3960. forward OnLoadMailboxes();
  3961. public OnLoadMailboxes()
  3962. {
  3963. new string[512], i;
  3964. new rows, fields;
  3965. cache_get_data(rows, fields, MainPipeline);
  3966. while(i<rows)
  3967. {
  3968. for(new field;field<fields;field++)
  3969. {
  3970. cache_get_row(i, field, string, MainPipeline);
  3971. switch(field)
  3972. {
  3973. case 1: MailBoxes[i][mbVW] = strval(string);
  3974. case 2: MailBoxes[i][mbInt] = strval(string);
  3975. case 3: MailBoxes[i][mbModel] = strval(string);
  3976. case 4: MailBoxes[i][mbPosX] = floatstr(string);
  3977. case 5: MailBoxes[i][mbPosY] = floatstr(string);
  3978. case 6: MailBoxes[i][mbPosZ] = floatstr(string);
  3979. case 7: MailBoxes[i][mbAngle] = floatstr(string);
  3980. }
  3981. }
  3982. RenderStreetMailbox(i);
  3983. i++;
  3984. }
  3985. if(i > 0) printf("[LoadMailboxes] %d mailboxes rehashed/loaded.", i);
  3986. else printf("[LoadMailboxes] Failed to load any mailboxes.");
  3987. return 1;
  3988. }
  3989.  
  3990. forward OnLoadSpeedCameras();
  3991. public OnLoadSpeedCameras()
  3992. {
  3993. new fields, rows, index, result[128];
  3994. cache_get_data(rows, fields, MainPipeline);
  3995.  
  3996. while ((index < rows))
  3997. {
  3998. cache_get_field_content(index, "id", result, MainPipeline); SpeedCameras[index][_scDatabase] = strval(result);
  3999. cache_get_field_content(index, "speed_limit", result, MainPipeline); SpeedCameras[index][_scLimit] = floatstr(result);
  4000.  
  4001. SpeedCameras[index][_scActive] = true;
  4002. SpeedCameras[index][_scObjectId] = -1;
  4003. SpawnSpeedCamera(index);
  4004.  
  4005. index++;
  4006. }
  4007.  
  4008. if (index == 0)
  4009. printf("[SpeedCameras] No Speed Cameras loaded.");
  4010. else
  4011. printf("[SpeedCameras] Loaded %i Speed Cameras.", index);
  4012.  
  4013. return 1;
  4014. }
  4015.  
  4016. forward OnNewSpeedCamera(index);
  4017. public OnNewSpeedCamera(index)
  4018. {
  4019. new db = mysql_insert_id(MainPipeline);
  4020. SpeedCameras[index][_scDatabase] = db;
  4021. }
  4022.  
  4023. // @returns
  4024. // ID of new speed cam on success, or -1 on failure
  4025.  
  4026. forward OnLoadTxtLabel(index);
  4027. public OnLoadTxtLabel(index)
  4028. {
  4029. new rows, fields, tmp[128];
  4030. cache_get_data(rows, fields, MainPipeline);
  4031.  
  4032. for(new row; row < rows; row++)
  4033. {
  4034. cache_get_field_content(row, "id", tmp, MainPipeline); TxtLabels[index][tlSQLId] = strval(tmp);
  4035. cache_get_field_content(row, "Text", TxtLabels[index][tlText], MainPipeline, 128);
  4036. cache_get_field_content(row, "PosX", tmp, MainPipeline); TxtLabels[index][tlPosX] = floatstr(tmp);
  4037. cache_get_field_content(row, "PosY", tmp, MainPipeline); TxtLabels[index][tlPosY] = floatstr(tmp);
  4038. cache_get_field_content(row, "PosZ", tmp, MainPipeline); TxtLabels[index][tlPosZ] = floatstr(tmp);
  4039. cache_get_field_content(row, "VW", tmp, MainPipeline); TxtLabels[index][tlVW] = strval(tmp);
  4040. cache_get_field_content(row, "Int", tmp, MainPipeline); TxtLabels[index][tlInt] = strval(tmp);
  4041. cache_get_field_content(row, "Color", tmp, MainPipeline); TxtLabels[index][tlColor] = strval(tmp);
  4042. cache_get_field_content(row, "PickupModel", tmp, MainPipeline); TxtLabels[index][tlPickupModel] = strval(tmp);
  4043. if(strcmp(TxtLabels[index][tlText], "None", true) != 0) CreateTxtLabel(index);
  4044. }
  4045. return 1;
  4046. }
  4047.  
  4048. forward OnLoadTxtLabels();
  4049. public OnLoadTxtLabels()
  4050. {
  4051. new i, rows, fields, tmp[128];
  4052. cache_get_data(rows, fields, MainPipeline);
  4053.  
  4054. while(i < rows)
  4055. {
  4056. cache_get_field_content(i, "id", tmp, MainPipeline); TxtLabels[i][tlSQLId] = strval(tmp);
  4057. cache_get_field_content(i, "Text", TxtLabels[i][tlText], MainPipeline, 128);
  4058. cache_get_field_content(i, "PosX", tmp, MainPipeline); TxtLabels[i][tlPosX] = floatstr(tmp);
  4059. cache_get_field_content(i, "PosY", tmp, MainPipeline); TxtLabels[i][tlPosY] = floatstr(tmp);
  4060. cache_get_field_content(i, "PosZ", tmp, MainPipeline); TxtLabels[i][tlPosZ] = floatstr(tmp);
  4061. cache_get_field_content(i, "VW", tmp, MainPipeline); TxtLabels[i][tlVW] = strval(tmp);
  4062. cache_get_field_content(i, "Int", tmp, MainPipeline); TxtLabels[i][tlInt] = strval(tmp);
  4063. cache_get_field_content(i, "Color", tmp, MainPipeline); TxtLabels[i][tlColor] = strval(tmp);
  4064. cache_get_field_content(i, "PickupModel", tmp, MainPipeline); TxtLabels[i][tlPickupModel] = strval(tmp);
  4065. if(strcmp(TxtLabels[i][tlText], "None", true) != 0) CreateTxtLabel(i);
  4066. i++;
  4067. }
  4068. }
  4069.  
  4070. forward OnLoadPayNSprays();
  4071. public OnLoadPayNSprays()
  4072. {
  4073. new i, rows, fields, tmp[128], string[128];
  4074. cache_get_data(rows, fields, MainPipeline);
  4075.  
  4076. while(i < rows)
  4077. {
  4078. cache_get_field_content(i, "id", tmp, MainPipeline); PayNSprays[i][pnsSQLId] = strval(tmp);
  4079. cache_get_field_content(i, "Status", tmp, MainPipeline); PayNSprays[i][pnsStatus] = strval(tmp);
  4080. cache_get_field_content(i, "PosX", tmp, MainPipeline); PayNSprays[i][pnsPosX] = floatstr(tmp);
  4081. cache_get_field_content(i, "PosY", tmp, MainPipeline); PayNSprays[i][pnsPosY] = floatstr(tmp);
  4082. cache_get_field_content(i, "PosZ", tmp, MainPipeline); PayNSprays[i][pnsPosZ] = floatstr(tmp);
  4083. cache_get_field_content(i, "VW", tmp, MainPipeline); PayNSprays[i][pnsVW] = strval(tmp);
  4084. cache_get_field_content(i, "Int", tmp, MainPipeline); PayNSprays[i][pnsInt] = strval(tmp);
  4085. cache_get_field_content(i, "GroupCost", tmp, MainPipeline); PayNSprays[i][pnsGroupCost] = strval(tmp);
  4086. cache_get_field_content(i, "RegCost", tmp, MainPipeline); PayNSprays[i][pnsRegCost] = strval(tmp);
  4087. if(PayNSprays[i][pnsStatus] > 0)
  4088. {
  4089. format(string, sizeof(string), "/repaircar\nRepair Cost -- Regular: $%s | Faction: $%s\nID: %d", number_format(PayNSprays[i][pnsRegCost]), number_format(PayNSprays[i][pnsGroupCost]), i);
  4090. PayNSprays[i][pnsTextID] = CreateDynamic3DTextLabel(string, COLOR_RED, PayNSprays[i][pnsPosX], PayNSprays[i][pnsPosY], PayNSprays[i][pnsPosZ]+0.5,10.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, PayNSprays[i][pnsVW], PayNSprays[i][pnsInt], -1);
  4091. PayNSprays[i][pnsPickupID] = CreateDynamicPickup(1239, 23, PayNSprays[i][pnsPosX], PayNSprays[i][pnsPosY], PayNSprays[i][pnsPosZ], PayNSprays[i][pnsVW]);
  4092. PayNSprays[i][pnsMapIconID] = CreateDynamicMapIcon(PayNSprays[i][pnsPosX], PayNSprays[i][pnsPosY], PayNSprays[i][pnsPosZ], 63, 0, PayNSprays[i][pnsVW], PayNSprays[i][pnsInt], -1, 500.0);
  4093. }
  4094. i++;
  4095. }
  4096. }
  4097.  
  4098. forward OnLoadArrestPoint(index);
  4099. public OnLoadArrestPoint(index)
  4100. {
  4101. new rows, fields, tmp[128], string[128];
  4102. cache_get_data(rows, fields, MainPipeline);
  4103.  
  4104. for(new row; row < rows; row++)
  4105. {
  4106. cache_get_field_content(row, "id", tmp, MainPipeline); ArrestPoints[index][arrestSQLId] = strval(tmp);
  4107. cache_get_field_content(row, "PosX", tmp, MainPipeline); ArrestPoints[index][arrestPosX] = floatstr(tmp);
  4108. cache_get_field_content(row, "PosY", tmp, MainPipeline); ArrestPoints[index][arrestPosY] = floatstr(tmp);
  4109. cache_get_field_content(row, "PosZ", tmp, MainPipeline); ArrestPoints[index][arrestPosZ] = floatstr(tmp);
  4110. cache_get_field_content(row, "VW", tmp, MainPipeline); ArrestPoints[index][arrestVW] = strval(tmp);
  4111. cache_get_field_content(row, "Int", tmp, MainPipeline); ArrestPoints[index][arrestInt] = strval(tmp);
  4112. cache_get_field_content(row, "Type", tmp, MainPipeline); ArrestPoints[index][arrestType] = strval(tmp);
  4113. if(ArrestPoints[index][arrestPosX] != 0)
  4114. {
  4115. switch(ArrestPoints[index][arrestType])
  4116. {
  4117. case 0:
  4118. {
  4119. format(string, sizeof(string), "/arrest\nArrest Point #%d", index);
  4120. ArrestPoints[index][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[index][arrestVW], ArrestPoints[index][arrestInt], -1);
  4121. ArrestPoints[index][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ], ArrestPoints[index][arrestVW]);
  4122. }
  4123. case 2:
  4124. {
  4125. format(string, sizeof(string), "/docarrest\nArrest Point #%d", index);
  4126. ArrestPoints[index][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[index][arrestVW], ArrestPoints[index][arrestInt], -1);
  4127. ArrestPoints[index][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ], ArrestPoints[index][arrestVW]);
  4128. }
  4129. case 3:
  4130. {
  4131. format(string, sizeof(string), "/warrantarrest\nArrest Point #%d", index);
  4132. ArrestPoints[index][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[index][arrestVW], ArrestPoints[index][arrestInt], -1);
  4133. ArrestPoints[index][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ], ArrestPoints[index][arrestVW]);
  4134. }
  4135. case 4:
  4136. {
  4137. format(string, sizeof(string), "/jarrest\nArrest Point #%d", index);
  4138. ArrestPoints[index][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[index][arrestVW], ArrestPoints[index][arrestInt], -1);
  4139. ArrestPoints[index][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[index][arrestPosX], ArrestPoints[index][arrestPosY], ArrestPoints[index][arrestPosZ], ArrestPoints[index][arrestVW]);
  4140. }
  4141. }
  4142. }
  4143. }
  4144. return 1;
  4145. }
  4146.  
  4147. forward OnLoadArrestPoints();
  4148. public OnLoadArrestPoints()
  4149. {
  4150. new i, rows, fields, tmp[128], string[128];
  4151. cache_get_data(rows, fields, MainPipeline);
  4152.  
  4153. while(i < rows)
  4154. {
  4155. cache_get_field_content(i, "id", tmp, MainPipeline); ArrestPoints[i][arrestSQLId] = strval(tmp);
  4156. cache_get_field_content(i, "PosX", tmp, MainPipeline); ArrestPoints[i][arrestPosX] = floatstr(tmp);
  4157. cache_get_field_content(i, "PosY", tmp, MainPipeline); ArrestPoints[i][arrestPosY] = floatstr(tmp);
  4158. cache_get_field_content(i, "PosZ", tmp, MainPipeline); ArrestPoints[i][arrestPosZ] = floatstr(tmp);
  4159. cache_get_field_content(i, "VW", tmp, MainPipeline); ArrestPoints[i][arrestVW] = strval(tmp);
  4160. cache_get_field_content(i, "Int", tmp, MainPipeline); ArrestPoints[i][arrestInt] = strval(tmp);
  4161. cache_get_field_content(i, "Type", tmp, MainPipeline); ArrestPoints[i][arrestType] = strval(tmp);
  4162. if(ArrestPoints[i][arrestPosX] != 0)
  4163. {
  4164. switch(ArrestPoints[i][arrestType])
  4165. {
  4166. case 0:
  4167. {
  4168. format(string, sizeof(string), "/arrest\nArrest Point #%d", i);
  4169. ArrestPoints[i][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[i][arrestVW], ArrestPoints[i][arrestInt], -1);
  4170. ArrestPoints[i][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ], ArrestPoints[i][arrestVW]);
  4171. }
  4172. case 2:
  4173. {
  4174. format(string, sizeof(string), "/docarrest\nArrest Point #%d", i);
  4175. ArrestPoints[i][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[i][arrestVW], ArrestPoints[i][arrestInt], -1);
  4176. ArrestPoints[i][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ], ArrestPoints[i][arrestVW]);
  4177. }
  4178. case 3:
  4179. {
  4180. format(string, sizeof(string), "/warrantarrest\nArrest Point #%d", i);
  4181. ArrestPoints[i][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[i][arrestVW], ArrestPoints[i][arrestInt], -1);
  4182. ArrestPoints[i][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ], ArrestPoints[i][arrestVW]);
  4183. }
  4184. case 4:
  4185. {
  4186. format(string, sizeof(string), "/jarrest\nArrest Point #%d", i);
  4187. ArrestPoints[i][arrestTextID] = CreateDynamic3DTextLabel(string, COLOR_DBLUE, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ]+0.6, 4.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ArrestPoints[i][arrestVW], ArrestPoints[i][arrestInt], -1);
  4188. ArrestPoints[i][arrestPickupID] = CreateDynamicPickup(1247, 23, ArrestPoints[i][arrestPosX], ArrestPoints[i][arrestPosY], ArrestPoints[i][arrestPosZ], ArrestPoints[i][arrestVW]);
  4189. }
  4190. }
  4191. }
  4192. i++;
  4193. }
  4194. }
  4195.  
  4196. forward OnLoadImpoundPoint(index);
  4197. public OnLoadImpoundPoint(index)
  4198. {
  4199. new rows, fields, tmp[128], string[128];
  4200. cache_get_data(rows, fields, MainPipeline);
  4201.  
  4202. for(new row; row < rows; row++)
  4203. {
  4204. cache_get_field_content(row, "id", tmp, MainPipeline); ImpoundPoints[index][impoundSQLId] = strval(tmp);
  4205. cache_get_field_content(row, "PosX", tmp, MainPipeline); ImpoundPoints[index][impoundPosX] = floatstr(tmp);
  4206. cache_get_field_content(row, "PosY", tmp, MainPipeline); ImpoundPoints[index][impoundPosY] = floatstr(tmp);
  4207. cache_get_field_content(row, "PosZ", tmp, MainPipeline); ImpoundPoints[index][impoundPosZ] = floatstr(tmp);
  4208. cache_get_field_content(row, "VW", tmp, MainPipeline); ImpoundPoints[index][impoundVW] = strval(tmp);
  4209. cache_get_field_content(row, "Int", tmp, MainPipeline); ImpoundPoints[index][impoundInt] = strval(tmp);
  4210. if(ImpoundPoints[index][impoundPosX] != 0)
  4211. {
  4212. format(string, sizeof(string), "Impound Yard #%d\nType /impound to impound a vehicle", index);
  4213. ImpoundPoints[index][impoundTextID] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, ImpoundPoints[index][impoundPosX], ImpoundPoints[index][impoundPosY], ImpoundPoints[index][impoundPosZ]+0.6, 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ImpoundPoints[index][impoundVW], ImpoundPoints[index][impoundInt], -1);
  4214. }
  4215. }
  4216. return 1;
  4217. }
  4218.  
  4219. forward OnLoadImpoundPoints();
  4220. public OnLoadImpoundPoints()
  4221. {
  4222. new i, rows, fields, tmp[128], string[128];
  4223. cache_get_data(rows, fields, MainPipeline);
  4224.  
  4225. while(i < rows)
  4226. {
  4227. cache_get_field_content(i, "id", tmp, MainPipeline); ImpoundPoints[i][impoundSQLId] = strval(tmp);
  4228. cache_get_field_content(i, "Int", tmp, MainPipeline); ImpoundPoints[i][impoundInt] = strval(tmp);
  4229. if(ImpoundPoints[i][impoundPosX] != 0)
  4230. {
  4231. format(string, sizeof(string), "Impound Yard #%d\nType /impound to impound a vehicle", i);
  4232. ImpoundPoints[i][impoundTextID] = CreateDynamic3DTextLabel(string, COLOR_YELLOW, ImpoundPoints[i][impoundPosX], ImpoundPoints[i][impoundPosY], ImpoundPoints[i][impoundPosZ]+0.6, 5.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1, ImpoundPoints[i][impoundVW], ImpoundPoints[i][impoundInt], -1);
  4233. }
  4234. i++;
  4235. }
  4236. }
  4237.  
  4238. forward LoadDynamicGroups();
  4239. public LoadDynamicGroups()
  4240. {
  4241. mysql_function_query(MainPipeline, "SELECT * FROM `groups`", true, "Group_QueryFinish", "ii", GROUP_QUERY_LOAD, 0);
  4242. mysql_function_query(MainPipeline, "SELECT * FROM `lockers`", true, "Group_QueryFinish", "ii", GROUP_QUERY_LOCKERS, 0);
  4243. mysql_function_query(MainPipeline, "SELECT * FROM `jurisdictions`", true, "Group_QueryFinish", "ii", GROUP_QUERY_JURISDICTIONS, 0);
  4244. return ;
  4245. }
  4246.  
  4247. forward LoadDynamicGroupVehicles();
  4248. public LoadDynamicGroupVehicles()
  4249. {
  4250. mysql_function_query(MainPipeline, "SELECT * FROM `groupvehs`", true, "DynVeh_QueryFinish", "ii", GV_QUERY_LOAD, 0);
  4251. return 1;
  4252. }
  4253.  
  4254. forward ParkRentedVehicle(playerid, vehicleid, modelid, Float:X, Float:Y, Float:Z);
  4255. public ParkRentedVehicle(playerid, vehicleid, modelid, Float:X, Float:Y, Float:Z)
  4256. {
  4257. if(IsPlayerInRangeOfPoint(playerid, 1.0, X, Y, Z))
  4258. {
  4259. new Float:x, Float:y, Float:z, Float:angle, Float:health, string[180], Float: oldfuel, arrDamage[4];
  4260. GetVehicleHealth(vehicleid, health);
  4261. if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessageEx(playerid, COLOR_GREY, "You must be in the driver seat.");
  4262. if(health < 800) return SendClientMessageEx(playerid, COLOR_GREY, " Your vehicle is too damaged to park it.");
  4263.  
  4264. GetVehiclePos(vehicleid, x, y, z);
  4265. GetVehicleZAngle(vehicleid, angle);
  4266. SurfingCheck(vehicleid);
  4267. oldfuel = VehicleFuel[vehicleid];
  4268.  
  4269. GetVehicleDamageStatus(vehicleid, arrDamage[0], arrDamage[1], arrDamage[2], arrDamage[3]);
  4270. DestroyVehicle(GetPVarInt(playerid, "RentedVehicle"));
  4271. SetPVarInt(playerid, "RentedVehicle", CreateVehicle(modelid, x, y, z, angle, random(128), random(128), 2000000));
  4272. Vehicle_ResetData(GetPVarInt(playerid, "RentedVehicle"));
  4273. VehicleFuel[GetPVarInt(playerid, "RentedVehicle")] = oldfuel;
  4274. SetVehicleHealth(GetPVarInt(playerid, "RentedVehicle"), health);
  4275. UpdateVehicleDamageStatus(vehicleid, arrDamage[0], arrDamage[1], arrDamage[2], arrDamage[3]);
  4276.  
  4277. format(string, sizeof(string), "UPDATE `rentedcars` SET `posx` = '%f', `posy` = '%f', `posz` = '%f', `posa` = '%f' WHERE `sqlid` = '%d'", x, y, z, angle, GetPlayerSQLId(playerid));
  4278. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  4279.  
  4280. IsPlayerEntering{playerid} = true;
  4281. PutPlayerInVehicle(playerid, vehicleid, 0);
  4282. SetPlayerArmedWeapon(playerid, 0);
  4283. format(string, sizeof(string), "* %s has parked their vehicle.", GetPlayerNameEx(playerid));
  4284. ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
  4285.  
  4286. }
  4287. else
  4288. {
  4289. SendClientMessage(playerid, COLOR_WHITE, "Vehicle did not park because you moved!");
  4290. }
  4291. return 1;
  4292. }
  4293.  
  4294. forward OnPlayerChangePass(index);
  4295. public OnPlayerChangePass(index)
  4296. {
  4297. if(mysql_affected_rows(MainPipeline)) {
  4298.  
  4299. new
  4300. szBuffer[129],
  4301. szMessage[103];
  4302.  
  4303. GetPVarString(index, "PassChange", szBuffer, sizeof(szBuffer));
  4304. format(szMessage, sizeof(szMessage), "You have changed your password to '%s'.", szBuffer);
  4305. SendClientMessageEx(index, COLOR_YELLOW, szMessage);
  4306.  
  4307. format(szMessage, sizeof(szMessage), "%s (IP: %s) has changed their password.", GetPlayerNameEx(index), PlayerInfo[index][pIP]);
  4308. Log("logs/password.log", szMessage);
  4309. DeletePVar(index, "PassChange");
  4310.  
  4311. if(PlayerInfo[index][pForcePasswordChange] == 1)
  4312. {
  4313. PlayerInfo[index][pForcePasswordChange] = 0;
  4314. format(szMessage, sizeof(szMessage), "UPDATE `accounts` SET `ForcePasswordChange` = '0' WHERE `id` = '%i'", PlayerInfo[index][pId]);
  4315. mysql_function_query(MainPipeline, szMessage, false, "OnQueryFinish", "ii", SENDDATA_THREAD, index);
  4316. }
  4317. }
  4318. else SendClientMessageEx(index, COLOR_RED, "There was an issue with processing your request. Your password will remain as it is.");
  4319. return 1;
  4320. }
  4321.  
  4322. forward OnChangeUserPassword(index);
  4323. public OnChangeUserPassword(index)
  4324. {
  4325. if(GetPVarType(index, "ChangePin"))
  4326. {
  4327. new string[128], name[24];
  4328. GetPVarString(index, "OnChangeUserPassword", name, 24);
  4329.  
  4330. if(mysql_affected_rows(MainPipeline)) {
  4331. format(string, sizeof(string), "You have successfully changed %s's pin.", name);
  4332. SendClientMessageEx(index, COLOR_WHITE, string);
  4333. }
  4334. else {
  4335. format(string, sizeof(string), "There was an issue with changing %s's pin.", name);
  4336. SendClientMessageEx(index, COLOR_WHITE, string);
  4337. }
  4338. DeletePVar(index, "ChangePin");
  4339. DeletePVar(index, "OnChangeUserPassword");
  4340. }
  4341. else
  4342. {
  4343. new string[128], name[24];
  4344. GetPVarString(index, "OnChangeUserPassword", name, 24);
  4345.  
  4346. if(mysql_affected_rows(MainPipeline)) {
  4347. format(string, sizeof(string), "You have successfully changed %s's password.", name);
  4348. SendClientMessageEx(index, COLOR_WHITE, string);
  4349. }
  4350. else {
  4351. format(string, sizeof(string), "There was an issue with changing %s's password.", name);
  4352. SendClientMessageEx(index, COLOR_WHITE, string);
  4353. }
  4354. DeletePVar(index, "OnChangeUserPassword");
  4355. }
  4356. return 1;
  4357. }
  4358.  
  4359. forward QueryCheckCountFinish(playerid, giveplayername[], tdate[], type);
  4360. public QueryCheckCountFinish(playerid, giveplayername[], tdate[], type)
  4361. {
  4362. new string[128], rows, fields, sResult[24], tcount, hhour[9], chour;
  4363. cache_get_data(rows, fields, MainPipeline);
  4364.  
  4365. switch(type)
  4366. {
  4367. case 0:
  4368. {
  4369. cache_get_field_content(0, "SUM(count)", sResult, MainPipeline); tcount = strval(sResult);
  4370. if(tcount > 0)
  4371. {
  4372. format(string, sizeof(string), "%s accepted {%06x}%d {%06x}reports on %s.", giveplayername, COLOR_GREEN >>> 8, tcount, COLOR_WHITE >>> 8, tdate);
  4373. SendClientMessageEx(playerid, COLOR_WHITE, string);
  4374. }
  4375. else
  4376. {
  4377. format(string, sizeof(string), "%s did not accept any reports on %s.", giveplayername, tdate);
  4378. return SendClientMessageEx(playerid, COLOR_GRAD1, string);
  4379. }
  4380. }
  4381. case 1:
  4382. {
  4383. if(rows > 0)
  4384. {
  4385. SendClientMessageEx(playerid, COLOR_GRAD1, "By hour:");
  4386. for(new i; i < rows; i++)
  4387. {
  4388. cache_get_field_content(i, "count", sResult, MainPipeline); new hcount = strval(sResult);
  4389. cache_get_field_content(i, "hour", hhour, MainPipeline, sizeof(hhour));
  4390. format(hhour, sizeof(hhour), "%s", str_replace(":00:00", "", hhour));
  4391. chour = strval(hhour);
  4392. format(string, sizeof(string), "%s: {%06x}%d", ConvertToTwelveHour(chour), COLOR_GREEN >>> 8, hcount);
  4393. SendClientMessageEx(playerid, COLOR_WHITE, string);
  4394. }
  4395. }
  4396. }
  4397. case 2:
  4398. {
  4399. cache_get_field_content(0, "SUM(count)", sResult, MainPipeline); tcount = strval(sResult);
  4400. if(tcount > 0)
  4401. {
  4402. format(string, sizeof(string), "%s accepted {%06x}%d {%06x}help requests on %s.", giveplayername, COLOR_GREEN >>> 8, tcount, COLOR_WHITE >>> 8, tdate);
  4403. SendClientMessageEx(playerid, COLOR_WHITE, string);
  4404. }
  4405. else
  4406. {
  4407. format(string, sizeof(string), "%s did not accept any help requests on %s.", giveplayername, tdate);
  4408. return SendClientMessageEx(playerid, COLOR_GRAD1, string);
  4409. }
  4410. }
  4411. case 3:
  4412. {
  4413. if(rows > 0)
  4414. {
  4415. SendClientMessageEx(playerid, COLOR_GRAD1, "By hour:");
  4416. for(new i; i < rows; i++)
  4417. {
  4418. cache_get_field_content(i, "count", sResult, MainPipeline); new hcount = strval(sResult);
  4419. cache_get_field_content(i, "hour", hhour, MainPipeline, sizeof(hhour));
  4420. format(hhour, sizeof(hhour), "%s", str_replace(":00:00", "", hhour));
  4421. chour = strval(hhour);
  4422. format(string, sizeof(string), "%s: {%06x}%d", ConvertToTwelveHour(chour), COLOR_GREEN >>> 8, hcount);
  4423. SendClientMessageEx(playerid, COLOR_WHITE, string);
  4424. }
  4425. }
  4426. }
  4427. }
  4428. return 1;
  4429. }
  4430.  
  4431. forward QueryUsernameCheck(playerid, tdate[], type);
  4432. public QueryUsernameCheck(playerid, tdate[], type)
  4433. {
  4434. new string[128], rows, fields, giveplayerid, sResult[MAX_PLAYER_NAME];
  4435. cache_get_data(rows, fields, MainPipeline);
  4436.  
  4437. if(rows > 0)
  4438. {
  4439. switch(type)
  4440. {
  4441. case 0:
  4442. {
  4443. cache_get_field_content(0, "id", sResult, MainPipeline); giveplayerid = strval(sResult);
  4444. cache_get_field_content(0, "Username", sResult, MainPipeline, sizeof(sResult));
  4445. format(string, sizeof(string), "SELECT SUM(count) FROM `tokens_report` WHERE `playerid` = %d AND `date` = '%s'", giveplayerid, tdate);
  4446. mysql_function_query(MainPipeline, string, true, "QueryCheckCountFinish", "issi", playerid, sResult, tdate, 0);
  4447. format(string, sizeof(string), "SELECT `count`, `hour` FROM `tokens_report` WHERE `playerid` = %d AND `date` = '%s' ORDER BY `hour` ASC", giveplayerid, tdate);
  4448. mysql_function_query(MainPipeline, string, true, "QueryCheckCountFinish", "issi", playerid, sResult, tdate, 1);
  4449. }
  4450. case 1:
  4451. {
  4452. cache_get_field_content(0, "id", sResult, MainPipeline); giveplayerid = strval(sResult);
  4453. cache_get_field_content(0, "Username", sResult, MainPipeline, sizeof(sResult));
  4454. format(string, sizeof(string), "SELECT SUM(count) FROM `tokens_request` WHERE `playerid` = %d AND `date` = '%s'", giveplayerid, tdate);
  4455. mysql_function_query(MainPipeline, string, true, "QueryCheckCountFinish", "issi", playerid, sResult, tdate, 2);
  4456. format(string, sizeof(string), "SELECT `count`, `hour` FROM `tokens_request` WHERE `playerid` = %d AND `date` = '%s' ORDER BY `hour` ASC", giveplayerid, tdate);
  4457. mysql_function_query(MainPipeline, string, true, "QueryCheckCountFinish", "issi", playerid, sResult, tdate, 3);
  4458. }
  4459. }
  4460. }
  4461. else return SendClientMessageEx(playerid, COLOR_GRAD1, "That account doesn't exist!");
  4462. return 1;
  4463. }
  4464.  
  4465. forward OnBanPlayer(index);
  4466. public OnBanPlayer(index)
  4467. {
  4468. new string[128], name[24], reason[64];
  4469. GetPVarString(index, "OnBanPlayer", name, 24);
  4470. GetPVarString(index, "OnBanPlayerReason", reason, 64);
  4471.  
  4472. if(IsPlayerConnected(index))
  4473. {
  4474. if(mysql_affected_rows(MainPipeline)) {
  4475. format(string, sizeof(string), "You have successfully banned %s's account.", name);
  4476. SendClientMessageEx(index, COLOR_WHITE, string);
  4477.  
  4478. format(string, sizeof(string), "AdmCmd: %s was offline banned by %s, reason: %s", name, GetPlayerNameEx(index), reason);
  4479. Log("logs/ban.log", string);
  4480. format(string, 128, "AdmCmd: %s was offline banned by %s, reason: %s", name, GetPlayerNameEx(index), reason);
  4481. ABroadCast(COLOR_LIGHTRED,string,2);
  4482. print(string);
  4483. }
  4484. else {
  4485. format(string, sizeof(string), "There was an issue with banning %s's account.", name);
  4486. SendClientMessageEx(index, COLOR_WHITE, string);
  4487. }
  4488. DeletePVar(index, "OnBanPlayer");
  4489. DeletePVar(index, "OnBanPlayerReason");
  4490. }
  4491. return 1;
  4492. }
  4493.  
  4494. forward OnBanIP(index);
  4495. public OnBanIP(index)
  4496. {
  4497. if(IsPlayerConnected(index))
  4498. {
  4499. new rows, fields;
  4500. new string[128], ip[32], sqlid[5], id;
  4501. cache_get_data(rows, fields, MainPipeline);
  4502.  
  4503. if(rows)
  4504. {
  4505. cache_get_field_content(0, "id", sqlid, MainPipeline); id = strval(sqlid);
  4506. cache_get_field_content(0, "IP", ip, MainPipeline, 16);
  4507.  
  4508. MySQLBan(id, ip, "Offline Banned (/banaccount)", 1, GetPlayerNameEx(index));
  4509.  
  4510. format(string, sizeof(string), "INSERT INTO `ip_bans` (`ip`, `date`, `reason`, `admin`) VALUES ('%s', NOW(), '%s', '%s')", ip, "Offline Banned", GetPlayerNameEx(index));
  4511. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  4512. }
  4513. }
  4514. return 1;
  4515. }
  4516.  
  4517. forward OnUnbanPlayer(index);
  4518. public OnUnbanPlayer(index)
  4519. {
  4520. new string[128], name[24];
  4521. GetPVarString(index, "OnUnbanPlayer", name, 24);
  4522.  
  4523. if(mysql_affected_rows(MainPipeline)) {
  4524. format(string, sizeof(string), "You have successfully unbanned %s's account.", name);
  4525. SendClientMessageEx(index, COLOR_WHITE, string);
  4526.  
  4527. format(string, 128, "AdmCmd: %s was unbanned by %s.", name, GetPlayerNameEx(index));
  4528. ABroadCast(COLOR_LIGHTRED,string,2);
  4529. format(string, sizeof(string), "AdmCmd: %s was unbanned by %s.", name, GetPlayerNameEx(index));
  4530. Log("logs/ban.log", string);
  4531. print(string);
  4532. }
  4533. else {
  4534. format(string, sizeof(string), "There was an issue with unbanning %s's account.", name);
  4535. SendClientMessageEx(index, COLOR_WHITE, string);
  4536. }
  4537. DeletePVar(index, "OnUnbanPlayer");
  4538.  
  4539. return 1;
  4540. }
  4541.  
  4542. forward OnUnbanIP(index);
  4543. public OnUnbanIP(index)
  4544. {
  4545. if(IsPlayerConnected(index))
  4546. {
  4547. new string[128], ip[16];
  4548. new rows, fields;
  4549. cache_get_data(rows, fields, MainPipeline);
  4550. if(rows) {
  4551. cache_get_field_content(0, "IP", ip, MainPipeline, 16);
  4552. RemoveBan(index, ip);
  4553.  
  4554. format(string, sizeof(string), "UPDATE `bans` SET `status` = 4, `date_unban` = NOW() WHERE `ip_address` = '%s'", ip);
  4555. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  4556. }
  4557. }
  4558. return 1;
  4559. }
  4560.  
  4561. // Use this for generic "You have successfully altered X's account" messages... no need for 578947 public functions!
  4562. forward Query_OnExecution(iTargetID);
  4563. public Query_OnExecution(iTargetID) {
  4564.  
  4565. new
  4566. szName[MAX_PLAYER_NAME],
  4567. szMessage[64];
  4568.  
  4569. GetPVarString(iTargetID, "QueryEx_Name", szName, sizeof szName);
  4570. if(mysql_affected_rows(MainPipeline)) {
  4571. format(szMessage, sizeof szMessage, "The query on %s's account was successful.", szName);
  4572. SendClientMessageEx(iTargetID, COLOR_WHITE, szMessage);
  4573. }
  4574. else {
  4575. format(szMessage, sizeof szMessage, "The query on %s's account was unsuccessful.", szName);
  4576. SendClientMessageEx(iTargetID, COLOR_WHITE, szMessage);
  4577. }
  4578. return DeletePVar(iTargetID, "QueryEx_Name");
  4579. }
  4580.  
  4581. forward OnSetSuspended(index, value);
  4582. public OnSetSuspended(index, value)
  4583. {
  4584. new string[128], name[24];
  4585. GetPVarString(index, "OnSetSuspended", name, 24);
  4586.  
  4587. if(mysql_affected_rows(MainPipeline)) {
  4588. format(string, sizeof(string), "You have successfully %s %s's account.", ((value) ? ("suspended") : ("unsuspended")), name);
  4589. SendClientMessageEx(index, COLOR_WHITE, string);
  4590.  
  4591. format(string, sizeof(string), "AdmCmd: %s was offline %s by %s.", name, ((value) ? ("suspended") : ("unsuspended")), GetPlayerNameEx(index));
  4592. Log("logs/admin.log", string);
  4593. }
  4594. else {
  4595. format(string, sizeof(string), "There was an issue with %s %s's account.", ((value) ? ("suspending") : ("unsuspending")), name);
  4596. SendClientMessageEx(index, COLOR_WHITE, string);
  4597. }
  4598. DeletePVar(index, "OnSetSuspended");
  4599.  
  4600. return 1;
  4601. }
  4602. /*#if defined SHOPAUTOMATED
  4603. forward OnShopOrder(index);
  4604. public OnShopOrder(index)
  4605. {
  4606. if(IsPlayerConnected(index))
  4607. {
  4608. HideNoticeGUIFrame(index);
  4609. new rows, fields;
  4610. cache_get_data(rows, fields, ShopPipeline);
  4611. if(rows > 0)
  4612. {
  4613. new string[512];
  4614. new ipsql[16], ip[16];
  4615. GetPlayerIp(index, ip, sizeof(ip));
  4616. mysql_fetch_field_row(ipsql, "ip", MainPipeline);
  4617. cache_get_field_content(0, "ip", ipsql, ShopPipeline);
  4618. if(!isnull(ipsql) && strcmp(ipsql, ip, true) == 0)
  4619. {
  4620. new status[2], name[64], quantity[8], delivered[8], product_id[8];
  4621. for(new i;i<rows;i++)
  4622. {
  4623. cache_get_field_content(i, "order_status_id", status, ShopPipeline);
  4624. if(strval(status) == 2)
  4625. {
  4626. cache_get_field_content(i, "name", name, ShopPipeline);
  4627. cache_get_field_content(i, "quantity", quantity, ShopPipeline);
  4628. cache_get_field_content(i, "delivered", delivered, ShopPipeline);
  4629. cache_get_field_content(i, "order_product_id", product_id, ShopPipeline);
  4630. if(strval(quantity)-strval(delivered) <= 0)
  4631. {
  4632. if(i<rows) format(string, sizeof(string), "%s%s (Delivered)\n", string, name);
  4633. else format(string, sizeof(string), "%s%s (Delivered)", string, name);
  4634. }
  4635. else
  4636. {
  4637. if(i<rows) format(string, sizeof(string), "%s%s (%d)\n", string, name, strval(quantity)-strval(delivered));
  4638. else format(string, sizeof(string), "%s%s (%d)", string, name, strval(quantity)-strval(delivered));
  4639. }
  4640. }
  4641. else
  4642. {
  4643. new reason[27];
  4644. switch(strval(status))
  4645. {
  4646. case 0: format(reason, sizeof(reason), "{FF0000}No Payment");
  4647. case 1: format(reason, sizeof(reason), "{FF0000}Pending");
  4648. case 3: format(reason, sizeof(reason), "{00FF00}Shipped");
  4649. case 5:
  4650. {
  4651. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", "This order has already been delivered", "OK", "");
  4652. return 1;
  4653. }
  4654. case 7: format(reason, sizeof(reason), "{FF0000}Cancelled");
  4655. case 8: format(reason, sizeof(reason), "{FF0000}Denied");
  4656. case 9: format(reason, sizeof(reason), "{FF0000}Cancelled Reversal");
  4657. case 10: format(reason, sizeof(reason), "{FF0000}Failed");
  4658. case 11: format(reason, sizeof(reason), "{00FF00}Refundend");
  4659. case 12: format(reason, sizeof(reason), "{FF0000}Reversed");
  4660. case 13: format(reason, sizeof(reason), "{FF0000}Chargeback");
  4661. default: format(reason, sizeof(reason), "{FF0000}Unknown");
  4662. }
  4663. format(string, sizeof(string), "We are unable to process that order at this time,\nbecause the payment is currently marked as: %s", reason);
  4664. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", string, "OK", "");
  4665. return 1;
  4666. }
  4667. }
  4668. }
  4669. else
  4670. {
  4671. new email[256];
  4672. cache_get_field_content(0, "email", email, ShopPipeline);
  4673. SetPVarString(index, "ShopEmailVerify", email);
  4674. ShowPlayerDialog(index, DIALOG_SHOPORDEREMAIL, DIALOG_STYLE_INPUT, "Shop Order Error", "We were unable to link your order to your IP,\nfor further verification of your identity please input your shop e-mail address:", "Submit", "Cancel");
  4675. return 1;
  4676. }
  4677. ShowPlayerDialog(index, DIALOG_SHOPORDER2, DIALOG_STYLE_LIST, "Shop Order List", string, "Select", "Cancel");
  4678. }
  4679. else
  4680. {
  4681. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", "Error: No orders were found by that Order ID\nIf you are sure that is the correct Order ID, please try again or input '1' for your order ID.", "OK", "");
  4682. }
  4683. }
  4684. return 1;
  4685. }
  4686.  
  4687. forward OnShopOrderEmailVer(index);
  4688. public OnShopOrderEmailVer(index)
  4689. {
  4690. if(IsPlayerConnected(index))
  4691. {
  4692. HideNoticeGUIFrame(index);
  4693. new rows, fields;
  4694. cache_get_data(rows, fields, ShopPipeline);
  4695. if(rows > 0)
  4696. {
  4697. new string[512];
  4698. new status[2], name[64], quantity[8], delivered[8], product_id[8];
  4699. for(new i;i<rows;i++)
  4700. {
  4701. cache_get_field_content(i, "order_status_id", status, ShopPipeline);
  4702. if(strval(status) == 2)
  4703. {
  4704. cache_get_field_content(i, "name", name, ShopPipeline);
  4705. cache_get_field_content(i, "quantity", quantity, ShopPipeline);
  4706. cache_get_field_content(i, "delivered", delivered, ShopPipeline);
  4707. cache_get_field_content(i, "order_product_id", product_id, ShopPipeline);
  4708. if(strval(quantity)-strval(delivered) <= 0)
  4709. {
  4710. if(i<rows) format(string, sizeof(string), "%s%s (Delivered)\n", string, name);
  4711. else format(string, sizeof(string), "%s%s (Delivered)", string, name);
  4712. }
  4713. else
  4714. {
  4715. if(i<rows) format(string, sizeof(string), "%s%s (%d)\n", string, name, strval(quantity)-strval(delivered));
  4716. else format(string, sizeof(string), "%s%s (%d)", string, name, strval(quantity)-strval(delivered));
  4717. }
  4718. }
  4719. else
  4720. {
  4721. new reason[27];
  4722. switch(strval(status))
  4723. {
  4724. case 0: format(reason, sizeof(reason), "{FF0000}No Payment");
  4725. case 1: format(reason, sizeof(reason), "{FF0000}Pending");
  4726. case 3: format(reason, sizeof(reason), "{00FF00}Shipped");
  4727. case 5:
  4728. {
  4729. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", "This order has already been delivered", "OK", "");
  4730. return 1;
  4731. }
  4732. case 7: format(reason, sizeof(reason), "{FF0000}Cancelled");
  4733. case 8: format(reason, sizeof(reason), "{FF0000}Denied");
  4734. case 9: format(reason, sizeof(reason), "{FF0000}Cancelled Reversal");
  4735. case 10: format(reason, sizeof(reason), "{FF0000}Failed");
  4736. case 11: format(reason, sizeof(reason), "{00FF00}Refundend");
  4737. case 12: format(reason, sizeof(reason), "{FF0000}Reversed");
  4738. case 13: format(reason, sizeof(reason), "{FF0000}Chargeback");
  4739. default: format(reason, sizeof(reason), "{FF0000}Unknown");
  4740. }
  4741. format(string, sizeof(string), "We are unable to process that order at this time,\nbecause the payment is currently marked as: %s", reason);
  4742. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", string, "OK", "");
  4743. return 1;
  4744. }
  4745. }
  4746. ShowPlayerDialog(index, DIALOG_SHOPORDER2, DIALOG_STYLE_LIST, "Shop Order List", string, "Select", "Cancel");
  4747. }
  4748. else
  4749. {
  4750. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", "Error: No orders were found by that Order ID\nIf you are sure that is the correct Order ID, please try again or input '1' for your order ID.", "OK", "");
  4751. }
  4752. }
  4753. return 1;
  4754. }
  4755.  
  4756. forward OnShopOrder2(index, extraid);
  4757. public OnShopOrder2(index, extraid)
  4758. {
  4759. if(IsPlayerConnected(index))
  4760. {
  4761. HideNoticeGUIFrame(index);
  4762. new string[256];
  4763. new rows, fields;
  4764. cache_get_data(rows, fields, ShopPipeline);
  4765. if(rows > 0)
  4766. {
  4767. for(new i;i<rows;i++)
  4768. {
  4769. if(i == extraid)
  4770. {
  4771. new status[2];
  4772. cache_get_field_content(i, "status", status, ShopPipeline);
  4773. if(strval(status) == 2)
  4774. {
  4775. new order_id[8], order_product_id[8], product_id[8], name[64], price[8], user[32], quantity[8], delivered[8];
  4776. cache_get_field_content(i, "order_id", order_id, ShopPipeline);
  4777. cache_get_field_content(i, "order_product_id", order_product_id, ShopPipeline);
  4778. cache_get_field_content(i, "product_id", product_id, ShopPipeline);
  4779. cache_get_field_content(i, "name", name, ShopPipeline);
  4780. cache_get_field_content(i, "price", price, ShopPipeline);
  4781. cache_get_field_content(i, "deliveruser", user, ShopPipeline);
  4782. cache_get_field_content(i, "quantity", quantity, ShopPipeline);
  4783. cache_get_field_content(i, "delivered", delivered, ShopPipeline);
  4784.  
  4785. format(string, sizeof(string), "Order ID: %d\nProduct ID: %d\nProduct: %s\nPrice: %s\nName: %s\nQuantity: %d", \
  4786. strval(order_id), strval(order_product_id), name, price, user, strval(quantity)-strval(delivered));
  4787.  
  4788. SetPVarInt(index, "DShop_order_id", strval(order_id));
  4789. SetPVarInt(index, "DShop_product_id", strval(product_id));
  4790. SetPVarString(index, "DShop_name", name);
  4791. SetPVarInt(index, "DShop_quantity", strval(quantity)-strval(delivered));
  4792.  
  4793. ShowPlayerDialog(index, DIALOG_SHOPDELIVER, DIALOG_STYLE_LIST, "Shop Order Info", string, "Deliver", "Cancel");
  4794. return 1;
  4795. }
  4796. else
  4797. {
  4798. new reason[27];
  4799. switch(strval(status))
  4800. {
  4801. case 0: format(reason, sizeof(reason), "{FF0000}No Payment");
  4802. case 1: format(reason, sizeof(reason), "{FF0000}Pending");
  4803. case 3: format(reason, sizeof(reason), "{00FF00}Shipped");
  4804. case 5:
  4805. {
  4806. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", "This order has already been delivered", "OK", "");
  4807. return 1;
  4808. }
  4809. case 7: format(reason, sizeof(reason), "{FF0000}Cancelled");
  4810. case 8: format(reason, sizeof(reason), "{FF0000}Denied");
  4811. case 9: format(reason, sizeof(reason), "{FF0000}Cancelled Reversal");
  4812. case 10: format(reason, sizeof(reason), "{FF0000}Failed");
  4813. case 11: format(reason, sizeof(reason), "{00FF00}Refundend");
  4814. case 12: format(reason, sizeof(reason), "{FF0000}Reversed");
  4815. case 13: format(reason, sizeof(reason), "{FF0000}Chargeback");
  4816. default: format(reason, sizeof(reason), "{FF0000}Unknown");
  4817. }
  4818. format(string, sizeof(string), "We are unable to process that order at this time,\nbecause the payment is currently marked as: %s", reason);
  4819. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", string, "OK", "");
  4820. return 1;
  4821. }
  4822. }
  4823. }
  4824. }
  4825. else
  4826. {
  4827. ShowPlayerDialog(index, 0, DIALOG_STYLE_MSGBOX, "Shop Order Error", "Error: No orders were found by that Order ID\nIf you are sure that is the correct Order ID, please try again or input '1' for your order ID.", "OK", "");
  4828. }
  4829. }
  4830. return 1;
  4831. }
  4832. #endif*/
  4833.  
  4834. forward OnSetMyName(index);
  4835. public OnSetMyName(index)
  4836. {
  4837. if(IsPlayerConnected(index))
  4838. {
  4839. new rows, fields;
  4840. cache_get_data(rows, fields, MainPipeline);
  4841. if(!rows)
  4842. {
  4843. new string[128], tmpName[24];
  4844. GetPVarString(index, "OnSetMyName", tmpName, 24);
  4845.  
  4846. new name[MAX_PLAYER_NAME];
  4847. GetPlayerName(index, name, sizeof(name));
  4848. SetPVarString(index, "TempNameName", name);
  4849. if(strlen(tmpName) > 0)
  4850. {
  4851. SetPlayerName(index, tmpName);
  4852. format(string, sizeof(string), "%s has changed their name to %s.", name, tmpName);
  4853. Log("logs/undercover.log", string);
  4854. DeletePVar(index, "OnSetMyName");
  4855.  
  4856. format(string, sizeof(string), "You have temporarily set your name to %s.", tmpName);
  4857. SendClientMessageEx(index, COLOR_YELLOW, string);
  4858. SendClientMessageEx(index, COLOR_GRAD2, "NOTE: None of your stats will save until you type this command again.");
  4859. SetPVarInt(index, "TempName", 1);
  4860. }
  4861. }
  4862. else
  4863. {
  4864. SendClientMessageEx(index, COLOR_WHITE, "This name is already registered.");
  4865. }
  4866. }
  4867. else
  4868. {
  4869. DeletePVar(index, "OnSetMyName");
  4870. }
  4871. return 1;
  4872. }
  4873.  
  4874. forward OnSetName(index, extraid);
  4875. public OnSetName(index, extraid)
  4876. {
  4877. if(IsPlayerConnected(index))
  4878. {
  4879. if(IsPlayerConnected(extraid))
  4880. {
  4881. new rows, fields;
  4882. cache_get_data(rows, fields, MainPipeline);
  4883. if(rows < 1)
  4884. {
  4885. new string[128], tmpName[24], playername[24];
  4886. GetPVarString(index, "OnSetName", tmpName, 24);
  4887.  
  4888. GetPlayerName(extraid, playername, sizeof(playername));
  4889.  
  4890. UpdateCitizenApp(extraid, PlayerInfo[extraid][pNation]);
  4891.  
  4892. if(PlayerInfo[extraid][pMarriedID] != -1)
  4893. {
  4894. foreach(new i: Player)
  4895. {
  4896. if(PlayerInfo[extraid][pMarriedID] == GetPlayerSQLId(i)) format(PlayerInfo[i][pMarriedName], MAX_PLAYER_NAME, "%s", tmpName);
  4897. }
  4898. }
  4899.  
  4900. for(new i; i < MAX_DDOORS; i++)
  4901. {
  4902. if(DDoorsInfo[i][ddType] == 1 && DDoorsInfo[i][ddOwner] == GetPlayerSQLId(extraid))
  4903. {
  4904. strcat((DDoorsInfo[i][ddOwnerName][0] = 0, DDoorsInfo[i][ddOwnerName]), tmpName, 42);
  4905. DestroyDynamicPickup(DDoorsInfo[i][ddPickupID]);
  4906. if(IsValidDynamic3DTextLabel(DDoorsInfo[i][ddTextID])) DestroyDynamic3DTextLabel(DDoorsInfo[i][ddTextID]);
  4907. CreateDynamicDoor(i);
  4908. SaveDynamicDoor(i);
  4909. }
  4910. }
  4911.  
  4912. if(Homes[extraid] > 0)
  4913. {
  4914. for(new i; i < MAX_HOUSES; i++)
  4915. {
  4916. if(GetPlayerSQLId(extraid) == HouseInfo[i][hOwnerID])
  4917. {
  4918. format(HouseInfo[i][hOwnerName], MAX_PLAYER_NAME, "%s", tmpName);
  4919. SaveHouse(i);
  4920. ReloadHouseText(i);
  4921. }
  4922. }
  4923. }
  4924.  
  4925. if(PlayerInfo[extraid][pDonateRank] >= 1)
  4926. {
  4927. new string2[128];
  4928. format(string2, sizeof(string2), "[VIP NAMECHANGES] %s has changed their name to %s.", GetPlayerNameEx(extraid), tmpName);
  4929. Log("logs/vipnamechanges.log", string2);
  4930. }
  4931.  
  4932. if(strlen(tmpName) > 0)
  4933. {
  4934. format(string, sizeof(string), " Your name has been changed from %s to %s.", GetPlayerNameEx(extraid), tmpName);
  4935. SendClientMessageEx(extraid,COLOR_YELLOW,string);
  4936. format(string, sizeof(string), " You have changed %s's name to %s.", GetPlayerNameEx(extraid), tmpName);
  4937. SendClientMessageEx(index,COLOR_YELLOW,string);
  4938. format(string, sizeof(string), "%s changed %s's name to %s",GetPlayerNameEx(index),GetPlayerNameExt(extraid),tmpName);
  4939. Log("logs/stats.log", string);
  4940. if(SetPlayerName(extraid, tmpName) == 1)
  4941. {
  4942. format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", tmpName, playername);
  4943. mysql_function_query(MainPipeline, string, true, "OnSetNameTwo", "ii", index, extraid);
  4944. }
  4945. else
  4946. {
  4947. SendClientMessage(extraid, COLOR_REALRED, "There was an issue with your name change.");
  4948. format(string, sizeof(string), "%s's name change has failed due to incorrect size or characters.", GetPlayerNameExt(extraid));
  4949. SendClientMessage(extraid, COLOR_REALRED, string);
  4950. format(string, sizeof(string), "Error changing %s's name to %s", GetPlayerNameExt(extraid), tmpName);
  4951. Log("logs/stats.log", string);
  4952. return 1;
  4953. }
  4954. OnPlayerStatsUpdate(extraid);
  4955. }
  4956. }
  4957. }
  4958. }
  4959. DeletePVar(index, "OnSetName");
  4960. return 1;
  4961. }
  4962.  
  4963. forward OnSetNameTwo(index, extraid);
  4964. public OnSetNameTwo(index, extraid)
  4965. {
  4966. return 1;
  4967. }
  4968.  
  4969. forward OnApproveName(index, extraid);
  4970. public OnApproveName(index, extraid)
  4971. {
  4972. if(IsPlayerConnected(extraid))
  4973. {
  4974. new string[128];
  4975. new rows, fields;
  4976. cache_get_data(rows, fields, MainPipeline);
  4977. if(rows < 1)
  4978. {
  4979. new newname[24], oldname[24];
  4980. GetPVarString(extraid, "NewNameRequest", newname, 24);
  4981. GetPlayerName(extraid, oldname, sizeof(oldname));
  4982.  
  4983. UpdateCitizenApp(extraid, PlayerInfo[extraid][pNation]);
  4984.  
  4985. if(PlayerInfo[extraid][pMarriedID] != -1)
  4986. {
  4987. foreach(new i: Player)
  4988. {
  4989. if(PlayerInfo[extraid][pMarriedID] == GetPlayerSQLId(i)) format(PlayerInfo[i][pMarriedName], MAX_PLAYER_NAME, "%s", newname);
  4990. }
  4991. }
  4992.  
  4993. for(new i; i < MAX_DDOORS; i++)
  4994. {
  4995. if(DDoorsInfo[i][ddType] == 1 && DDoorsInfo[i][ddOwner] == GetPlayerSQLId(extraid))
  4996. {
  4997. strcat((DDoorsInfo[i][ddOwnerName][0] = 0, DDoorsInfo[i][ddOwnerName]), newname, 42);
  4998. DestroyDynamicPickup(DDoorsInfo[i][ddPickupID]);
  4999. if(IsValidDynamic3DTextLabel(DDoorsInfo[i][ddTextID])) DestroyDynamic3DTextLabel(DDoorsInfo[i][ddTextID]);
  5000. CreateDynamicDoor(i);
  5001. SaveDynamicDoor(i);
  5002. }
  5003. }
  5004.  
  5005. if(Homes[extraid] > 0)
  5006. {
  5007. for(new i; i < MAX_HOUSES; i++)
  5008. {
  5009. if(GetPlayerSQLId(extraid) == HouseInfo[i][hOwnerID])
  5010. {
  5011. format(HouseInfo[i][hOwnerName], MAX_PLAYER_NAME, "%s", newname);
  5012. SaveHouse(i);
  5013. ReloadHouseText(i);
  5014. }
  5015. }
  5016. }
  5017.  
  5018. if(PlayerInfo[extraid][pBusiness] != INVALID_BUSINESS_ID && Businesses[PlayerInfo[extraid][pBusiness]][bOwner] == GetPlayerSQLId(extraid))
  5019. {
  5020. strcpy(Businesses[PlayerInfo[extraid][pBusiness]][bOwnerName], newname, MAX_PLAYER_NAME);
  5021. SaveBusiness(PlayerInfo[extraid][pBusiness]);
  5022. RefreshBusinessPickup(PlayerInfo[extraid][pBusiness]);
  5023. }
  5024.  
  5025. if(PlayerInfo[extraid][pDonateRank] >= 1)
  5026. {
  5027. format(string, sizeof(string), "[VIP NAMECHANGES] %s has changed their name to %s.", GetPlayerNameEx(extraid), newname);
  5028. Log("logs/vipnamechanges.log", string);
  5029. }
  5030.  
  5031. if((0 <= PlayerInfo[extraid][pMember] < MAX_GROUPS) && PlayerInfo[extraid][pRank] >= arrGroupData[PlayerInfo[extraid][pMember]][g_iFreeNameChange])
  5032. {
  5033. if(strlen(newname) > 0)
  5034. {
  5035. format(string, sizeof(string), " Your name has been changed from %s to %s for free.", GetPlayerNameEx(extraid), newname);
  5036. SendClientMessageEx(extraid,COLOR_YELLOW,string);
  5037. format(string, sizeof(string), " You have changed %s's name to %s at no cost.", GetPlayerNameEx(extraid), newname);
  5038. SendClientMessageEx(index,COLOR_YELLOW,string);
  5039. format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free.",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
  5040. Log("logs/stats.log", string);
  5041. format(string, sizeof(string), "%s has approved %s's name change to %s at no cost.",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
  5042. ABroadCast(COLOR_YELLOW, string, 3);
  5043.  
  5044.  
  5045. if(SetPlayerName(extraid, newname) == 1)
  5046. {
  5047. format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
  5048. mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
  5049. }
  5050. else
  5051. {
  5052. SendClientMessage(extraid, COLOR_REALRED, "There was an issue with your name change.");
  5053. format(string, sizeof(string), "%s's name change has failed due to incorrect size or characters.", GetPlayerNameExt(extraid));
  5054. SendClientMessage(index, COLOR_REALRED, string);
  5055. format(string, sizeof(string), "Error changing %s's name to %s", GetPlayerNameExt(extraid), newname);
  5056. Log("logs/stats.log", string);
  5057. return 1;
  5058. }
  5059. DeletePVar(extraid, "RequestingNameChange");
  5060. }
  5061. }
  5062.  
  5063. else if(PlayerInfo[extraid][pAdmin] == 1 && PlayerInfo[extraid][pSMod] > 0)
  5064. {
  5065. if(strlen(newname) > 0)
  5066. {
  5067. format(string, sizeof(string), " Your name has been changed from %s to %s for free (Senior Mod).", GetPlayerNameEx(extraid), newname);
  5068. SendClientMessageEx(extraid,COLOR_YELLOW,string);
  5069. format(string, sizeof(string), " You have changed %s's name to %s at no cost.", GetPlayerNameEx(extraid), newname);
  5070. SendClientMessageEx(index,COLOR_YELLOW,string);
  5071. format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free (Senior Mod).",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
  5072. Log("logs/stats.log", string);
  5073. format(string, sizeof(string), "%s has approved %s's name change to %s at no cost (Senior Mod).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
  5074. ABroadCast(COLOR_YELLOW, string, 3);
  5075.  
  5076. if(SetPlayerName(extraid, newname) == 1)
  5077. {
  5078. format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
  5079. mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
  5080. }
  5081. else
  5082. {
  5083. SendClientMessage(extraid, COLOR_REALRED, "There was an issue with your name change.");
  5084. format(string, sizeof(string), "%s's name change has failed due to incorrect size or characters.", GetPlayerNameExt(extraid));
  5085. SendClientMessage(index, COLOR_REALRED, string);
  5086. format(string, sizeof(string), "Error changing %s's name to %s", GetPlayerNameExt(extraid), newname);
  5087. Log("logs/stats.log", string);
  5088. return 1;
  5089. }
  5090. DeletePVar(extraid, "RequestingNameChange");
  5091. }
  5092. }
  5093.  
  5094. else
  5095. {
  5096. if(GetPVarInt(extraid, "NameChangeCost") == 0)
  5097. {
  5098. if(strlen(newname) > 0)
  5099. {
  5100. format(string, sizeof(string), " Your name has been changed from %s to %s for free (non-RP name).", GetPlayerNameEx(extraid), newname);
  5101. SendClientMessageEx(extraid,COLOR_YELLOW,string);
  5102. format(string, sizeof(string), " You have changed %s's name to %s for free (non-RP name).", GetPlayerNameEx(extraid), newname);
  5103. SendClientMessageEx(index,COLOR_YELLOW,string);
  5104. format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for free (non-RP name).",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid));
  5105. Log("logs/stats.log", string);
  5106. format(string, sizeof(string), "%s has approved %s's name change to %s for free (non-RP name).",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname);
  5107. ABroadCast(COLOR_YELLOW, string, 3);
  5108.  
  5109. if(SetPlayerName(extraid, newname) == 1)
  5110. {
  5111. format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
  5112. mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
  5113. }
  5114. else
  5115. {
  5116. SendClientMessage(extraid, COLOR_REALRED, "There was an issue with your name change.");
  5117. format(string, sizeof(string), "%s's name change has failed due to incorrect size or characters.", GetPlayerNameExt(extraid));
  5118. SendClientMessage(index, COLOR_REALRED, string);
  5119. format(string, sizeof(string), "Error changing %s's name to %s", GetPlayerNameExt(extraid), newname);
  5120. Log("logs/stats.log", string);
  5121. return 1;
  5122. }
  5123. DeletePVar(extraid, "RequestingNameChange");
  5124. }
  5125. }
  5126. else
  5127. {
  5128. if(strlen(newname) > 0)
  5129. {
  5130. GivePlayerCash(extraid, -GetPVarInt(extraid, "NameChangeCost"));
  5131. format(string, sizeof(string), " Your name has been changed from %s to %s for $%d.", GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
  5132. SendClientMessageEx(extraid,COLOR_YELLOW,string);
  5133. format(string, sizeof(string), " You have changed %s's name to %s for $%d.", GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
  5134. SendClientMessageEx(index,COLOR_YELLOW,string);
  5135. format(string, sizeof(string), "%s changed \"%s\"s name to \"%s\" (id: %i) for $%d",GetPlayerNameEx(index),GetPlayerNameEx(extraid),newname, GetPlayerSQLId(extraid), GetPVarInt(extraid, "NameChangeCost"));
  5136. Log("logs/stats.log", string);
  5137. format(string, sizeof(string), "%s has approved %s's name change to %s for $%d",GetPlayerNameEx(index),GetPlayerNameEx(extraid), newname, GetPVarInt(extraid, "NameChangeCost"));
  5138. ABroadCast(COLOR_YELLOW, string, 3);
  5139.  
  5140. if(SetPlayerName(extraid, newname) == 1)
  5141. {
  5142. format(string, sizeof(string), "UPDATE `accounts` SET `Username`='%s' WHERE `Username`='%s'", newname, oldname);
  5143. mysql_function_query(MainPipeline, string, true, "OnApproveSetName", "ii", index, extraid);
  5144. }
  5145. else
  5146. {
  5147. SendClientMessage(extraid, COLOR_REALRED, "There was an issue with your name change.");
  5148. format(string, sizeof(string), "%s's name change has failed due to incorrect size or characters.", GetPlayerNameExt(extraid));
  5149. SendClientMessage(index, COLOR_REALRED, string);
  5150. format(string, sizeof(string), "Error changing %s's name to %s", GetPlayerNameExt(extraid), newname);
  5151. Log("logs/stats.log", string);
  5152. return 1;
  5153. }
  5154.  
  5155. DeletePVar(extraid, "RequestingNameChange");
  5156. }
  5157. }
  5158. }
  5159. }
  5160. else
  5161. {
  5162. SendClientMessageEx(extraid, COLOR_GRAD2, "That name already exists, please choose a different one.");
  5163. SendClientMessageEx(index, COLOR_GRAD2, "That name already exists.");
  5164. DeletePVar(extraid, "RequestingNameChange");
  5165. return 1;
  5166. }
  5167. }
  5168. return 1;
  5169. }
  5170.  
  5171. forward OnIPWhitelist(index);
  5172. public OnIPWhitelist(index)
  5173. {
  5174. new string[128], name[24];
  5175. GetPVarString(index, "OnIPWhitelist", name, 24);
  5176.  
  5177. if(mysql_affected_rows(MainPipeline)) {
  5178. format(string, sizeof(string), "You have successfully whitelisted %s's account.", name);
  5179. SendClientMessageEx(index, COLOR_WHITE, string);
  5180. format(string, sizeof(string), "%s has IP Whitelisted %s", GetPlayerNameEx(index), name);
  5181. Log("logs/whitelist.log", string);
  5182. }
  5183. else {
  5184. format(string, sizeof(string), "There was a issue with whitelisting %s's account.", name);
  5185. SendClientMessageEx(index, COLOR_WHITE, string);
  5186. }
  5187. DeletePVar(index, "OnIPWhitelist");
  5188.  
  5189. return 1;
  5190. }
  5191.  
  5192. forward OnIPCheck(index);
  5193. public OnIPCheck(index)
  5194. {
  5195. if(IsPlayerConnected(index))
  5196. {
  5197. new string[128], ip[16], name[24];
  5198. new rows, fields;
  5199. cache_get_data(rows, fields, MainPipeline);
  5200. if(rows)
  5201. {
  5202. cache_get_field_content(0, "IP", ip, MainPipeline, 16);
  5203. cache_get_field_content(0, "Username", name, MainPipeline, MAX_PLAYER_NAME);
  5204. format(string, sizeof(string), "%s's IP: %s", name, ip);
  5205. SendClientMessageEx(index, COLOR_WHITE, string);
  5206. format(string, sizeof(string), "%s has IP Checked %s", GetPlayerNameEx(index), name);
  5207. Log("logs/ipcheck.log", string);
  5208. }
  5209. else
  5210. {
  5211. SendClientMessageEx(index, COLOR_WHITE, "There was an issue with checking the account's IP.");
  5212. }
  5213. }
  5214. return 1;
  5215. }
  5216.  
  5217. forward OnProcessOrderCheck(index, extraid);
  5218. public OnProcessOrderCheck(index, extraid)
  5219. {
  5220. if(IsPlayerConnected(index))
  5221. {
  5222. new string[164],playerip[32], giveplayerip[32];
  5223. GetPlayerIp(index, playerip, sizeof(playerip));
  5224. GetPlayerIp(extraid, giveplayerip, sizeof(giveplayerip));
  5225.  
  5226. new rows, fields;
  5227. cache_get_data(rows, fields, MainPipeline);
  5228. if(rows)
  5229. {
  5230. SendClientMessageEx(index, COLOR_WHITE, "This order has previously been processed, therefore it did not count toward your pay.");
  5231. format(string, sizeof(string), "%s(IP: %s) has processed shop order ID %d from %s(IP: %s).", GetPlayerNameEx(index), playerip, GetPVarInt(index, "processorder"), GetPlayerNameEx(extraid), giveplayerip);
  5232. Log("logs/shoporders.log", string);
  5233. }
  5234. else
  5235. {
  5236. format(string, sizeof(string), "%s(IP: %s) has processed shop order ID %d from %s(IP: %s).", GetPlayerNameEx(index), playerip, GetPVarInt(index, "processorder"), GetPlayerNameEx(extraid), giveplayerip);
  5237. Log("logs/shopconfirmedorders.log", string);
  5238. PlayerInfo[index][pShopTechOrders]++;
  5239.  
  5240. format(string, sizeof(string), "INSERT INTO shoptech (id,total,dtotal) VALUES (%d,1,%f) ON DUPLICATE KEY UPDATE total = total + 1, dtotal = dtotal + %f", GetPlayerSQLId(index), ShopTechPay, ShopTechPay);
  5241. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, index);
  5242.  
  5243. format(string, sizeof(string), "INSERT INTO `orders` (`id`) VALUES ('%d')", GetPVarInt(index, "processorder"));
  5244. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "ii", SENDDATA_THREAD, index);
  5245. }
  5246. DeletePVar(index, "processorder");
  5247. }
  5248. return 1;
  5249. }
  5250.  
  5251. forward OnFine(index);
  5252. public OnFine(index)
  5253. {
  5254. new string[128], name[24], amount, reason[64];
  5255. GetPVarString(index, "OnFine", name, 24);
  5256. amount = GetPVarInt(index, "OnFineAmount");
  5257. GetPVarString(index, "OnFineReason", reason, 64);
  5258.  
  5259. if(mysql_affected_rows(MainPipeline)) {
  5260. format(string, sizeof(string), "You have successfully fined %s's account.", name);
  5261. SendClientMessageEx(index, COLOR_WHITE, string);
  5262.  
  5263. format(string, sizeof(string), "AdmCmd: %s was offline fined $%d by %s, reason: %s", name, amount, GetPlayerNameEx(index), reason);
  5264. Log("logs/admin.log", string);
  5265. }
  5266. else {
  5267. format(string, sizeof(string), "There was an issue with fining %s's account.", name);
  5268. SendClientMessageEx(index, COLOR_WHITE, string);
  5269. }
  5270. DeletePVar(index, "OnFine");
  5271. DeletePVar(index, "OnFineAmount");
  5272. DeletePVar(index, "OnFineReason");
  5273.  
  5274. return 1;
  5275. }
  5276.  
  5277. forward OnSetDDOwner(playerid, doorid);
  5278. public OnSetDDOwner(playerid, doorid)
  5279. {
  5280. if(IsPlayerConnected(playerid))
  5281. {
  5282. new rows, fields;
  5283. new string[128], sqlid[5], playername[MAX_PLAYER_NAME], id;
  5284. cache_get_data(rows, fields, MainPipeline);
  5285.  
  5286. if(rows)
  5287. {
  5288. cache_get_field_content(0, "id", sqlid, MainPipeline); id = strval(sqlid);
  5289. cache_get_field_content(0, "Username", playername, MainPipeline, MAX_PLAYER_NAME);
  5290. strcat((DDoorsInfo[doorid][ddOwnerName][0] = 0, DDoorsInfo[doorid][ddOwnerName]), playername, MAX_PLAYER_NAME);
  5291. DDoorsInfo[doorid][ddOwner] = id;
  5292.  
  5293. format(string, sizeof(string), "Successfully set the owner to %s.", playername);
  5294. SendClientMessageEx(playerid, COLOR_WHITE, string);
  5295.  
  5296. DestroyDynamicPickup(DDoorsInfo[doorid][ddPickupID]);
  5297. if(IsValidDynamic3DTextLabel(DDoorsInfo[doorid][ddTextID])) DestroyDynamic3DTextLabel(DDoorsInfo[doorid][ddTextID]);
  5298. CreateDynamicDoor(doorid);
  5299. SaveDynamicDoor(doorid);
  5300. format(string, sizeof(string), "%s has edited door ID %d's owner to %s (SQL ID: %d).", GetPlayerNameEx(playerid), doorid, playername, id);
  5301. Log("logs/ddedit.log", string);
  5302. }
  5303. else SendClientMessageEx(playerid, COLOR_GREY, "That account name does not appear to exist.");
  5304. }
  5305. return 1;
  5306. }
  5307.  
  5308. forward OnPrisonAccount(index);
  5309. public OnPrisonAccount(index)
  5310. {
  5311. new string[128], name[24], reason[64];
  5312. GetPVarString(index, "OnPrisonAccount", name, 24);
  5313. GetPVarString(index, "OnPrisonAccountReason", reason, 64);
  5314.  
  5315. if(mysql_affected_rows(MainPipeline)) {
  5316. format(string, sizeof(string), "You have successfully prisoned %s's account.", name);
  5317. SendClientMessageEx(index, COLOR_WHITE, string);
  5318.  
  5319. format(string, sizeof(string), "AdmCmd: %s was offline prisoned by %s, reason: %s ", name, GetPlayerNameEx(index), reason);
  5320. Log("logs/admin.log", string);
  5321. }
  5322. else {
  5323. format(string, sizeof(string), "There was an issue with prisoning %s's account.");
  5324. SendClientMessageEx(index, COLOR_WHITE, string);
  5325. }
  5326. DeletePVar(index, "OnPrisonAccount");
  5327. DeletePVar(index, "OnPrisonAccountReason");
  5328.  
  5329. return 1;
  5330. }
  5331.  
  5332. forward OnJailAccount(index);
  5333. public OnJailAccount(index)
  5334. {
  5335. new string[128], name[24], reason[64];
  5336. GetPVarString(index, "OnJailAccount", name, 24);
  5337. GetPVarString(index, "OnJailAccountReason", reason, 64);
  5338.  
  5339. if(mysql_affected_rows(MainPipeline)) {
  5340. format(string, sizeof(string), "You have successfully jailed %s's account.", name);
  5341. SendClientMessageEx(index, COLOR_WHITE, string);
  5342.  
  5343. format(string, sizeof(string), "AdmCmd: %s was offline jailed by %s, reason: %s", name, GetPlayerNameEx(index), reason);
  5344. Log("logs/admin.log", string);
  5345. }
  5346. else {
  5347. format(string, sizeof(string), "There was an issue with jailing %s's account.", name);
  5348. SendClientMessageEx(index, COLOR_WHITE, string);
  5349. }
  5350.  
  5351. DeletePVar(index, "OnJailAccount");
  5352. DeletePVar(index, "OnJailAccountReason");
  5353.  
  5354. return 1;
  5355. }
  5356.  
  5357. forward OnGetLatestKills(playerid, giveplayerid);
  5358. public OnGetLatestKills(playerid, giveplayerid)
  5359. {
  5360. new string[128], killername[MAX_PLAYER_NAME], killedname[MAX_PLAYER_NAME], kDate[20], weapon[56], rows, fields;
  5361. cache_get_data(rows, fields, MainPipeline);
  5362. if(rows)
  5363. {
  5364. for(new i; i < rows; i++)
  5365. {
  5366. cache_get_row(i, 0, killername, MainPipeline, MAX_PLAYER_NAME);
  5367. cache_get_row(i, 1, killedname, MainPipeline, MAX_PLAYER_NAME);
  5368. cache_get_field_content(i, "killerid", string, MainPipeline); new killer = strval(string);
  5369. cache_get_field_content(i, "killedid", string, MainPipeline); new killed = strval(string);
  5370. cache_get_field_content(i, "date", kDate, MainPipeline, sizeof(kDate));
  5371. cache_get_field_content(i, "weapon", weapon, MainPipeline, sizeof(weapon));
  5372. if(GetPlayerSQLId(giveplayerid) == killer && GetPlayerSQLId(giveplayerid) == killed) format(string, sizeof(string), "[%s] %s killed themselves (%s)", kDate, StripUnderscore(killedname), weapon);
  5373. else if(GetPlayerSQLId(giveplayerid) == killer && GetPlayerSQLId(giveplayerid) != killed) format(string, sizeof(string), "[%s] %s killed %s with %s", kDate, StripUnderscore(killername), StripUnderscore(killedname), weapon);
  5374. else if(GetPlayerSQLId(giveplayerid) != killer && GetPlayerSQLId(giveplayerid) == killed) format(string, sizeof(string), "[%s] %s was killed by %s with %s", kDate, StripUnderscore(killedname), StripUnderscore(killername), weapon);
  5375. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  5376. }
  5377. }
  5378. else SendClientMessageEx(playerid, COLOR_YELLOW, "No kills recorded on this player.");
  5379. return 1;
  5380. }
  5381.  
  5382. forward OnGetOKills(playerid);
  5383. public OnGetOKills(playerid)
  5384. {
  5385. if(IsPlayerConnected(playerid))
  5386. {
  5387. new string[256], giveplayername[MAX_PLAYER_NAME], giveplayerid;
  5388.  
  5389. new rows, fields;
  5390. cache_get_data(rows, fields, MainPipeline);
  5391.  
  5392. if(rows)
  5393. {
  5394. cache_get_field_content(0, "id", string, MainPipeline); giveplayerid = strval(string);
  5395. cache_get_field_content(0, "Username", giveplayername, MainPipeline, MAX_PLAYER_NAME);
  5396. format(string, sizeof(string), "SELECT Killer.Username, Killed.Username, k.* FROM Kills k LEFT JOIN accounts Killed ON k.killedid = Killed.id LEFT JOIN accounts Killer ON Killer.id = k.killerid WHERE k.killerid = %d OR k.killedid = %d ORDER BY `date` DESC LIMIT 10", giveplayerid, giveplayerid);
  5397. mysql_function_query(MainPipeline, string, true, "OnGetLatestOKills", "iis", playerid, giveplayerid, giveplayername);
  5398. }
  5399. else return SendClientMessageEx(playerid, COLOR_GREY, "This account does not exist.");
  5400. }
  5401. return 1;
  5402. }
  5403.  
  5404. forward OnGetLatestOKills(playerid, giveplayerid, giveplayername[]);
  5405. public OnGetLatestOKills(playerid, giveplayerid, giveplayername[])
  5406. {
  5407. new string[128], killername[MAX_PLAYER_NAME], killedname[MAX_PLAYER_NAME], kDate[20], weapon[56], rows, fields;
  5408. cache_get_data(rows, fields, MainPipeline);
  5409. if(rows)
  5410. {
  5411. SendClientMessageEx(playerid, COLOR_GREEN, "________________________________________________");
  5412. format(string, sizeof(string), "<< Last 10 Kills/Deaths of %s >>", StripUnderscore(giveplayername));
  5413. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  5414. for(new i; i < rows; i++)
  5415. {
  5416. cache_get_row(i, 0, killername, MainPipeline, MAX_PLAYER_NAME);
  5417. cache_get_row(i, 1, killedname, MainPipeline, MAX_PLAYER_NAME);
  5418. cache_get_field_content(i, "killerid", string, MainPipeline); new killer = strval(string);
  5419. cache_get_field_content(i, "killedid", string, MainPipeline); new killed = strval(string);
  5420. cache_get_field_content(i, "date", kDate, MainPipeline, sizeof(kDate));
  5421. cache_get_field_content(i, "weapon", weapon, MainPipeline, sizeof(weapon));
  5422. if(giveplayerid == killer && giveplayerid == killed) format(string, sizeof(string), "[%s] %s killed themselves (%s)", kDate, StripUnderscore(killedname), weapon);
  5423. else if(giveplayerid == killer && giveplayerid != killed) format(string, sizeof(string), "[%s] %s killed %s with %s", kDate, StripUnderscore(killername), StripUnderscore(killedname), weapon);
  5424. else if(giveplayerid != killer && giveplayerid == killed) format(string, sizeof(string), "[%s] %s was killed by %s with %s", kDate, StripUnderscore(killedname), StripUnderscore(killername), weapon);
  5425. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  5426. }
  5427. }
  5428. else return SendClientMessageEx(playerid, COLOR_YELLOW, "No kills recorded on this player.");
  5429. return 1;
  5430. }
  5431.  
  5432. forward OnDMStrikeReset(playerid, giveplayerid);
  5433. public OnDMStrikeReset(playerid, giveplayerid)
  5434. {
  5435. new string[128];
  5436. format(string, sizeof(string), "Deleted %d strikes against %s", mysql_affected_rows(MainPipeline), GetPlayerNameEx(giveplayerid));
  5437. SendClientMessage(playerid, COLOR_WHITE, string);
  5438. return 1;
  5439. }
  5440.  
  5441. forward OnDMRLookup(playerid, giveplayerid);
  5442. public OnDMRLookup(playerid, giveplayerid)
  5443. {
  5444. new string[128], rows, fields;
  5445. cache_get_data(rows, fields, MainPipeline);
  5446. format(string, sizeof(string), "Showing the last %d /dmreports by %s", rows, GetPlayerNameEx(giveplayerid));
  5447. SendClientMessage(playerid, COLOR_WHITE, string);
  5448. SendClientMessage(playerid, COLOR_WHITE, "| Reported | Time |");
  5449. for(new i;i < rows;i++)
  5450. {
  5451. new szResult[32], name[MAX_PLAYER_NAME], timestamp;
  5452. cache_get_row(i, 0, szResult, MainPipeline); timestamp = strval(szResult);
  5453. cache_get_row(i, 1, name, MainPipeline, MAX_PLAYER_NAME);
  5454. format(string, sizeof(string), "%s - %s", name, date(timestamp, 1));
  5455. SendClientMessage(playerid, COLOR_WHITE, string);
  5456. }
  5457. return 1;
  5458. }
  5459.  
  5460. forward OnDMTokenLookup(playerid, giveplayerid);
  5461. public OnDMTokenLookup(playerid, giveplayerid)
  5462. {
  5463. new string[128], rows, fields;
  5464. cache_get_data(rows, fields, MainPipeline);
  5465. format(string, sizeof(string), "Showing the %d active /dmreports on %s", rows, GetPlayerNameEx(giveplayerid));
  5466. SendClientMessage(playerid, COLOR_WHITE, string);
  5467. SendClientMessage(playerid, COLOR_WHITE, "| Reporter | Time |");
  5468. for(new i;i < rows;i++)
  5469. {
  5470. new szResult[32], name[MAX_PLAYER_NAME], timestamp;
  5471. cache_get_row(i, 0, szResult, MainPipeline); timestamp = strval(szResult);
  5472. cache_get_row(i, 1, name, MainPipeline);
  5473. format(string, sizeof(string), "%s - %s", name, date(timestamp, 1));
  5474. SendClientMessage(playerid, COLOR_WHITE, string);
  5475. }
  5476. return 1;
  5477. }
  5478.  
  5479. forward OnDMWatchListLookup(playerid);
  5480. public OnDMWatchListLookup(playerid)
  5481. {
  5482. new string[128], rows, fields;
  5483. cache_get_data(rows, fields, MainPipeline);
  5484. format(string, sizeof(string), "Showing %d active people to watch", rows);
  5485. SendClientMessage(playerid, COLOR_WHITE, string);
  5486. for(new i;i < rows;i++)
  5487. {
  5488. new name[MAX_PLAYER_NAME], watchid;
  5489. cache_get_row(i, 0, name, MainPipeline);
  5490. sscanf(name, "u", watchid);
  5491. format(string, sizeof(string), "(ID: %d) %s", watchid, name);
  5492. SendClientMessage(playerid, COLOR_WHITE, string);
  5493. }
  5494. return 1;
  5495. }
  5496.  
  5497. forward OnDMWatch(playerid);
  5498. public OnDMWatch(playerid)
  5499. {
  5500. new rows, fields;
  5501. cache_get_data(rows, fields, MainPipeline);
  5502. if(rows)
  5503. {
  5504. new string[128], namesql[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
  5505. cache_get_row(0, 0, namesql, MainPipeline);
  5506. foreach(new i: Player)
  5507. {
  5508. if(!PlayerInfo[i][pJailTime])
  5509. {
  5510. GetPlayerName(i, name, sizeof(name));
  5511. if(strcmp(name, namesql, true) == 0)
  5512. {
  5513. foreach(new x: Player)
  5514. {
  5515. if(GetPVarInt(x, "pWatchdogWatching") == i)
  5516. {
  5517. return SendClientMessage(playerid, COLOR_WHITE, "The random person selected for you is already being watched, please try again!");
  5518. }
  5519. }
  5520. format(string, sizeof(string), "You now have access to /spec %s (ID: %i). Use /dmalert if this person deathmatches.", name, i);
  5521. SendClientMessage(playerid, COLOR_WHITE, string);
  5522. return SetPVarInt(playerid, "pWatchdogWatching", i);
  5523. }
  5524. }
  5525. }
  5526. }
  5527. return SendClientMessageEx(playerid, COLOR_WHITE, "There is no one online to DM Watch!");
  5528. }
  5529.  
  5530. forward OnWarnPlayer(index);
  5531. public OnWarnPlayer(index)
  5532. {
  5533. new string[128], name[24], reason[64];
  5534. GetPVarString(index, "OnWarnPlayer", name, 24);
  5535. GetPVarString(index, "OnWarnPlayerReason", reason, 64);
  5536.  
  5537. if(mysql_affected_rows(MainPipeline)) {
  5538. format(string, sizeof(string), "You have successfully warned %s's account.", name);
  5539. SendClientMessageEx(index, COLOR_WHITE, string);
  5540.  
  5541. format(string, sizeof(string), "AdmCmd: %s was offline warned by %s, reason: %s", name, GetPlayerNameEx(index), reason);
  5542. Log("logs/admin.log", string);
  5543. }
  5544. else {
  5545. format(string, sizeof(string), "There was an issue with warning %s's account.", name);
  5546. SendClientMessageEx(index, COLOR_WHITE, string);
  5547. }
  5548. DeletePVar(index, "OnWarnPlayer");
  5549. DeletePVar(index, "OnWarnPlayerReason");
  5550.  
  5551. return 1;
  5552. }
  5553.  
  5554. forward OnPinCheck2(index);
  5555. public OnPinCheck2(index)
  5556. {
  5557. if(IsPlayerConnected(index))
  5558. {
  5559. new rows, fields;
  5560. cache_get_data(rows, fields, MainPipeline);
  5561. if(rows)
  5562. {
  5563. new Pin[256];
  5564. cache_get_field_content(0, "Pin", Pin, MainPipeline, 256);
  5565. if(isnull(Pin)) {
  5566. ShowPlayerDialog(index, DIALOG_CREATEPIN, DIALOG_STYLE_INPUT, "Pin Number", "Create a pin number so you can secure your account credits.", "Create", "Exit");
  5567. }
  5568. else
  5569. {
  5570. new passbuffer[256], passbuffer2[64];
  5571. GetPVarString(index, "PinNumber", passbuffer2, sizeof(passbuffer2));
  5572. WP_Hash(passbuffer, sizeof(passbuffer), passbuffer2);
  5573. if (strcmp(passbuffer, Pin) == 0)
  5574. {
  5575. SetPVarInt(index, "PinConfirmed", 1);
  5576. SendClientMessageEx(index, COLOR_CYAN, "Pin confirmed, you will now be able to spend credits.");
  5577. switch(GetPVarInt(index, "OpenShop"))
  5578. {
  5579. case 1:
  5580. {
  5581. new szDialog[512];
  5582. format(szDialog, sizeof(szDialog), "Poker Table (Credits: {FFD700}%s{A9C4E4})\nBoombox (Credits: {FFD700}%s{A9C4E4})\n100 Paintball Tokens (Credits: {FFD700}%s{A9C4E4})\nEXP Token (Credits: {FFD700}%s{A9C4E4})\nFireworks x5 (Credits: {FFD700}%s{A9C4E4})\nCustom License Plate (Credits: {FFD700}%s{A9C4E4})" \
  5583. "\nHunger Games Voucher(Credits: {FFD700}%s{A9C4E4})",
  5584. number_format(ShopItems[6][sItemPrice]), number_format(ShopItems[7][sItemPrice]), number_format(ShopItems[8][sItemPrice]), number_format(ShopItems[9][sItemPrice]),
  5585. number_format(ShopItems[10][sItemPrice]), number_format(ShopItems[22][sItemPrice]), number_format(ShopItems[29][sItemPrice]));
  5586. ShowPlayerDialog(index, DIALOG_MISCSHOP, DIALOG_STYLE_LIST, "Misc Shop", szDialog, "Select", "Cancel");
  5587. }
  5588. case 2: SetPVarInt(index, "RentaCar", 1), ShowModelSelectionMenu(index, CarList2, "Rent a Car!");
  5589. case 3: ShowModelSelectionMenu(index, CarList2, "Car Shop");
  5590. case 4: ShowPlayerDialog( index, DIALOG_HOUSESHOP, DIALOG_STYLE_LIST, "House Shop", "Purchase House\nHouse Interior Change\nHouse Move\nGarage - Small\nGarage - Medium\nGarage - Large\nGarage - Extra Large","Select", "Exit" );
  5591. case 5: ShowPlayerDialog( index, DIALOG_VIPSHOP, DIALOG_STYLE_LIST, "VIP Shop", "Purchase VIP\nRenew Gold VIP","Continue", "Exit" );
  5592. case 6: ShowPlayerDialog(index, DIALOG_SHOPBUSINESS, DIALOG_STYLE_LIST, "Businesses Shop", "Purchase Business\nRenew Business", "Select", "Exit");
  5593. case 7: ShowModelSelectionMenu(index, PlaneList, "Plane Shop");
  5594. case 8: ShowModelSelectionMenu(index, BoatList, "Boat Shop");
  5595. case 9: ShowModelSelectionMenu(index, CarList3, "Restricted Car Shop");
  5596. }
  5597. DeletePVar(index, "OpenShop");
  5598. }
  5599. else
  5600. {
  5601. ShowPlayerDialog(index, DIALOG_ENTERPIN, DIALOG_STYLE_INPUT, "Pin Number", "(INVALID PIN)\n\nEnter your pin number to access credit shops.", "Confirm", "Exit");
  5602. }
  5603. DeletePVar(index, "PinNumber");
  5604. }
  5605. }
  5606. else
  5607. {
  5608. SendClientMessageEx(index, COLOR_WHITE, "There was an issue, please try again.");
  5609. }
  5610. }
  5611. return 1;
  5612. }
  5613.  
  5614. forward OnPinCheck(index);
  5615. public OnPinCheck(index)
  5616. {
  5617. if(IsPlayerConnected(index))
  5618. {
  5619. new rows, fields;
  5620. cache_get_data(rows, fields, MainPipeline);
  5621. if(rows)
  5622. {
  5623. new Pin[128];
  5624. cache_get_field_content(0, "Pin", Pin, MainPipeline, 128);
  5625. if(isnull(Pin)) {
  5626. ShowPlayerDialog(index, DIALOG_CREATEPIN, DIALOG_STYLE_INPUT, "Pin Number", "Create a pin number so you can secure your account credits.", "Create", "Exit");
  5627. }
  5628. else
  5629. {
  5630. ShowPlayerDialog(index, DIALOG_ENTERPIN, DIALOG_STYLE_INPUT, "Pin Number", "Enter your pin number to access credit shops.", "Confirm", "Exit");
  5631. }
  5632. }
  5633. else
  5634. {
  5635. SendClientMessageEx(index, COLOR_WHITE, "There was an issue, please try again.");
  5636. }
  5637. }
  5638. return 1;
  5639. }
  5640.  
  5641. forward OnGetSMSLog(playerid);
  5642. public OnGetSMSLog(playerid)
  5643. {
  5644. new string[128], sender[MAX_PLAYER_NAME], message[256], sDate[20], rows, fields;
  5645. cache_get_data(rows, fields, MainPipeline);
  5646. if(rows)
  5647. {
  5648. SendClientMessageEx(playerid, COLOR_GREEN, "________________________________________________");
  5649. SendClientMessageEx(playerid, COLOR_YELLOW, "<< Last 10 SMS Received >>");
  5650. for(new i; i < rows; i++)
  5651. {
  5652. cache_get_field_content(i, "sender", sender, MainPipeline, MAX_PLAYER_NAME);
  5653. cache_get_field_content(i, "sendernumber", string, MainPipeline); new sendernumber = strval(string);
  5654. cache_get_field_content(i, "message", message, MainPipeline, sizeof(message));
  5655. cache_get_field_content(i, "date", sDate, MainPipeline, sizeof(sDate));
  5656. if(sendernumber != 0) format(string, sizeof(string), "[%s] SMS: %s, Sender: %s (%d)", sDate, message, StripUnderscore(sender), sendernumber);
  5657. else format(string, sizeof(string), "[%s] SMS: %s, Sender: Unknown", sDate, message);
  5658. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  5659. }
  5660. }
  5661. else SendClientMessageEx(playerid, COLOR_GREY, "You have not received any SMS messages.");
  5662. return 1;
  5663. }
  5664.  
  5665. forward Group_QueryFinish(iType, iExtraID);
  5666. public Group_QueryFinish(iType, iExtraID) {
  5667.  
  5668. /*
  5669. Internally, every group array/subarray starts from zero (divisions, group ids etc)
  5670. When displaying to the clients or saving to the db, we add 1 to them!
  5671. The only exception is ranks which already start from zero.
  5672. */
  5673.  
  5674. new
  5675. iFields,
  5676. iRows,
  5677. iIndex,
  5678. i = 0,
  5679. szResult[128];
  5680.  
  5681. cache_get_data(iRows, iFields, MainPipeline);
  5682.  
  5683. switch(iType) {
  5684. case GROUP_QUERY_JURISDICTIONS:
  5685. {
  5686. for(new iG = 0; iG < MAX_GROUPS; iG++)
  5687. {
  5688. arrGroupData[iG][g_iJCount] = 0;
  5689. }
  5690. while(iIndex < iRows) {
  5691.  
  5692. cache_get_field_content(iIndex, "GroupID", szResult, MainPipeline, 24);
  5693. new iGroup = strval(szResult);
  5694.  
  5695. if(arrGroupData[iGroup][g_iJCount] > MAX_GROUP_JURISDICTIONS) arrGroupData[iGroup][g_iJCount] = MAX_GROUP_JURISDICTIONS;
  5696. if (!(0 <= iGroup < MAX_GROUPS)) break;
  5697. cache_get_field_content(iIndex, "id", szResult, MainPipeline, 24);
  5698. arrGroupJurisdictions[iGroup][arrGroupData[iGroup][g_iJCount]][g_iJurisdictionSQLId] = strval(szResult);
  5699. cache_get_field_content(iIndex, "AreaName", arrGroupJurisdictions[iGroup][arrGroupData[iGroup][g_iJCount]][g_iAreaName], MainPipeline, 64);
  5700. arrGroupData[iGroup][g_iJCount]++;
  5701. iIndex++;
  5702. }
  5703. }
  5704. case GROUP_QUERY_LOCKERS: while(iIndex < iRows) {
  5705.  
  5706. cache_get_field_content(iIndex, "Group_ID", szResult, MainPipeline);
  5707. new iGroup = strval(szResult)-1;
  5708.  
  5709. cache_get_field_content(iIndex, "Locker_ID", szResult, MainPipeline);
  5710. new iLocker = strval(szResult)-1;
  5711.  
  5712. if (!(0 <= iGroup < MAX_GROUPS)) break;
  5713. if (!(0 <= iLocker < MAX_GROUP_LOCKERS)) break;
  5714.  
  5715. cache_get_field_content(iIndex, "Id", szResult, MainPipeline);
  5716. arrGroupLockers[iGroup][iLocker][g_iLockerSQLId] = strval(szResult);
  5717.  
  5718. cache_get_field_content(iIndex, "LockerX", szResult, MainPipeline);
  5719. arrGroupLockers[iGroup][iLocker][g_fLockerPos][0] = floatstr(szResult);
  5720.  
  5721. cache_get_field_content(iIndex, "LockerY", szResult, MainPipeline);
  5722. arrGroupLockers[iGroup][iLocker][g_fLockerPos][1] = floatstr(szResult);
  5723.  
  5724. cache_get_field_content(iIndex, "LockerZ", szResult, MainPipeline);
  5725. arrGroupLockers[iGroup][iLocker][g_fLockerPos][2] = floatstr(szResult);
  5726.  
  5727. cache_get_field_content(iIndex, "LockerVW", szResult, MainPipeline);
  5728. arrGroupLockers[iGroup][iLocker][g_iLockerVW] = strval(szResult);
  5729.  
  5730. cache_get_field_content(iIndex, "LockerShare", szResult, MainPipeline);
  5731. arrGroupLockers[iGroup][iLocker][g_iLockerShare] = strval(szResult);
  5732.  
  5733. format(szResult, sizeof szResult, "%s Locker\n{1FBDFF}/locker{FFFF00} to use\n ID: %i", arrGroupData[iGroup][g_szGroupName], arrGroupLockers[iGroup][iLocker]);
  5734. arrGroupLockers[iGroup][iLocker][g_tLocker3DLabel] = CreateDynamic3DTextLabel(szResult, arrGroupData[iGroup][g_hDutyColour] * 256 + 0xFF, arrGroupLockers[iGroup][iLocker][g_fLockerPos][0], arrGroupLockers[iGroup][iLocker][g_fLockerPos][1], arrGroupLockers[iGroup][iLocker][g_fLockerPos][2], 15.0, .testlos = 1, .worldid = arrGroupLockers[iGroup][iLocker][g_iLockerVW]);
  5735. iIndex++;
  5736.  
  5737. }
  5738. case GROUP_QUERY_LOAD: while(iIndex < iRows) {
  5739. cache_get_field_content(iIndex, "Name", arrGroupData[iIndex][g_szGroupName], MainPipeline, GROUP_MAX_NAME_LEN);
  5740.  
  5741. cache_get_field_content(iIndex, "MOTD", arrGroupData[iIndex][g_szGroupMOTD], MainPipeline, GROUP_MAX_MOTD_LEN);
  5742.  
  5743. cache_get_field_content(iIndex, "Type", szResult, MainPipeline);
  5744. arrGroupData[iIndex][g_iGroupType] = strval(szResult);
  5745.  
  5746. cache_get_field_content(iIndex, "Allegiance", szResult, MainPipeline);
  5747. arrGroupData[iIndex][g_iAllegiance] = strval(szResult);
  5748.  
  5749. cache_get_field_content(iIndex, "Bug", szResult, MainPipeline);
  5750. arrGroupData[iIndex][g_iBugAccess] = strval(szResult);
  5751.  
  5752. cache_get_field_content(iIndex, "RadioColour", szResult, MainPipeline);
  5753. arrGroupData[iIndex][g_hRadioColour] = strval(szResult);
  5754.  
  5755. cache_get_field_content(iIndex, "Radio", szResult, MainPipeline);
  5756. arrGroupData[iIndex][g_iRadioAccess] = strval(szResult);
  5757.  
  5758. cache_get_field_content(iIndex, "DeptRadio", szResult, MainPipeline);
  5759. arrGroupData[iIndex][g_iDeptRadioAccess] = strval(szResult);
  5760.  
  5761. cache_get_field_content(iIndex, "IntRadio", szResult, MainPipeline);
  5762. arrGroupData[iIndex][g_iIntRadioAccess] = strval(szResult);
  5763.  
  5764. cache_get_field_content(iIndex, "GovAnnouncement", szResult, MainPipeline);
  5765. arrGroupData[iIndex][g_iGovAccess] = strval(szResult);
  5766.  
  5767. cache_get_field_content(iIndex, "FreeNameChange", szResult, MainPipeline);
  5768. arrGroupData[iIndex][g_iFreeNameChange] = strval(szResult);
  5769.  
  5770. cache_get_field_content(iIndex, "Budget", szResult, MainPipeline);
  5771. arrGroupData[iIndex][g_iBudget] = strval(szResult);
  5772.  
  5773. cache_get_field_content(iIndex, "BudgetPayment", szResult, MainPipeline);
  5774. arrGroupData[iIndex][g_iBudgetPayment] = strval(szResult);
  5775.  
  5776. cache_get_field_content(iIndex, "SpikeStrips", szResult, MainPipeline);
  5777. arrGroupData[iIndex][g_iSpikeStrips] = strval(szResult);
  5778.  
  5779. cache_get_field_content(iIndex, "Barricades", szResult, MainPipeline);
  5780. arrGroupData[iIndex][g_iBarricades] = strval(szResult);
  5781.  
  5782. cache_get_field_content(iIndex, "Cones", szResult, MainPipeline);
  5783. arrGroupData[iIndex][g_iCones] = strval(szResult);
  5784.  
  5785. cache_get_field_content(iIndex, "Flares", szResult, MainPipeline);
  5786. arrGroupData[iIndex][g_iFlares] = strval(szResult);
  5787.  
  5788. cache_get_field_content(iIndex, "Barrels", szResult, MainPipeline);
  5789. arrGroupData[iIndex][g_iBarrels] = strval(szResult);
  5790.  
  5791. cache_get_field_content(iIndex, "DutyColour", szResult, MainPipeline);
  5792. arrGroupData[iIndex][g_hDutyColour] = strval(szResult);
  5793.  
  5794. cache_get_field_content(iIndex, "Stock", szResult, MainPipeline);
  5795. arrGroupData[iIndex][g_iLockerStock] = strval(szResult);
  5796.  
  5797. cache_get_field_content(iIndex, "CrateX", szResult, MainPipeline);
  5798. arrGroupData[iIndex][g_fCratePos][0] = floatstr(szResult);
  5799.  
  5800. cache_get_field_content(iIndex, "CrateY", szResult, MainPipeline);
  5801. arrGroupData[iIndex][g_fCratePos][1] = floatstr(szResult);
  5802.  
  5803. cache_get_field_content(iIndex, "CrateZ", szResult, MainPipeline);
  5804. arrGroupData[iIndex][g_fCratePos][2] = floatstr(szResult);
  5805.  
  5806. cache_get_field_content(iIndex, "LockerCostType", szResult, MainPipeline);
  5807. arrGroupData[iIndex][g_iLockerCostType] = strval(szResult);
  5808.  
  5809. cache_get_field_content(iIndex, "CratesOrder", szResult, MainPipeline);
  5810. arrGroupData[iIndex][g_iCratesOrder] = strval(szResult);
  5811.  
  5812. cache_get_field_content(iIndex, "CrateIsland", szResult, MainPipeline);
  5813. arrGroupData[iIndex][g_iCrateIsland] = strval(szResult);
  5814.  
  5815. cache_get_field_content(iIndex, "GarageX", szResult, MainPipeline);
  5816. arrGroupData[iIndex][g_fGaragePos][0] = floatstr(szResult);
  5817.  
  5818. cache_get_field_content(iIndex, "GarageY", szResult, MainPipeline);
  5819. arrGroupData[iIndex][g_fGaragePos][1] = floatstr(szResult);
  5820.  
  5821. cache_get_field_content(iIndex, "GarageZ", szResult, MainPipeline);
  5822. arrGroupData[iIndex][g_fGaragePos][2] = floatstr(szResult);
  5823.  
  5824. while(i < MAX_GROUP_RANKS) {
  5825. format(szResult, sizeof szResult, "Rank%i", i);
  5826. cache_get_field_content(iIndex, szResult, arrGroupRanks[iIndex][i], MainPipeline, GROUP_MAX_RANK_LEN);
  5827. format(szResult, sizeof szResult, "Rank%iPay", i);
  5828. cache_get_field_content(iIndex, szResult, szResult, MainPipeline);
  5829. arrGroupData[iIndex][g_iPaycheck][i] = strval(szResult);
  5830. i++;
  5831. }
  5832. i = 0;
  5833.  
  5834. while(i < MAX_GROUP_DIVS) {
  5835. format(szResult, sizeof szResult, "Div%i", i + 1);
  5836. cache_get_field_content(iIndex, szResult, arrGroupDivisions[iIndex][i], MainPipeline, GROUP_MAX_DIV_LEN);
  5837. i++;
  5838. }
  5839. i = 0;
  5840.  
  5841. while(i < MAX_GROUP_WEAPONS) {
  5842. format(szResult, sizeof szResult, "Gun%i", i + 1);
  5843. cache_get_field_content(iIndex, szResult, szResult, MainPipeline);
  5844. arrGroupData[iIndex][g_iLockerGuns][i] = strval(szResult);
  5845. format(szResult, sizeof szResult, "Cost%i", i + 1);
  5846. cache_get_field_content(iIndex, szResult, szResult, MainPipeline);
  5847. arrGroupData[iIndex][g_iLockerCost][i] = strval(szResult);
  5848. i++;
  5849. }
  5850. i = 0;
  5851.  
  5852. if (arrGroupData[iIndex][g_szGroupName][0] && arrGroupData[iIndex][g_fCratePos][0] != 0.0)
  5853. {
  5854. format(szResult, sizeof szResult, "%s Crate Delivery Point\n{1FBDFF}/delivercrate", arrGroupData[iIndex][g_szGroupName]);
  5855. arrGroupData[iIndex][g_tCrate3DLabel] = CreateDynamic3DTextLabel(szResult, arrGroupData[iIndex][g_hDutyColour] * 256 + 0xFF, arrGroupData[iIndex][g_fCratePos][0], arrGroupData[iIndex][g_fCratePos][1], arrGroupData[iIndex][g_fCratePos][2], 10.0, .testlos = 1, .streamdistance = 20.0);
  5856. }
  5857. iIndex++;
  5858. }
  5859.  
  5860. case GROUP_QUERY_INVITE: if(GetPVarType(iExtraID, "Group_Invited")) {
  5861. if(!iRows) {
  5862.  
  5863. i = GetPVarInt(iExtraID, "Group_Invited");
  5864. iIndex = PlayerInfo[iExtraID][pMember];
  5865.  
  5866. format(szResult, sizeof szResult, "%s %s has offered you an invite to %s (type /accept group to join).", arrGroupRanks[iIndex][PlayerInfo[iExtraID][pRank]], GetPlayerNameEx(iExtraID), arrGroupData[iIndex][g_szGroupName]);
  5867. SendClientMessageEx(i, COLOR_LIGHTBLUE, szResult);
  5868.  
  5869. format(szResult, sizeof szResult, "You have offered %s to join %s.", GetPlayerNameEx(i), arrGroupData[iIndex][g_szGroupName]);
  5870. SendClientMessageEx(iExtraID, COLOR_LIGHTBLUE, szResult);
  5871. SetPVarInt(i, "Group_Inviter", iExtraID);
  5872. }
  5873. else {
  5874. SendClientMessage(iExtraID, COLOR_GREY, "That person is banned from joining this group.");
  5875. DeletePVar(iExtraID, "Group_Invited");
  5876. }
  5877. }
  5878. case GROUP_QUERY_ADDBAN: {
  5879. new string[128];
  5880. new otherplayer = GetPVarInt(iExtraID, "GroupBanningPlayer");
  5881. new group = GetPVarInt(iExtraID, "GroupBanningGroup");
  5882. format(string, sizeof(string), "You have group-banned %s from group %d.", GetPlayerNameEx(otherplayer), group);
  5883. SendClientMessageEx(iExtraID, COLOR_WHITE, string);
  5884. format(string, sizeof(string), "You have been group-banned, by %s.", GetPlayerNameEx(iExtraID));
  5885. SendClientMessageEx(otherplayer, COLOR_LIGHTBLUE, string);
  5886. format(string, sizeof(string), "Administrator %s has group-banned %s from %s (%d)", GetPlayerNameEx(iExtraID), GetPlayerNameEx(otherplayer), arrGroupData[PlayerInfo[otherplayer][pMember]][g_szGroupName], PlayerInfo[otherplayer][pMember]);
  5887. Log("logs/group.log", string);
  5888. PlayerInfo[otherplayer][pMember] = INVALID_GROUP_ID;
  5889. PlayerInfo[otherplayer][pLeader] = INVALID_GROUP_ID;
  5890. PlayerInfo[otherplayer][pRank] = INVALID_RANK;
  5891. PlayerInfo[otherplayer][pDuty] = 0;
  5892. PlayerInfo[otherplayer][pDivision] = INVALID_DIVISION;
  5893. new rand = random(sizeof(CIV));
  5894. PlayerInfo[otherplayer][pModel] = CIV[rand];
  5895. SetPlayerToTeamColor(otherplayer);
  5896. SetPlayerSkin(otherplayer, CIV[rand]);
  5897. OnPlayerStatsUpdate(otherplayer);
  5898. DeletePVar(iExtraID, "GroupBanningPlayer");
  5899. DeletePVar(iExtraID, "GroupBanningGroup");
  5900. }
  5901.  
  5902. case GROUP_QUERY_UNBAN: {
  5903. new string[128];
  5904. new otherplayer = GetPVarInt(iExtraID, "GroupUnBanningPlayer");
  5905. new group = GetPVarInt(iExtraID, "GroupUnBanningGroup");
  5906. if(mysql_affected_rows(MainPipeline))
  5907. {
  5908. format(string, sizeof(string), "You have group-unbanned %s from group %s (%d).", GetPlayerNameEx(otherplayer), arrGroupData[group][g_szGroupName], group);
  5909. SendClientMessageEx(iExtraID, COLOR_WHITE, string);
  5910. format(string, sizeof(string), "You have been group-unbanned from %s, by %s.", arrGroupData[group][g_szGroupName], GetPlayerNameEx(iExtraID));
  5911. SendClientMessageEx(otherplayer, COLOR_LIGHTBLUE, string);
  5912. format(string, sizeof(string), "Administrator %s has group-unbanned %s from %s (%d)", GetPlayerNameEx(iExtraID), GetPlayerNameEx(otherplayer), arrGroupData[group][g_szGroupName], group);
  5913. Log("logs/group.log", string);
  5914. }
  5915. else
  5916. {
  5917. format(string, sizeof(string), "There was an issue group-unbanning %s from %s (%d)", GetPlayerNameEx(otherplayer), arrGroupData[group][g_szGroupName], group);
  5918. SendClientMessageEx(iExtraID, COLOR_WHITE, string);
  5919. }
  5920. DeletePVar(iExtraID, "GroupUnBanningPlayer");
  5921. DeletePVar(iExtraID, "GroupUnBanningGroup");
  5922. }
  5923. case GROUP_QUERY_UNCHECK: if(GetPVarType(iExtraID, "Group_Uninv")) {
  5924. if(iRows) {
  5925. cache_get_field_content(0, "Member", szResult, MainPipeline, MAX_PLAYER_NAME);
  5926. if(strval(szResult) == PlayerInfo[iExtraID][pMember]) {
  5927. cache_get_field_content(0, "Rank", szResult, MainPipeline);
  5928. if(PlayerInfo[iExtraID][pRank] > strval(szResult) || PlayerInfo[iExtraID][pRank] >= Group_GetMaxRank(PlayerInfo[iExtraID][pMember])) {
  5929. cache_get_field_content(0, "ID", szResult, MainPipeline);
  5930. format(szResult, sizeof szResult, "UPDATE `accounts` SET `Model` = "#NOOB_SKIN", `Member` = "#INVALID_GROUP_ID", `Rank` = "#INVALID_RANK", `Leader` = "#INVALID_GROUP_ID", `Division` = -1 WHERE `id` = %i", strval(szResult));
  5931. mysql_function_query(MainPipeline, szResult, true, "Group_QueryFinish", "ii", GROUP_QUERY_UNINVITE, iExtraID);
  5932. }
  5933. else SendClientMessage(iExtraID, COLOR_GREY, "You can't do this to a person of equal or higher rank.");
  5934. }
  5935. else SendClientMessage(iExtraID, COLOR_GREY, "That person is not in your group.");
  5936.  
  5937. }
  5938. else {
  5939. SendClientMessage(iExtraID, COLOR_GREY, "That account does not exist.");
  5940. DeletePVar(iExtraID, "Group_Uninv");
  5941. }
  5942. }
  5943. case GROUP_QUERY_UNINVITE: if(GetPVarType(iExtraID, "Group_Uninv")) {
  5944.  
  5945. new
  5946. szName[MAX_PLAYER_NAME],
  5947. iGroupID = PlayerInfo[iExtraID][pMember];
  5948.  
  5949. GetPVarString(iExtraID, "Group_Uninv", szName, sizeof szName);
  5950. if(mysql_affected_rows(MainPipeline)) {
  5951.  
  5952. i = PlayerInfo[iExtraID][pRank];
  5953. format(szResult, sizeof szResult, "You have successfully removed %s from your group.", szName);
  5954. SendClientMessage(iExtraID, COLOR_GREY, szResult);
  5955.  
  5956. format(szResult, sizeof szResult, "%s %s (rank %i) has offline uninvited %s from %s (%i).", arrGroupRanks[iGroupID][i], GetPlayerNameEx(iExtraID), i + 1, szName, arrGroupData[iGroupID][g_szGroupName], iGroupID + 1);
  5957. Log("logs/group.log", szResult);
  5958. }
  5959. else {
  5960. format(szResult, sizeof szResult, "An error was encountered while attempting to remove %s from your group.", szName);
  5961. SendClientMessage(iExtraID, COLOR_GREY, szResult);
  5962. }
  5963. DeletePVar(iExtraID, "Group_Uninv");
  5964. }
  5965. }
  5966. }
  5967.  
  5968. forward Jurisdiction_RehashFinish(iGroup);
  5969. public Jurisdiction_RehashFinish(iGroup) {
  5970.  
  5971. new
  5972. iFields,
  5973. iRows,
  5974. iIndex,
  5975. szResult[128];
  5976.  
  5977. cache_get_data(iRows, iFields, MainPipeline);
  5978.  
  5979. while(iIndex < iRows)
  5980. {
  5981. new iGroupID;
  5982. arrGroupData[iGroup][g_iJCount] = iRows;
  5983. if(arrGroupData[iGroup][g_iJCount] > MAX_GROUP_JURISDICTIONS) {
  5984. arrGroupData[iGroup][g_iJCount] = MAX_GROUP_JURISDICTIONS;
  5985. }
  5986. cache_get_field_content(iIndex, "GroupID", szResult, MainPipeline, 24);
  5987. iGroupID = strval(szResult);
  5988. if(iGroupID == iGroup)
  5989. {
  5990. cache_get_field_content(iIndex, "id", szResult, MainPipeline, 64);
  5991. arrGroupJurisdictions[iGroup][iIndex][g_iJurisdictionSQLId] = strval(szResult);
  5992. cache_get_field_content(iIndex, "AreaName", arrGroupJurisdictions[iGroup][iIndex][g_iAreaName], MainPipeline, 64);
  5993. }
  5994. iIndex++;
  5995. }
  5996. }
  5997.  
  5998. forward DynVeh_QueryFinish(iType, iExtraID);
  5999. public DynVeh_QueryFinish(iType, iExtraID) {
  6000.  
  6001. new
  6002. iFields,
  6003. iRows,
  6004. iIndex,
  6005. i = 0,
  6006. sqlid,
  6007. szResult[128];
  6008.  
  6009. cache_get_data(iRows, iFields, MainPipeline);
  6010. switch(iType) {
  6011. case GV_QUERY_LOAD:
  6012. {
  6013. format(szResult, sizeof(szResult), "UPDATE `groupvehs` SET `SpawnedID` = %d", INVALID_VEHICLE_ID);
  6014. mysql_function_query(MainPipeline, szResult, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6015. while((iIndex < iRows) && (iIndex < MAX_DYNAMIC_VEHICLES)) {
  6016. cache_get_field_content(iIndex, "id", szResult, MainPipeline); sqlid = strval(szResult);
  6017. if((sqlid >= MAX_DYNAMIC_VEHICLES)) {// Array bounds check. Use it.
  6018. format(szResult, sizeof(szResult), "DELETE FROM `groupvehs` WHERE `id` = %d", sqlid);
  6019. mysql_function_query(MainPipeline, szResult, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6020. return printf("SQL ID %d exceeds Max Dynamic Vehicles", sqlid);
  6021. }
  6022. cache_get_field_content(iIndex, "gID", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_igID] = strval(szResult);
  6023. cache_get_field_content(iIndex, "gDivID", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_igDivID] = strval(szResult);
  6024. cache_get_field_content(iIndex, "fID", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_ifID] = strval(szResult);
  6025. cache_get_field_content(iIndex, "rID", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_irID] = strval(szResult);
  6026. cache_get_field_content(iIndex, "vModel", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iModel] = strval(szResult);
  6027. switch(DynVehicleInfo[sqlid][gv_iModel]) {
  6028. case 538, 537, 449, 590, 569, 570: {
  6029. DynVehicleInfo[sqlid][gv_iModel] = 0;
  6030. }
  6031. }
  6032. cache_get_field_content(iIndex, "vPlate", DynVehicleInfo[sqlid][gv_iPlate], MainPipeline, 32);
  6033. cache_get_field_content(iIndex, "vMaxHealth", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fMaxHealth] = floatstr(szResult);
  6034. cache_get_field_content(iIndex, "vType", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iType] = strval(szResult);
  6035. cache_get_field_content(iIndex, "vLoadMax", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iLoadMax] = strval(szResult);
  6036. if(DynVehicleInfo[sqlid][gv_iLoadMax] > 6) {
  6037. DynVehicleInfo[sqlid][gv_iLoadMax] = 6;
  6038. }
  6039. cache_get_field_content(iIndex, "vCol1", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iCol1] = strval(szResult);
  6040. cache_get_field_content(iIndex, "vCol2", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iCol2] = strval(szResult);
  6041. cache_get_field_content(iIndex, "vX", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fX] = floatstr(szResult);
  6042. cache_get_field_content(iIndex, "vY", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fY] = floatstr(szResult);
  6043. cache_get_field_content(iIndex, "vZ", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fZ] = floatstr(szResult);
  6044. cache_get_field_content(iIndex, "vVW", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iVW] = strval(szResult);
  6045. cache_get_field_content(iIndex, "vInt", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iInt] = strval(szResult);
  6046. cache_get_field_content(iIndex, "vDisabled", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iDisabled] = strval(szResult);
  6047. cache_get_field_content(iIndex, "vRotZ", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fRotZ] = floatstr(szResult);
  6048. cache_get_field_content(iIndex, "vUpkeep", szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iUpkeep] = strval(szResult);
  6049. i = 1;
  6050. while(i <= MAX_DV_OBJECTS) {
  6051. format(szResult, sizeof szResult, "vAttachedObjectModel%i", i);
  6052. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iAttachedObjectModel][i-1] = strval(szResult);
  6053. format(szResult, sizeof szResult, "vObjectX%i", i);
  6054. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fObjectX][i-1] = floatstr(szResult);
  6055. format(szResult, sizeof szResult, "vObjectY%i", i);
  6056. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fObjectY][i-1] = floatstr(szResult);
  6057. format(szResult, sizeof szResult, "vObjectZ%i", i);
  6058. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fObjectZ][i-1] = floatstr(szResult);
  6059. format(szResult, sizeof szResult, "vObjectRX%i", i);
  6060. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fObjectRX][i-1] = floatstr(szResult);
  6061. format(szResult, sizeof szResult, "vObjectRY%i", i);
  6062. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fObjectRY][i-1] = floatstr(szResult);
  6063. format(szResult, sizeof szResult, "vObjectRZ%i", i);
  6064. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_fObjectRZ][i-1] = floatstr(szResult);
  6065. i++;
  6066. }
  6067. i = 0;
  6068. while(i < MAX_DV_MODS) {
  6069. format(szResult, sizeof szResult, "vMod%i", i);
  6070. cache_get_field_content(iIndex, szResult, szResult, MainPipeline); DynVehicleInfo[sqlid][gv_iMod][i++] = strval(szResult);
  6071. }
  6072.  
  6073. if(400 < DynVehicleInfo[sqlid][gv_iModel] < 612) {
  6074. if(!IsWeaponizedVehicle(DynVehicleInfo[sqlid][gv_iModel])) {
  6075. DynVeh_Spawn(iIndex);
  6076. //printf("[DynVeh] Loaded Dynamic Vehicle %i.", iIndex);
  6077. for(i = 0; i != MAX_DV_OBJECTS; i++)
  6078. {
  6079. if(DynVehicleInfo[sqlid][gv_iAttachedObjectModel][i] == 0 || DynVehicleInfo[sqlid][gv_iAttachedObjectModel][i] == INVALID_OBJECT_ID) {
  6080. DynVehicleInfo[sqlid][gv_iAttachedObjectID][i] = INVALID_OBJECT_ID;
  6081. DynVehicleInfo[sqlid][gv_iAttachedObjectModel][i] = INVALID_OBJECT_ID;
  6082. }
  6083. }
  6084. } else {
  6085. DynVehicleInfo[sqlid][gv_iSpawnedID] = INVALID_VEHICLE_ID;
  6086. }
  6087. }
  6088. iIndex++;
  6089. }
  6090. }
  6091. }
  6092. return 1;
  6093. }
  6094.  
  6095. forward LoadBusinessesSaless();
  6096. public LoadBusinessesSaless() {
  6097.  
  6098. new
  6099. iFields,
  6100. iRows,
  6101. iIndex,
  6102. szResult[128];
  6103.  
  6104. cache_get_data(iRows, iFields, MainPipeline);
  6105.  
  6106. while((iIndex < iRows)) {
  6107. cache_get_field_content(iIndex, "bID", szResult, MainPipeline); BusinessSales[iIndex][bID] = strval(szResult);
  6108. iIndex++;
  6109. }
  6110. return 1;
  6111. }
  6112.  
  6113. forward AuctionLoadQuery();
  6114. public AuctionLoadQuery() {
  6115.  
  6116. new
  6117. iFields,
  6118. iRows,
  6119. iIndex,
  6120. szResult[128];
  6121.  
  6122. cache_get_data(iRows, iFields, MainPipeline);
  6123.  
  6124. while((iIndex < iRows)) {
  6125. cache_get_field_content(iIndex, "BiddingFor", Auctions[iIndex][BiddingFor], MainPipeline, 64);
  6126. cache_get_field_content(iIndex, "Increment", szResult, MainPipeline); Auctions[iIndex][Increment] = strval(szResult);
  6127. if(Auctions[iIndex][InProgress] == 1 && Auctions[iIndex][Expires] != 0)
  6128. {
  6129. Auctions[iIndex][Timer] = SetTimerEx("EndAuction", 60000, true, "i", iIndex);
  6130. printf("[auction - %i - started] %s, %d, %d, %d, %d, %s, %d",iIndex, Auctions[iIndex][BiddingFor],Auctions[iIndex][InProgress],Auctions[iIndex][Bid],Auctions[iIndex][Bidder],Auctions[iIndex][Expires],Auctions[iIndex][Wining],Auctions[iIndex][Increment]);
  6131. }
  6132. iIndex++;
  6133. }
  6134. return 1;
  6135. }
  6136.  
  6137. forward PlantsLoadQuery();
  6138. public PlantsLoadQuery() {
  6139.  
  6140. new
  6141. iFields,
  6142. iRows,
  6143. iIndex,
  6144. szResult[128];
  6145.  
  6146. cache_get_data(iRows, iFields, MainPipeline);
  6147.  
  6148. while((iIndex < iRows)) {
  6149. cache_get_field_content(iIndex, "Owner", szResult, MainPipeline); Plants[iIndex][pOwner] = strval(szResult);
  6150. cache_get_field_content(iIndex, "Object", szResult, MainPipeline); Plants[iIndex][pObject] = strval(szResult);
  6151. cache_get_field_content(iIndex, "DrugsSkill", szResult, MainPipeline); Plants[iIndex][pDrugsSkill] = strval(szResult);
  6152.  
  6153. if(Plants[iIndex][pOwner] != 0) {
  6154. Plants[iIndex][pObjectSpawned] = CreateDynamicObject(Plants[iIndex][pObject], Plants[iIndex][pPos][0], Plants[iIndex][pPos][1], Plants[iIndex][pPos][2], 0.0, 0.0, 0.0, Plants[iIndex][pVirtual], Plants[iIndex][pInterior]);
  6155. }
  6156. iIndex++;
  6157. }
  6158. if(iIndex > 0) printf("[LoadPlants] Successfully loaded %d plants", iIndex);
  6159. else printf("[LoadPlants] Error: Failed to load any plants!");
  6160. return 1;
  6161. }
  6162.  
  6163. forward BusinessesLoadQueryFinish();
  6164. public BusinessesLoadQueryFinish()
  6165. {
  6166.  
  6167. new i, rows, fields, tmp[128];
  6168. cache_get_data(rows, fields, MainPipeline);
  6169. while(i < rows)
  6170. {
  6171. cache_get_field_content(i, "Name", Businesses[i][bName], MainPipeline, MAX_BUSINESS_NAME);
  6172. cache_get_field_content(i, "OwnerID", tmp, MainPipeline); Businesses[i][bOwner] = strval(tmp);
  6173. cache_get_field_content(i, "Months", tmp, MainPipeline); Businesses[i][bMonths] = strval(tmp);
  6174. cache_get_field_content(i, "GymEntryFee", tmp, MainPipeline); Businesses[i][bGymEntryFee] = strval(tmp);
  6175. cache_get_field_content(i, "GymType", tmp, MainPipeline); Businesses[i][bGymType] = strval(tmp);
  6176.  
  6177. if (Businesses[i][bOrderState] == 2) {
  6178. Businesses[i][bOrderState] = 1;
  6179. }
  6180.  
  6181. RefreshBusinessPickup(i);
  6182.  
  6183. for (new j; j <= 5; j++)
  6184. {
  6185. new col[9];
  6186. format(col, sizeof(col), "Rank%dPay", j);
  6187. cache_get_field_content(i, col, tmp, MainPipeline);
  6188. Businesses[i][bRankPay][j] = strval(tmp);
  6189. }
  6190.  
  6191. if (Businesses[i][bType] == BUSINESS_TYPE_GASSTATION)
  6192. {
  6193. for (new j, column[17]; j < MAX_BUSINESS_GAS_PUMPS; j++)
  6194. {
  6195. format(column, sizeof(column), "GasPump%dPosX", j + 1);
  6196. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][GasPumpPosX][j] = floatstr(tmp);
  6197. format(column, sizeof(column), "GasPump%dPosY", j + 1);
  6198. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][GasPumpPosY][j] = floatstr(tmp);
  6199. format(column, sizeof(column), "GasPump%dPosZ", j + 1);
  6200. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][GasPumpPosZ][j] = floatstr(tmp);
  6201. format(column, sizeof(column), "GasPump%dAngle", j + 1);
  6202. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][GasPumpAngle][j] = floatstr(tmp);
  6203. format(column, sizeof(column), "GasPump%dCapacity", j + 1);
  6204. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][GasPumpCapacity][j] = floatstr(tmp);
  6205. format(column, sizeof(column), "GasPump%dGas", j + 1);
  6206. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][GasPumpGallons][j] = floatstr(tmp);
  6207. CreateDynamicGasPump(_, i, j);
  6208.  
  6209. for (new z; z <= 17; z++)
  6210. {
  6211. new col[12];
  6212. format(col, sizeof(col), "Item%dPrice", z + 1);
  6213. cache_get_field_content(i, col, tmp, MainPipeline);
  6214. Businesses[i][bItemPrices][z] = strval(tmp);
  6215. }
  6216. }
  6217. }
  6218. else if (Businesses[i][bType] == BUSINESS_TYPE_NEWCARDEALERSHIP || Businesses[i][bType] == BUSINESS_TYPE_OLDCARDEALERSHIP)
  6219. {
  6220. for (new j, column[16], label[50]; j < MAX_BUSINESS_DEALERSHIP_VEHICLES; j++)
  6221. {
  6222.  
  6223. format(column, sizeof(column), "Car%dModelId", j);
  6224. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][bModel][j] = strval(tmp);
  6225. format(column, sizeof(column), "Car%dPosX", j);
  6226. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][bParkPosX][j] = floatstr(tmp);
  6227. format(column, sizeof(column), "Car%dPosY", j);
  6228. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][bParkPosY][j] = floatstr(tmp);
  6229. format(column, sizeof(column), "Car%dPosZ", j);
  6230. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][bParkPosZ][j] = floatstr(tmp);
  6231. format(column, sizeof(column), "Car%dPosAngle", j);
  6232. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][bParkAngle][j] = floatstr(tmp);
  6233. format(column, sizeof(column), "Car%dPrice", j);
  6234. cache_get_field_content(i, column, tmp, MainPipeline); Businesses[i][bPrice][j] = strval(tmp);
  6235.  
  6236. cache_get_field_content(i, "PurchaseX", tmp, MainPipeline); Businesses[i][bPurchaseX][j] = strval(tmp);
  6237. cache_get_field_content(i, "PurchaseY", tmp, MainPipeline); Businesses[i][bPurchaseY][j] = strval(tmp);
  6238. cache_get_field_content(i, "PurchaseZ", tmp, MainPipeline); Businesses[i][bPurchaseZ][j] = strval(tmp);
  6239. cache_get_field_content(i, "PurchaseAngle", tmp, MainPipeline); Businesses[i][bPurchaseAngle][j] = strval(tmp);
  6240.  
  6241. if(400 < Businesses[i][bModel][j] < 612) {
  6242. Businesses[i][bVehID][j] = CreateVehicle(Businesses[i][bModel][j], Businesses[i][bParkPosX][j], Businesses[i][bParkPosY][j], Businesses[i][bParkPosZ][j], Businesses[i][bParkAngle][j], Businesses[i][bColor1][j], Businesses[i][bColor2][j], 10);
  6243. format(label, sizeof(label), "%s For Sale | Price: $%s", GetVehicleName(Businesses[i][bVehID][j]), number_format(Businesses[i][bPrice][j]));
  6244. Businesses[i][bVehicleLabel][j] = CreateDynamic3DTextLabel(label,COLOR_LIGHTBLUE,Businesses[i][bParkPosX][j], Businesses[i][bParkPosY][j], Businesses[i][bParkPosZ][j],8.0,INVALID_PLAYER_ID, Businesses[i][bVehID][j]);
  6245. }
  6246. }
  6247. }
  6248. else
  6249. {
  6250. for (new j; j <= 17; j++)
  6251. {
  6252. new col[12];
  6253. format(col, sizeof(col), "Item%dPrice", j + 1);
  6254. cache_get_field_content(i, col, tmp, MainPipeline);
  6255. Businesses[i][bItemPrices][j] = strval(tmp);
  6256. }
  6257. }
  6258.  
  6259. Businesses[i][bGymBoxingArena1][0] = INVALID_PLAYER_ID;
  6260. Businesses[i][bGymBoxingArena1][1] = INVALID_PLAYER_ID;
  6261. Businesses[i][bGymBoxingArena2][0] = INVALID_PLAYER_ID;
  6262. Businesses[i][bGymBoxingArena2][1] = INVALID_PLAYER_ID;
  6263.  
  6264. for (new it = 0; it < 10; ++it)
  6265. {
  6266. Businesses[i][bGymBikePlayers][it] = INVALID_PLAYER_ID;
  6267. Businesses[i][bGymBikeVehicles][it] = INVALID_VEHICLE_ID;
  6268. }
  6269.  
  6270. i++;
  6271. }
  6272. if(i > 0) printf("[LoadBusinesses] %d businesses rehashed/loaded.", i);
  6273. else printf("[LoadBusinesses] Failed to load any businesses.");
  6274. }
  6275.  
  6276. forward ReturnMoney(index);
  6277. public ReturnMoney(index)
  6278. {
  6279. if(IsPlayerConnected(index))
  6280. {
  6281. new
  6282. AuctionItem = GetPVarInt(index, "AuctionItem");
  6283.  
  6284. new money[15], money2, string[128];
  6285. new rows, fields;
  6286. cache_get_data(rows, fields, MainPipeline);
  6287. if(rows)
  6288. {
  6289. cache_get_field_content(0, "Money", money, MainPipeline); money2 = strval(money);
  6290.  
  6291. format(string, sizeof(string), "UPDATE `accounts` SET `Money` = %d WHERE `id` = '%d'", money2+Auctions[AuctionItem][Bid], Auctions[AuctionItem][Bidder]);
  6292. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6293.  
  6294. format(string, sizeof(string), "Amount of $%d (Before: %i | After: %i) has been returned to (id: %i) for being outbid", Auctions[AuctionItem][Bid], money2,Auctions[AuctionItem][Bid]+money2, Auctions[AuctionItem][Bidder]);
  6295. Log("logs/auction.log", string);
  6296.  
  6297. GivePlayerCash(index, -GetPVarInt(index, "BidPlaced"));
  6298. Auctions[AuctionItem][Bid] = GetPVarInt(index, "BidPlaced");
  6299. Auctions[AuctionItem][Bidder] = GetPlayerSQLId(index);
  6300. strcpy(Auctions[AuctionItem][Wining], GetPlayerNameExt(index), MAX_PLAYER_NAME);
  6301.  
  6302. format(string, sizeof(string), "You have placed a bid of %i on %s.", GetPVarInt(index, "BidPlaced"), Auctions[AuctionItem][BiddingFor]);
  6303. SendClientMessageEx(index, COLOR_WHITE, string);
  6304.  
  6305. format(string, sizeof(string), "%s (IP:%s) has placed a bid of %i on %s(%i)", GetPlayerNameEx(index), GetPlayerIpEx(index), GetPVarInt(index, "BidPlaced"), Auctions[AuctionItem][BiddingFor], AuctionItem);
  6306. Log("logs/auction.log", string);
  6307.  
  6308. SaveAuction(AuctionItem);
  6309.  
  6310. DeletePVar(index, "BidPlaced");
  6311. DeletePVar(index, "AuctionItem");
  6312. }
  6313. else
  6314. {
  6315. printf("[AuctionError] id: %i | money %i", Auctions[AuctionItem][Bidder], Auctions[AuctionItem][Bid]);
  6316. }
  6317. }
  6318. return 1;
  6319. }
  6320.  
  6321. forward OnQueryCreateVehicle(playerid, playervehicleid);
  6322. public OnQueryCreateVehicle(playerid, playervehicleid)
  6323. {
  6324. PlayerVehicleInfo[playerid][playervehicleid][pvSlotId] = mysql_insert_id(MainPipeline);
  6325. printf("VNumber: %d", PlayerVehicleInfo[playerid][playervehicleid][pvSlotId]);
  6326.  
  6327. new string[128];
  6328. format(string, sizeof(string), "UPDATE `vehicles` SET `pvModelId` = %d WHERE `id` = %d", PlayerVehicleInfo[playerid][playervehicleid][pvModelId], PlayerVehicleInfo[playerid][playervehicleid][pvSlotId]);
  6329. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6330.  
  6331. g_mysql_SaveVehicle(playerid, playervehicleid);
  6332. }
  6333.  
  6334. forward CheckAccounts(playerid);
  6335. public CheckAccounts(playerid)
  6336. {
  6337. if(IsPlayerConnected(playerid))
  6338. {
  6339. new szString[128];
  6340. new rows, fields;
  6341. cache_get_data(rows, fields, MainPipeline);
  6342. if(rows)
  6343. {
  6344. format(szString, sizeof(szString), "{AA3333}AdmWarning{FFFF00}: Moderator %s has logged into the server with s0beit installed.", GetPlayerNameEx(playerid));
  6345. ABroadCast(COLOR_YELLOW, szString, 2);
  6346.  
  6347. format(szString, sizeof(szString), "Admin %s (IP: %s) has logged into the server with s0beit installed.", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid));
  6348. Log("logs/sobeit.log", szString);
  6349. sobeitCheckvar[playerid] = 1;
  6350. sobeitCheckIsDone[playerid] = 1;
  6351. IsPlayerFrozen[playerid] = 0;
  6352. }
  6353. else
  6354. {
  6355. format(szString, sizeof(szString), "INSERT INTO `sobeitkicks` (sqlID, Kicks) VALUES (%d, 1) ON DUPLICATE KEY UPDATE Kicks = Kicks + 1", GetPlayerSQLId(playerid));
  6356. mysql_function_query(MainPipeline, szString, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  6357.  
  6358. SendClientMessageEx(playerid, COLOR_RED, "The hacking tool 's0beit' is not allowed on this server, please uninstall it.");
  6359. format(szString, sizeof(szString), "%s (IP: %s) has logged into the server with s0beit installed.", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid));
  6360. Log("logs/sobeit.log", szString);
  6361. sobeitCheckvar[playerid] = 1;
  6362. sobeitCheckIsDone[playerid] = 1;
  6363. IsPlayerFrozen[playerid] = 0;
  6364. SetTimerEx("KickEx", 1000, 0, "i", playerid);
  6365. }
  6366. }
  6367. return 1;
  6368. }
  6369.  
  6370. forward ReferralSecurity(playerid);
  6371. public ReferralSecurity(playerid)
  6372. {
  6373. new newrows, newfields, newresult[16], currentIP[16], szString[128];
  6374. GetPlayerIp(playerid, currentIP, sizeof(currentIP));
  6375. cache_get_data(newrows, newfields, MainPipeline);
  6376.  
  6377. if(newrows > 0)
  6378. {
  6379. cache_get_field_content(0, "IP", newresult, MainPipeline);
  6380.  
  6381. if(!strcmp(newresult, currentIP, true))
  6382. {
  6383. format(szString, sizeof(szString), "Nobody");
  6384. strmid(PlayerInfo[playerid][pReferredBy], szString, 0, strlen(szString), MAX_PLAYER_NAME);
  6385. ShowPlayerDialog(playerid, REGISTERREF, DIALOG_STYLE_INPUT, "{FF0000}Error", "This person has the same IP as you.\nPlease choose another player that is not on your network.\n\nIf you haven't been referred, press 'Skip'.\n\nExample: FirstName_LastName (20 Characters Max)", "Enter", "Skip");
  6386. }
  6387. else {
  6388. format(szString, sizeof(szString), "[Referral] (New Account: %s (IP:%s)) has been referred by (Referred Account: %s (IP:%s))", GetPlayerNameEx(playerid), currentIP, PlayerInfo[playerid][pReferredBy], newresult);
  6389. Log("logs/referral.log", szString);
  6390. mysql_free_result(MainPipeline);
  6391. RegistrationStep[playerid] = 3;
  6392. SetPlayerVirtualWorld(playerid, 0);
  6393. ClearChatbox(playerid);
  6394. TutStep[playerid] = 24;
  6395. TextDrawShowForPlayer(playerid, txtNationSelHelper);
  6396. TextDrawShowForPlayer(playerid, txtNationSelMain);
  6397. PlayerNationSelection[playerid] = -1;
  6398. SetPlayerVirtualWorld(playerid, 0);
  6399. SetPlayerInterior(playerid, 0);
  6400. Streamer_UpdateEx(playerid,1716.1129,-1880.0715,22.0264);
  6401. SetPlayerPos(playerid,1716.1129,-1880.0715,-10.0);
  6402. SetPlayerCameraPos(playerid,1755.0413,-1824.8710,20.2100);
  6403. SetPlayerCameraLookAt(playerid,1716.1129,-1880.0715,22.0264);
  6404.  
  6405. //Streamer_UpdateEx(playerid, 1607.0160,-1510.8218,207.4438);
  6406. //SetPlayerPos(playerid, 1607.0160,-1510.8218,-10.0);
  6407. //SetPlayerCameraPos(playerid, 1850.1813,-1765.7552,81.9271);
  6408. //SetPlayerCameraLookAt(playerid, 1607.0160,-1510.8218,207.4438);
  6409. }
  6410. }
  6411. return 1;
  6412. }
  6413.  
  6414. forward OnQueryCreateToy(playerid, toyslot);
  6415. public OnQueryCreateToy(playerid, toyslot)
  6416. {
  6417. PlayerToyInfo[playerid][toyslot][ptID] = mysql_insert_id(MainPipeline);
  6418. printf("Toy ID: %d", PlayerToyInfo[playerid][toyslot][ptID]);
  6419.  
  6420. new szQuery[128];
  6421. format(szQuery, sizeof(szQuery), "UPDATE `toys` SET `modelid` = '%d' WHERE `id` = '%d'", PlayerToyInfo[playerid][toyslot][ptID], PlayerToyInfo[playerid][toyslot][ptModelID]);
  6422. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6423.  
  6424. g_mysql_SaveToys(playerid, toyslot);
  6425. }
  6426.  
  6427. forward OnStaffAccountCheck(playerid);
  6428. public OnStaffAccountCheck(playerid)
  6429. {
  6430. new string[156], rows, fields;
  6431. cache_get_data(rows, fields, MainPipeline);
  6432. if(rows > 0)
  6433. {
  6434. format(string, sizeof(string), "{AA3333}AdmWarning{FFFF00}: %s (ID: %d) was punished and has a staff account associated with their IP address.", GetPlayerNameEx(playerid), playerid);
  6435. ABroadCast(COLOR_YELLOW, string, 2);
  6436. }
  6437. return 1;
  6438. }
  6439.  
  6440. // Relay For Life
  6441.  
  6442. stock LoadRelayForLifeTeam(teamid)
  6443. {
  6444. new string[128];
  6445. format(string, sizeof(string), "SELECT * FROM `rflteams` WHERE `id`=%d", teamid);
  6446. mysql_function_query(MainPipeline, string, true, "OnLoadRFLTeam", "i", mapiconid);
  6447. }
  6448.  
  6449. stock LoadRelayForLifeTeams()
  6450. {
  6451. printf("[LoadRelayForLifeTeams] Loading data from database...");
  6452. mysql_function_query(MainPipeline, "SELECT * FROM `rflteams`", true, "OnLoadRFLTeams", "");
  6453. }
  6454.  
  6455. forward OnLoadRFLTeams();
  6456. public OnLoadRFLTeams()
  6457. {
  6458. new i, rows, fields, tmp[128];
  6459. cache_get_data(rows, fields, MainPipeline);
  6460.  
  6461. while(i < rows)
  6462. {
  6463. cache_get_field_content(i, "id", tmp, MainPipeline); RFLInfo[i][RFLsqlid] = strval(tmp);
  6464. cache_get_field_content(i, "name", RFLInfo[i][RFLname], MainPipeline);
  6465. cache_get_field_content(i, "leader", RFLInfo[i][RFLleader], MainPipeline);
  6466. cache_get_field_content(i, "used", tmp, MainPipeline); RFLInfo[i][RFLused] = strval(tmp);
  6467. cache_get_field_content(i, "members", tmp, MainPipeline); RFLInfo[i][RFLmembers] = strval(tmp);
  6468. cache_get_field_content(i, "laps", tmp, MainPipeline); RFLInfo[i][RFLlaps] = strval(tmp);
  6469. i++;
  6470. }
  6471. if(i > 0) printf("[LoadRelayForLifeTeams] %d teams loaded.", i);
  6472. else printf("[LoadRelayForLifeTeams] Failed to load any teams.");
  6473. return 1;
  6474. }
  6475.  
  6476. forward OnLoadRFLTeam(index);
  6477. public OnLoadRFLTeam(index)
  6478. {
  6479. new rows, fields, tmp[128];
  6480. cache_get_data(rows, fields, MainPipeline);
  6481.  
  6482. for(new row; row < rows; row++)
  6483. {
  6484. cache_get_field_content(row, "id", tmp, MainPipeline); RFLInfo[index][RFLsqlid] = strval(tmp);
  6485. cache_get_field_content(row, "name", RFLInfo[index][RFLname], MainPipeline);
  6486. cache_get_field_content(row, "leader", RFLInfo[index][RFLleader], MainPipeline);
  6487. cache_get_field_content(row, "used", tmp, MainPipeline); RFLInfo[index][RFLused] = strval(tmp);
  6488. cache_get_field_content(row, "members", tmp, MainPipeline); RFLInfo[index][RFLmembers] = strval(tmp);
  6489. cache_get_field_content(row, "laps", tmp, MainPipeline); RFLInfo[index][RFLlaps] = strval(tmp);
  6490. }
  6491. }
  6492.  
  6493. stock SaveRelayForLifeTeam(teamid)
  6494. {
  6495. new string[248];
  6496. format(string, sizeof(string), "UPDATE `rflteams` SET `name`='%s', `leader`='%s', `used`=%d, `members`=%d, `laps`=%d WHERE id=%d",
  6497. RFLInfo[teamid][RFLname],
  6498. RFLInfo[teamid][RFLleader],
  6499. RFLInfo[teamid][RFLused],
  6500. RFLInfo[teamid][RFLmembers],
  6501. RFLInfo[teamid][RFLlaps],
  6502. RFLInfo[teamid][RFLsqlid]
  6503. );
  6504. mysql_function_query(MainPipeline, string, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6505. }
  6506.  
  6507. stock SaveRelayForLifeTeams()
  6508. {
  6509. for(new i = 0; i < MAX_RFLTEAMS; i++)
  6510. {
  6511. SaveRelayForLifeTeam(i);
  6512. }
  6513. }
  6514.  
  6515. forward OnRFLPScore(index, id);
  6516. public OnRFLPScore(index, id)
  6517. {
  6518. new i, rows, fields, string[1500], tmp[7], name[25], leader[25], laps;
  6519. cache_get_data(rows, fields, MainPipeline);
  6520. switch(id) {
  6521. case 1: {
  6522. while(i < rows)
  6523. {
  6524. cache_get_field_content(i, "name", name, MainPipeline);
  6525. cache_get_field_content(i, "leader", leader, MainPipeline);
  6526. cache_get_field_content(i, "laps", tmp, MainPipeline); laps = strval(tmp);
  6527. format(string, sizeof(string), "%s\nTeam: %s | Leader: %s | Laps: %d",string, name, leader, laps);
  6528. i++;
  6529. }
  6530. if(i < 1) {
  6531. DeletePVar(index, "rflTemp");
  6532. SendClientMessageEx(index, COLOR_GREY, "No teams found.");
  6533. return 1;
  6534. }
  6535. if(i >= 15) {
  6536. SetPVarInt(index, "rflTemp", GetPVarInt(index, "rflTemp") + i);
  6537. ShowPlayerDialog(index, DIALOG_RFL_TEAMS, DIALOG_STYLE_LIST, "Relay For Life Teams", string, "Next", "Close");
  6538. return 1;
  6539. }
  6540. else
  6541. {
  6542. DeletePVar(index, "rflTemp");
  6543. ShowPlayerDialog(index, DIALOG_RFL_TEAMS, DIALOG_STYLE_LIST, "Relay For Life Teams", string, "Close", "");
  6544. return 1;
  6545. }
  6546. }
  6547. case 2: {
  6548. while(i < rows)
  6549. {
  6550. cache_get_field_content(i, "Username", name, MainPipeline);
  6551. cache_get_field_content(i, "RacePlayerLaps", tmp, MainPipeline); laps = strval(tmp);
  6552. format(string, sizeof(string), "%s\n%s | Laps: %d",string, name, laps);
  6553. i++;
  6554. }
  6555. if(i > 0) {
  6556. ShowPlayerDialog(index, DIALOG_RFL_PLAYERS, DIALOG_STYLE_LIST, "Relay For Life Player Top 25", string, "Close", "");
  6557. }
  6558. else {
  6559. SendClientMessageEx(index, COLOR_GREY, "No player has run any laps yet.");
  6560. }
  6561. }
  6562. }
  6563. return 1;
  6564. }
  6565.  
  6566. forward OnCheckRFLName(playerid, Player);
  6567. public OnCheckRFLName(playerid, Player)
  6568. {
  6569. if(IsPlayerConnected(Player))
  6570. {
  6571. if(mysql_affected_rows(MainPipeline))
  6572. {
  6573. SendClientMessageEx(Player, COLOR_YELLOW, "This team name already exists.");
  6574. SendClientMessageEx(playerid, COLOR_YELLOW, "This team name already exists.");
  6575. }
  6576. else
  6577. {
  6578. new newname[25], string[128];
  6579. GetPVarString(Player, "NewRFLName", newname, sizeof(newname));
  6580. format(RFLInfo[PlayerInfo[Player][pRFLTeam]][RFLname], 25, "%s", newname);
  6581. format(string, sizeof(string), "* Your team name has been changed to %s.", newname);
  6582. SendClientMessageEx(Player, COLOR_YELLOW, string);
  6583. format(string, sizeof(string), "* You have changed %s's team name to %s.", GetPlayerNameEx(playerid), newname);
  6584. SendClientMessageEx(playerid, COLOR_YELLOW, string);
  6585. format(string, sizeof(string), "%s has accepted %s's team name change request",GetPlayerNameEx(playerid),GetPlayerNameEx(Player));
  6586. ABroadCast(COLOR_YELLOW, string, 3);
  6587. SaveRelayForLifeTeam(PlayerInfo[Player][pRFLTeam]);
  6588. foreach(new i: Player) {
  6589. if( GetPVarInt( i, "EventToken" ) == 1 ) {
  6590. if( EventKernel[ EventStatus ] == 1 || EventKernel[ EventStatus ] == 2 ) {
  6591. if(EventKernel[EventType] == 3) {
  6592. if(PlayerInfo[i][pRFLTeam] == PlayerInfo[Player][pRFLTeam]) {
  6593. format(string, sizeof(string), "Team: %s", newname);
  6594. UpdateDynamic3DTextLabelText(RFLTeamN3D[i], 0x008080FF, string);
  6595. }
  6596. }
  6597. }
  6598. }
  6599. }
  6600. }
  6601. }
  6602. else
  6603. {
  6604. SendClientMessageEx(playerid, COLOR_GREY, "This user has logged off.");
  6605. }
  6606. DeletePVar(Player, "RFLNameRequest");
  6607. DeletePVar(playerid, "RFLNameChange");
  6608. DeletePVar(Player, "NewRFLName");
  6609. return 1;
  6610. }
  6611.  
  6612. stock SavePoint(pid)
  6613. {
  6614. new szQuery[2048];
  6615.  
  6616. format(szQuery, sizeof(szQuery), "UPDATE `points` SET \
  6617. `posx` = '%f', \
  6618. `posy` = '%f', \
  6619. `posz` = '%f', \
  6620. `vw` = '%d', \
  6621. `type` = '%d', \
  6622. `vulnerable` = '%d', \
  6623. `matpoint` = '%d', \
  6624. `owner` = '%s', \
  6625. `cappername` = '%s', \
  6626. `name` = '%s' WHERE `id` = %d",
  6627. Points[pid][Pointx],
  6628. Points[pid][Pointy],
  6629. Points[pid][Pointz],
  6630. Points[pid][pointVW],
  6631. Points[pid][Type],
  6632. Points[pid][Vulnerable],
  6633. Points[pid][MatPoint],
  6634. g_mysql_ReturnEscaped(Points[pid][Owner], MainPipeline),
  6635. g_mysql_ReturnEscaped(Points[pid][CapperName], MainPipeline),
  6636. g_mysql_ReturnEscaped(Points[pid][Name], MainPipeline),
  6637. pid+1
  6638. );
  6639.  
  6640. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6641. }
  6642.  
  6643. forward OnLoadPoints();
  6644. public OnLoadPoints()
  6645. {
  6646. new fields, rows, index, result[128];
  6647. cache_get_data(rows, fields, MainPipeline);
  6648.  
  6649. while((index < rows))
  6650. {
  6651. cache_get_field_content(index, "id", result, MainPipeline); Points[index][pointID] = strval(result);
  6652. cache_get_field_content(index, "posx", result, MainPipeline); Points[index][Pointx] = floatstr(result);
  6653. cache_get_field_content(index, "posy", result, MainPipeline); Points[index][Pointy] = floatstr(result);
  6654. cache_get_field_content(index, "posz", result, MainPipeline); Points[index][Pointz] = floatstr(result);
  6655. cache_get_field_content(index, "vw", result, MainPipeline); Points[index][pointVW] = strval(result);
  6656. cache_get_field_content(index, "type", result, MainPipeline); Points[index][Type] = strval(result);
  6657. cache_get_field_content(index, "vulnerable", result, MainPipeline); Points[index][Vulnerable] = strval(result);
  6658. cache_get_field_content(index, "matpoint", result, MainPipeline); Points[index][MatPoint] = strval(result);
  6659. cache_get_field_content(index, "owner", Points[index][Owner], MainPipeline, 128);
  6660. cache_get_field_content(index, "cappername", Points[index][CapperName], MainPipeline, MAX_PLAYER_NAME);
  6661. cache_get_field_content(index, "name", Points[index][Name], MainPipeline, 128);
  6662. cache_get_field_content(index, "captime", result, MainPipeline); Points[index][CapTime] = strval(result);
  6663. cache_get_field_content(index, "capfam", result, MainPipeline); Points[index][CapFam] = strval(result);
  6664. cache_get_field_content(index, "capname", Points[index][CapName], MainPipeline, MAX_PLAYER_NAME);
  6665.  
  6666. Points[index][CaptureTimerEx2] = -1;
  6667. Points[index][ClaimerId] = INVALID_PLAYER_ID;
  6668. Points[index][PointPickupID] = CreateDynamicPickup(1239, 23, Points[index][Pointx], Points[index][Pointy], Points[index][Pointz], Points[index][pointVW]);
  6669.  
  6670. if(Points[index][CapFam] != INVALID_FAMILY_ID)
  6671. {
  6672. Points[index][CapCrash] = 1;
  6673. Points[index][TakeOverTimerStarted] = 1;
  6674. Points[index][ClaimerTeam] = Points[index][CapFam];
  6675. Points[index][TakeOverTimer] = Points[index][CapTime];
  6676. format(Points[index][PlayerNameCapping], MAX_PLAYER_NAME, "%s", Points[index][CapName]);
  6677. ReadyToCapture(index);
  6678. Points[index][CaptureTimerEx2] = SetTimerEx("CaptureTimerEx", 60000, 1, "d", index);
  6679. }
  6680.  
  6681. index++;
  6682. }
  6683. if(index == 0) print("[Family Points] No family points has been loaded.");
  6684. if(index != 0) printf("[Family Points] %d family points has been loaded.", index);
  6685. return 1;
  6686. }
  6687.  
  6688. stock GetPartnerName(playerid)
  6689. {
  6690. if(PlayerInfo[playerid][pMarriedID] == -1) format(PlayerInfo[playerid][pMarriedName], MAX_PLAYER_NAME, "Nobody");
  6691. else
  6692. {
  6693. new query[128];
  6694. format(query, sizeof(query), "SELECT `Username` FROM `accounts` WHERE `id` = %d", PlayerInfo[playerid][pMarriedID]);
  6695. mysql_function_query(MainPipeline, query, true, "OnGetPartnerName", "i", playerid);
  6696. }
  6697. }
  6698.  
  6699. forward OnGetPartnerName(playerid);
  6700. public OnGetPartnerName(playerid)
  6701. {
  6702. new fields, rows, index;
  6703. cache_get_data(rows, fields, MainPipeline);
  6704.  
  6705. cache_get_field_content(index, "Username", PlayerInfo[playerid][pMarriedName], MainPipeline, MAX_PLAYER_NAME);
  6706. return 1;
  6707. }
  6708.  
  6709. forward OnStaffPrize(playerid);
  6710. public OnStaffPrize(playerid)
  6711. {
  6712. if(mysql_affected_rows(MainPipeline))
  6713. {
  6714. new type[32], name[MAX_PLAYER_NAME], amount, string[128];
  6715. GetPVarString(playerid, "OnSPrizeType", type, 16);
  6716. GetPVarString(playerid, "OnSPrizeName", name, 24);
  6717. amount = GetPVarInt(playerid, "OnSPrizeAmount");
  6718. format(string, sizeof(string), "AdmCmd: %s has offline-given %s %d free %s.", GetPlayerNameEx(playerid), name, amount, type);
  6719. ABroadCast(COLOR_LIGHTRED, string, 2);
  6720. format(string, sizeof(string), "You have given %s %d %s.", name, amount, type);
  6721. SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
  6722. format(string, sizeof(string), "[Admin] %s(IP:%s) has offline-given %s %d free %s.", GetPlayerNameEx(playerid), GetPlayerIpEx(playerid), name, amount, type);
  6723. Log("logs/adminrewards.log", string);
  6724. }
  6725. else
  6726. {
  6727. SendClientMessageEx(playerid, COLOR_RED, "Failed to give the prize..");
  6728. }
  6729. DeletePVar(playerid, "OnSPrizeType");
  6730. DeletePVar(playerid, "OnSPrizeName");
  6731. DeletePVar(playerid, "OnSPrizeAmount");
  6732. return 1;
  6733. }
  6734.  
  6735. stock AddNewBackpack(id)
  6736. {
  6737. new string[1024];
  6738. format(string, sizeof(string), "INSERT into `hgbackpacks` (type, posx, posy, posz) VALUES ('%d', '%f', '%f', '%f')",
  6739. HungerBackpackInfo[id][hgBackpackType],
  6740. HungerBackpackInfo[id][hgBackpackPos][0],
  6741. HungerBackpackInfo[id][hgBackpackPos][1],
  6742. HungerBackpackInfo[id][hgBackpackPos][2]);
  6743.  
  6744. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "i", SENDDATA_THREAD);
  6745. }
  6746.  
  6747. stock SaveHGBackpack(id)
  6748. {
  6749. new string[1024];
  6750. format(string, sizeof(string), "UPDATE `hgbackpacks` SET \
  6751. `type` = %d,
  6752. `posx` = %f,
  6753. `posy` = %f,
  6754. `posz` = %f WHERE `id` = %d",
  6755. HungerBackpackInfo[id][hgBackpackType],
  6756. HungerBackpackInfo[id][hgBackpackPos][0],
  6757. HungerBackpackInfo[id][hgBackpackPos][1],
  6758. HungerBackpackInfo[id][hgBackpackPos][2],
  6759. id
  6760. );
  6761.  
  6762. mysql_function_query(MainPipeline, string, false "OnQueryFinish", "i", SENDDATA_THREAD);
  6763. }
  6764.  
  6765. forward OnLoadHGBackpacks();
  6766. public OnLoadHGBackpacks()
  6767. {
  6768. new fields, rows, index, result[128], string[128];
  6769. cache_get_data(rows, fields, MainPipeline);
  6770.  
  6771. while((index < rows))
  6772. {
  6773. cache_get_field_content(index, "id", result, MainPipeline); HungerBackpackInfo[index][hgBackpackId] = strval(result);
  6774. cache_get_field_content(index, "type", result, MainPipeline); HungerBackpackInfo[index][hgBackpackType] = strval(result);
  6775. cache_get_field_content(index, "posx", result, MainPipeline); HungerBackpackInfo[index][hgBackpackPos][0] = floatstr(result);
  6776. cache_get_field_content(index, "posy", result, MainPipeline); HungerBackpackInfo[index][hgBackpackPos][1] = floatstr(result);
  6777. cache_get_field_content(index, "posz", result, MainPipeline); HungerBackpackInfo[index][hgBackpackPos][2] = floatstr(result);
  6778.  
  6779. HungerBackpackInfo[index][hgActiveEx] = 1;
  6780.  
  6781. HungerBackpackInfo[index][hgBackpackPickupId] = CreateDynamicPickup(371, 23, HungerBackpackInfo[index][hgBackpackPos][0], HungerBackpackInfo[index][hgBackpackPos][1], HungerBackpackInfo[index][hgBackpackPos][2], 2039);
  6782. format(string, sizeof(string), "Hunger Games Backpack\nType: %s\n{FF0000}(ID: %d){FFFFFF}", GetBackpackName(index), index);
  6783. HungerBackpackInfo[index][hgBackpack3DText] = CreateDynamic3DTextLabel(string, COLOR_ORANGE, HungerBackpackInfo[index][hgBackpackPos][0], HungerBackpackInfo[index][hgBackpackPos][1], HungerBackpackInfo[index][hgBackpackPos][2]+1, 20.0, .worldid = 2039, .interiorid = 0);
  6784.  
  6785. index++;
  6786. }
  6787.  
  6788. hgBackpackCount = index;
  6789.  
  6790. if(index == 0) print("[Hunger Games] No Backpack has been loaded.");
  6791. if(index != 0) printf("[Hunger Games] %d Backpacks has been loaded.", index);
  6792. return true;
  6793. }
  6794.  
  6795. forward ExecuteShopQueue(playerid, id);
  6796. public ExecuteShopQueue(playerid, id)
  6797. {
  6798. new rows, fields, index, result[128], string[128], query[128], tmp[8];
  6799. switch(id)
  6800. {
  6801. case 0:
  6802. {
  6803. cache_get_data(rows, fields, MainPipeline);
  6804. if(IsPlayerConnected(playerid))
  6805. {
  6806. while(index < rows)
  6807. {
  6808. cache_get_field_content(index, "id", result, MainPipeline); tmp[0] = strval(result);
  6809. cache_get_field_content(index, "GiftVoucher", result, MainPipeline); tmp[1] = strval(result);
  6810. cache_get_field_content(index, "CarVoucher", result, MainPipeline); tmp[2] = strval(result);
  6811. cache_get_field_content(index, "VehVoucher", result, MainPipeline); tmp[3] = strval(result);
  6812. cache_get_field_content(index, "SVIPVoucher", result, MainPipeline); tmp[4] = strval(result);
  6813. cache_get_field_content(index, "GVIPVoucher", result, MainPipeline); tmp[5] = strval(result);
  6814. cache_get_field_content(index, "PVIPVoucher", result, MainPipeline); tmp[6] = strval(result);
  6815. cache_get_field_content(index, "credits_spent", result, MainPipeline); tmp[7] = strval(result);
  6816.  
  6817. if(tmp[1] > 0)
  6818. {
  6819. PlayerInfo[playerid][pGiftVoucher] += tmp[1];
  6820. format(string, sizeof(string), "You have been automatically issued %d gift reset voucher(s).", tmp[1]);
  6821. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6822. format(string, sizeof(string), "[ID: %d] %s was automatically issued %d gift reset voucher(s)", tmp[0], GetPlayerNameEx(playerid), tmp[1]);
  6823. Log("logs/shoplog.log", string);
  6824. }
  6825. if(tmp[2] > 0)
  6826. {
  6827. PlayerInfo[playerid][pCarVoucher] += tmp[2];
  6828. format(string, sizeof(string), "You have been automatically issued %d restricted car voucher(s).", tmp[2]);
  6829. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6830. format(string, sizeof(string), "[ID: %d] %s was automatically issued %d restricted car voucher(s)", tmp[0], GetPlayerNameEx(playerid), tmp[2]);
  6831. Log("logs/shoplog.log", string);
  6832. }
  6833. if(tmp[3] > 0)
  6834. {
  6835. PlayerInfo[playerid][pVehVoucher] += tmp[3];
  6836. format(string, sizeof(string), "You have been automatically issued %d car voucher(s).", tmp[3]);
  6837. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6838. format(string, sizeof(string), "[ID: %d] %s was automatically issued %d car voucher(s)", tmp[0], GetPlayerNameEx(playerid), tmp[3]);
  6839. Log("logs/shoplog.log", string);
  6840. }
  6841. if(tmp[4] > 0)
  6842. {
  6843. PlayerInfo[playerid][pSVIPVoucher] += tmp[4];
  6844. format(string, sizeof(string), "You have been automatically issued %d Silver VIP voucher(s).", tmp[4]);
  6845. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6846. format(string, sizeof(string), "[ID: %d] %s was automatically issued %d Silver VIP voucher(s)", tmp[0], GetPlayerNameEx(playerid), tmp[4]);
  6847. Log("logs/shoplog.log", string);
  6848. }
  6849. if(tmp[5] > 0)
  6850. {
  6851. PlayerInfo[playerid][pGVIPVoucher] += tmp[5];
  6852. format(string, sizeof(string), "You have been automatically issued %d Gold VIP voucher(s).", tmp[5]);
  6853. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6854. format(string, sizeof(string), "[ID: %d] %s was automatically issued %d Gold VIP voucher(s)", tmp[0], GetPlayerNameEx(playerid), tmp[5]);
  6855. Log("logs/shoplog.log", string);
  6856. }
  6857. if(tmp[6] > 0)
  6858. {
  6859. PlayerInfo[playerid][pPVIPVoucher] += tmp[6];
  6860. format(string, sizeof(string), "You have been automatically issued %d Platinum VIP voucher(s).", tmp[6]);
  6861. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6862. format(string, sizeof(string), "[ID: %d] %s was automatically issued %d Platinum VIP voucher(s)", tmp[0], GetPlayerNameEx(playerid), tmp[6]);
  6863. Log("logs/shoplog.log", string);
  6864. }
  6865.  
  6866. PlayerInfo[playerid][pCredits] -= tmp[7];
  6867. format(query, sizeof(query), "UPDATE `shop_orders` SET `status` = 1 WHERE `id` = %d", tmp[0]);
  6868. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6869. OnPlayerStatsUpdate(playerid);
  6870. return SendClientMessageEx(playerid, COLOR_CYAN, "* Use /myvouchers to check and use your vouchers at any time!");
  6871. }
  6872. }
  6873. }
  6874. case 1:
  6875. {
  6876. cache_get_data(rows, fields, ShopPipeline);
  6877. if(IsPlayerConnected(playerid))
  6878. {
  6879. while(index < rows)
  6880. {
  6881. cache_get_field_content(index, "order_id", result, ShopPipeline); tmp[0] = strval(result);
  6882. cache_get_field_content(index, "credit_amount", result, ShopPipeline); tmp[1] = strval(result);
  6883.  
  6884. PlayerInfo[playerid][pCredits] += tmp[1];
  6885. format(string, sizeof(string), "You have been automatically issued %s credit(s).", number_format(tmp[1]));
  6886. SendClientMessageEx(playerid, COLOR_WHITE, string);
  6887. format(string, sizeof(string), "[ID: %d] %s was automatically issued %s credit(s)", tmp[0], GetPlayerNameEx(playerid), number_format(tmp[1]));
  6888. Log("logs/shoplog.log", string);
  6889. format(query, sizeof(query), "UPDATE `order_delivery_status` SET `status` = 1 WHERE `order_id` = %d", tmp[0]);
  6890. mysql_function_query(ShopPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6891. OnPlayerStatsUpdate(playerid);
  6892. return 1;
  6893. }
  6894. }
  6895. }
  6896. }
  6897. return 1;
  6898. }
  6899.  
  6900. stock CheckAdminWhitelist(playerid)
  6901. {
  6902. new string[128];
  6903. format(string, sizeof(string), "SELECT `AdminLevel`, `SecureIP` FROM `accounts` WHERE `Username` = '%s'", GetPlayerNameExt(playerid));
  6904. mysql_function_query(MainPipeline, string, true, "OnQueryFinish", "iii", ADMINWHITELIST_THREAD, playerid, g_arrQueryHandle{playerid});
  6905. return true;
  6906. }
  6907.  
  6908. stock GivePlayerCashEx(playerid, type, amount)
  6909. {
  6910. if(IsPlayerConnected(playerid) && gPlayerLogged{playerid})
  6911. {
  6912. new szQuery[128];
  6913. switch(type)
  6914. {
  6915. case TYPE_BANK:
  6916. {
  6917. PlayerInfo[playerid][pAccount] += amount;
  6918. format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `Bank`=%d WHERE `id` = %d", PlayerInfo[playerid][pAccount], GetPlayerSQLId(playerid));
  6919. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  6920. }
  6921. case TYPE_ONHAND:
  6922. {
  6923. PlayerInfo[playerid][pCash] += amount;
  6924. format(szQuery, sizeof(szQuery), "UPDATE `accounts` SET `Money`=%d WHERE `id` = %d", PlayerInfo[playerid][pCash], GetPlayerSQLId(playerid));
  6925. mysql_function_query(MainPipeline, szQuery, false, "OnQueryFinish", "ii", SENDDATA_THREAD, playerid);
  6926. }
  6927. }
  6928. }
  6929. return 1;
  6930. }
  6931.  
  6932. stock PointCrashProtection(point)
  6933. {
  6934. new query[128], temp;
  6935. temp = Points[point][ClaimerTeam];
  6936. if(temp == INVALID_PLAYER_ID)
  6937. {
  6938. temp = INVALID_FAMILY_ID;
  6939. }
  6940. format(query, sizeof(query), "UPDATE `points` SET `captime` = %d, `capfam` = %d, `capname` = '%s' WHERE `id` = %d",Points[point][TakeOverTimer], temp, Points[point][PlayerNameCapping], Points[point][pointID]);
  6941. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  6942. return 1;
  6943. }
  6944.  
  6945. /*stock LoadHelp()
  6946. {
  6947. printf("[LoadHelp] Loading data from database...");
  6948. mysql_function_query(MainPipeline, "SELECT * FROM `help`", true, "OnLoadHelp", "");
  6949. }
  6950.  
  6951. forward OnLoadHelp();
  6952. public OnLoadHelp()
  6953. {
  6954. new i, rows, fields, tmp[128];
  6955. cache_get_data(rows, fields, MainPipeline);
  6956.  
  6957. TOTAL_COMMANDS = rows;
  6958. while(i < rows)
  6959. {
  6960. cache_get_field_content(i, "id", tmp, MainPipeline); HelpInfo[i][id] = strval(tmp);
  6961. cache_get_field_content(i, "name", HelpInfo[i][name], MainPipeline, 255);
  6962. cache_get_field_content(i, "params", HelpInfo[i][params], MainPipeline, 255);
  6963. cache_get_field_content(i, "description", HelpInfo[i][description], MainPipeline, 255);
  6964. cache_get_field_content(i, "type", tmp, MainPipeline); HelpInfo[i][type] = strval(tmp);
  6965. cache_get_field_content(i, "subtype", tmp, MainPipeline); HelpInfo[i][subtype] = strval(tmp);
  6966. cache_get_field_content(i, "perms", tmp, MainPipeline); HelpInfo[i][perms] = strval(tmp);
  6967. i++;
  6968. }
  6969. }*/
  6970.  
  6971. stock LoadGangTags()
  6972. {
  6973. new query[128];
  6974. format(query, sizeof(query), "SELECT * FROM `gangtags` LIMIT %d", MAX_GANGTAGS);
  6975. mysql_function_query(MainPipeline, query, true, "OnGangTagQueryFinish", "ii", LOAD_GANGTAGS, -1);
  6976. }
  6977.  
  6978. stock SaveGangTag(gangtag)
  6979. {
  6980. new query[256];
  6981. format(query, sizeof(query), "UPDATE `gangtags` SET \
  6982. `posx` = %f, \
  6983. `posy` = %f, \
  6984. `posz` = %f, \
  6985. `posrx` = %f, \
  6986. `posry` = %f, \
  6987. `posrz` = %f, \
  6988. `objectid` = %d, \
  6989. `vw` = %d, \
  6990. `interior` = %d, \
  6991. `family` = %d, \
  6992. `time` = %d, \
  6993. `used` = %d WHERE `id` = %d",
  6994. GangTags[gangtag][gt_PosX],
  6995. GangTags[gangtag][gt_PosY],
  6996. GangTags[gangtag][gt_PosZ],
  6997. GangTags[gangtag][gt_PosRX],
  6998. GangTags[gangtag][gt_PosRY],
  6999. GangTags[gangtag][gt_PosRZ],
  7000. GangTags[gangtag][gt_ObjectID],
  7001. GangTags[gangtag][gt_VW],
  7002. GangTags[gangtag][gt_Int],
  7003. GangTags[gangtag][gt_Family],
  7004. GangTags[gangtag][gt_Time],
  7005. GangTags[gangtag][gt_Used],
  7006. GangTags[gangtag][gt_SQLID]
  7007. );
  7008. mysql_function_query(MainPipeline, query, false, "OnGangTagQueryFinish", "ii", SAVE_GANGTAG, gangtag);
  7009. }
  7010.  
  7011. forward OnGangTagQueryFinish(threadid, extraid);
  7012. public OnGangTagQueryFinish(threadid, extraid)
  7013. {
  7014. new fields, rows;
  7015. cache_get_data(rows, fields, MainPipeline);
  7016. switch(threadid)
  7017. {
  7018. case LOAD_GANGTAGS:
  7019. {
  7020. new row, result[64];
  7021. while(row < rows)
  7022. {
  7023. cache_get_field_content(row, "id", result, MainPipeline); GangTags[row][gt_SQLID] = strval(result);
  7024. cache_get_field_content(row, "posx", result, MainPipeline); GangTags[row][gt_PosX] = floatstr(result);
  7025. cache_get_field_content(row, "posy", result, MainPipeline); GangTags[row][gt_PosY] = floatstr(result);
  7026. cache_get_field_content(row, "posz", result, MainPipeline); GangTags[row][gt_PosZ] = floatstr(result);
  7027. cache_get_field_content(row, "posrx", result, MainPipeline); GangTags[row][gt_PosRX] = floatstr(result);
  7028. cache_get_field_content(row, "posry", result, MainPipeline); GangTags[row][gt_PosRY] = floatstr(result);
  7029. cache_get_field_content(row, "posrz", result, MainPipeline); GangTags[row][gt_PosRZ] = floatstr(result);
  7030. cache_get_field_content(row, "objectid", result, MainPipeline); GangTags[row][gt_ObjectID] = strval(result);
  7031. cache_get_field_content(row, "vw", result, MainPipeline); GangTags[row][gt_VW] = strval(result);
  7032. cache_get_field_content(row, "interior", result, MainPipeline); GangTags[row][gt_Int] = strval(result);
  7033. cache_get_field_content(row, "family", result, MainPipeline); GangTags[row][gt_Family] = strval(result);
  7034. cache_get_field_content(row, "used", result, MainPipeline); GangTags[row][gt_Used] = strval(result);
  7035. cache_get_field_content(row, "time", result, MainPipeline); GangTags[row][gt_Time] = strval(result);
  7036. CreateGangTag(row);
  7037. row++;
  7038. }
  7039. if(row > 0)
  7040. {
  7041. printf("[MYSQL] Successfully loaded %d gang tags.", row);
  7042. }
  7043. else
  7044. {
  7045. print("[MYSQL] Failed loading any gang tags.");
  7046. }
  7047. }
  7048. case SAVE_GANGTAG:
  7049. {
  7050. if(mysql_affected_rows(MainPipeline))
  7051. {
  7052. printf("[MYSQL] Successfully saved gang tag %d (SQLID: %d).", extraid, GangTags[extraid][gt_SQLID]);
  7053. }
  7054. else
  7055. {
  7056. printf("[MYSQL] Failed saving gang tag %d (SQLID: %d).", extraid, GangTags[extraid][gt_SQLID]);
  7057. }
  7058. }
  7059. }
  7060. return 1;
  7061. }
  7062.  
  7063. // g_mysql_LoadGiftBox()
  7064. // Description: Loads the data of the dynamic giftbox from the SQL Database.
  7065. stock g_mysql_LoadGiftBox()
  7066. {
  7067. print("[Dynamic Giftbox] Loading the Dynamic Giftbox...");
  7068. mysql_function_query(MainPipeline, "SELECT * FROM `giftbox`", true, "OnQueryFinish", "iii", LOADGIFTBOX_THREAD, INVALID_PLAYER_ID, -1);
  7069. }
  7070.  
  7071. stock SaveDynamicGiftBox()
  7072. {
  7073. new query[4096];
  7074. for(new i = 0; i < 4; i++)
  7075. {
  7076. if(i == 0)
  7077. format(query, sizeof(query), "UPDATE `giftbox` SET `dgMoney%d` = '%d',", i, dgMoney[i]);
  7078. else
  7079. format(query, sizeof(query), "%s `dgMoney%d` = '%d',", query, i, dgMoney[i]);
  7080.  
  7081. format(query, sizeof(query), "%s `dgRimKit%d` = '%d',", query, i, dgRimKit[i]);
  7082. format(query, sizeof(query), "%s `dgFirework%d` = '%d',", query, i, dgFirework[i]);
  7083. format(query, sizeof(query), "%s `dgGVIP%d` = '%d',", query, i, dgGVIP[i]);
  7084. format(query, sizeof(query), "%s `dgNewbieMuteReset%d` = '%d',", query, i, dgNewbieMuteReset[i]);
  7085.  
  7086. if(i == 3)
  7087. format(query, sizeof(query), "%s `dgRestrictedCarVoucher%d` = '%d'", query, i, dgRestrictedCarVoucher[i]);
  7088. else
  7089. format(query, sizeof(query), "%s `dgPlatinumVIPVoucher%d` = '%d',", query, i, dgPlatinumVIPVoucher[i]);
  7090. }
  7091.  
  7092. mysql_function_query(MainPipeline, query, false, "OnQueryFinish", "i", SENDDATA_THREAD);
  7093. }
Advertisement
Add Comment
Please, Sign In to add comment