Advertisement
Guest User

Untitled

a guest
Sep 18th, 2016
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 98.67 KB | None | 0 0
  1. public OnGameModeInit()
  2. {
  3. AddPlayerClass(0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0);
  4. InitMapSystem();
  5. EnableStuntBonusForAll(0);
  6. DisableInteriorEnterExits();
  7. SetTimer("UpdateTextdraw", 1000, true);
  8. SetTimer("AntiCheat", 1000, true);
  9. SetTimer("timer_update",14400,true);
  10. gettime(ghour, gminute, gsecond);
  11. FixHour(ghour);
  12. ghour = shifthour;
  13. //------ Textdraws
  14. //------ clock
  15. Clockzz = TextDrawCreate(549.000000,38.000000,"00:00");
  16. TextDrawAlignment(Clockzz,0);
  17. TextDrawBackgroundColor(Clockzz,0x000000ff);
  18. TextDrawFont(Clockzz,2);
  19. TextDrawLetterSize(Clockzz,0.499999,3.199999);
  20. TextDrawColor(Clockzz,0x00ffff99);
  21. TextDrawSetOutline(Clockzz,1);
  22. TextDrawSetProportional(Clockzz,1);
  23. TextDrawSetShadow(Clockzz,1);
  24. //------ Advertisement
  25. AdTextdraw = TextDrawCreate(1.000000, 433.000000, "[Ad] Make an advertisement via /advertisement!");
  26. TextDrawBackgroundColor(AdTextdraw, 0x000000ff);
  27. TextDrawFont(AdTextdraw, 1);
  28. TextDrawLetterSize(AdTextdraw, 0.300000, 1.500000);
  29. TextDrawColor(AdTextdraw, -1);
  30. TextDrawSetOutline(AdTextdraw, 0);
  31. TextDrawSetProportional(AdTextdraw, 1);
  32. TextDrawSetShadow(AdTextdraw, 1);
  33. TextDrawUseBox(AdTextdraw, 1);
  34. TextDrawBoxColor(AdTextdraw, 0x00000033);
  35. TextDrawTextSize(AdTextdraw, 653.000000, 0.000000);
  36. //-----End of textdraws
  37. SetTimer("UpdateClock", 1000, true); //ANTI-CHEAT IN THIS.
  38. SetTimer("ChangeWeather", 720000, true);
  39. SetTimer("RandomMsg", 600000, true);
  40. ConnectMySQL();
  41. new mapname[75];
  42. format(mapname,sizeof(mapname),"mapname %s",revision);
  43. SendRconCommand(mapname);
  44. SetGameModeText("Flying/RP");
  45. new SendCommand[156]; // I don't want to count the letters, do it yourself
  46. format(SendCommand, sizeof(SendCommand), "hostname %s", HOSTNAME); // Format the command into a string.
  47. SendRconCommand(SendCommand); // Execute the command through Rcon.
  48. LoadAirline(1);
  49. LoadAirline(2);
  50. LoadAirline(3);
  51. LoadAirline(4);
  52. LoadAirline(5);
  53. new tmphour;
  54. new tmpminute;
  55. new tmpsecond;
  56. gettime(tmphour, tmpminute, tmpsecond);
  57. FixHour(tmphour);
  58. tmphour = shifthour;
  59. SetWorldTime(tmphour);
  60. randomtimer = SetTimer("RandomTimer", 1000, 1);
  61. onlinetimer = SetTimer("OnlineTimer", 60000, 1); //DYNAMIC SIG TIMER IS IN THIS!!
  62. LoadObjects();
  63. AddAirlineVehiclesSTART();
  64. AddHousesFromSQL();
  65. AddVehiclesFromSQL();
  66. AddPlayerVehicles();
  67. AddMapIcons();
  68. LoadStuff(); // Load the data, MOTD, etc.
  69. LoadTextdraws();
  70. for(new i=0;i<MAX_VEHICLES;i++) {
  71. vfuel[i] = 100; //set fuel to 100 percent
  72. }
  73. SetTimer("UpdateIRC", 5000, true);
  74. return 1;
  75. }
  76. public RandomTimer()
  77. {
  78. for(new i; i<MAX_PLAYERS; i++)
  79. {
  80. if(GetPlayerMoney(i) != PInfo[i][Money]) //Money/Cash anti-cheat
  81. {
  82. ResetPlayerMoney(i);
  83. GivePlayerMoney(i,PInfo[i][Money]);
  84. }
  85. }
  86. }
  87. stock Float:GetVehicleSpeed(vehicleid,UseMPH = 0)
  88. {
  89. new Float:speed_x,Float:speed_y,Float:speed_z,Float:temp_speed;
  90. GetVehicleVelocity(vehicleid,speed_x,speed_y,speed_z);
  91. if(UseMPH == 0)
  92. {
  93. temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*136.666667;
  94. } else {
  95. temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+(speed_z*speed_z))*85.4166672;
  96. }
  97. floatround(temp_speed,floatround_round);return temp_speed;
  98. }
  99. public UpdateClock() //ANTI CHEAT AND CLOCK UPDATE.
  100. {
  101. //----------- CLOCK UPDATER ---------------
  102. new fix[20];
  103. if(gMinutes == 60)
  104. {
  105. new theHour = gHour+1;
  106. SetWorldTime(theHour);
  107. }
  108. if(gHour == 23 && gMinutes == 60)
  109. {
  110. gHour = 0;
  111. gMinutes = 0;
  112. new PCount = 0;
  113. new string[256];
  114. for(new i = 0; i <MAX_PLAYERS; i++)
  115. {
  116. if(IsPlayerConnected(i))
  117. {
  118. PCount=PCount+1;
  119. if(SessionEarnt[i] > POTD_MaximumEarnt)
  120. {
  121. POTD_MaximumEarnt = SessionEarnt[i];
  122. POTD_Winner = i;
  123. POTD_FinalAmount = SessionEarnt[i];
  124. POTD_FinalAmount2 = SessionEarnt[i];
  125. format(string,sizeof(string),"%s", PlayerName(i));
  126. strmid(POTD_WinnerName, string, 0, strlen(string), 128);
  127. }
  128. format(string,sizeof(string),"[POTD] You have earnt a total of {1B8AE4}$%d {FFFFFF}today. (Excluding airline bonus)", SessionEarnt[i]);
  129. SendClientMessage(i, COLOR_WHITE, string);
  130. SessionEarnt[i] = 0;
  131. }
  132. }
  133. if(PCount > 1)
  134. {
  135. new POTDBonus = PCount*975; //50 players - $48750 bonus!
  136. new susername[MAX_PLAYER_NAME];
  137. new date,month,year;
  138. getdate(date,month,year);
  139. new hour,minute,second;
  140. gettime(hour,minute,second);
  141. format(susername,sizeof(susername),"%s", PlayerName(POTD_Winner));
  142. mysql_real_escape_string(susername, susername);
  143. new query[600];
  144. format(query,sizeof(query),"INSERT INTO `potd` (Username, AmountEarnt, AmountWon, Time, Date) VALUES ('%s', '%d', '%d', '%d:%d:%d', '%d/%d/%d')", susername, POTD_FinalAmount, POTDBonus, hour,minute,second,year,month,date);
  145. mysql_query(query);
  146. PInfo[POTD_Winner][Money]=PInfo[POTD_Winner][Money]+POTDBonus;
  147. GivePlayerMoney(POTD_Winner, POTDBonus);
  148. format(string,sizeof(string),"[POTD] {1B8AE4}%s(%d) {FFFFFF}has become the pilot of the day for earning {1B8AE4}$%d {FFFFFF}and has won {1B8AE4}$%d{FFFFFF}!", PlayerName(POTD_Winner), POTD_Winner, POTD_FinalAmount, POTDBonus);
  149. SendClientMessageToAll(COLOR_WHITE, string);
  150. POTD_MaximumEarnt = 0;
  151. POTD_FinalAmount = 0;
  152. PayLog(susername, POTDBonus, "Won POTD", "Server", "N/A");
  153. }
  154. new ACount = 0; //Participating Airline amounts. (must be atleast 2.)
  155. for(new aid = 0; aid <MAX_AIRLINES; aid++)
  156. {
  157. if(AOTD_Earnt[aid] > 0)
  158. {
  159. ACount=ACount+1;
  160. if(AOTD_Earnt[aid] > AOTD_MaximumEarnt)
  161. {
  162. AOTD_MaximumEarnt = AOTD_Earnt[aid];
  163. AOTD_Winner = aid;
  164. AOTD_FinalAmount = AOTD_Earnt[aid];
  165. AOTD_FinalAmount2 = AOTD_Earnt[aid];
  166. format(string,sizeof(string),"%s", AInfo[aid][aName]);
  167. strmid(AOTD_WinnerName, string, 0, strlen(string), 128);
  168. }
  169. format(string,sizeof(string),"* [AOTD] Your airline has earnt a total of $%d today!", AOTD_Earnt[aid]);
  170. SendAirlineMessage(COLOR_AIRLINECHAT, string, aid);
  171. AOTD_Earnt[aid] = 0;
  172. }
  173. }
  174. if(ACount > 1)
  175. {
  176. new AOTDBonus = PCount*1100;
  177. new aname[128];
  178. new date,month,year;
  179. getdate(date,month,year);
  180. new hour,minute,second;
  181. gettime(hour,minute,second);
  182. format(aname,sizeof(aname),"%s", AInfo[AOTD_Winner][aName]);
  183. mysql_real_escape_string(aname,aname);
  184. new query[600];
  185. format(query,sizeof(query),"INSERT INTO `aotd` (Airline, AmountEarnt, AmountWon, Time, Date) VALUES ('%s', '%d', '%d', '%d:%d:%d', '%d/%d/%d')", aname, AOTD_FinalAmount, AOTDBonus, hour,minute,second,year,month,date);
  186. mysql_query(query);
  187. format(string,sizeof(string),"[AOTD] {1B8AE4}%s {FFFFFF}has won airline of the day for earning {1B8AE4}$%d {FFFFFF}and has won {1B8AE4}$%d{FFFFFF}!", AInfo[AOTD_Winner][aName], AOTD_FinalAmount, AOTDBonus);
  188. SendClientMessageToAll(COLOR_WHITE, string);
  189. AInfo[AOTD_Winner][aBalance] = AInfo[AOTD_Winner][aBalance]+AOTDBonus;
  190. SaveAirline(AOTD_Winner);
  191. format(string,sizeof(string),"* A total of $%d has been added to the airlines bank.", AOTDBonus);
  192. SendAirlineMessage(COLOR_AIRLINECHAT, string, AOTD_Winner);
  193. AOTD_MaximumEarnt = 0;
  194. AOTD_FinalAmount = 0;
  195. }
  196. else
  197. {
  198. format(string,sizeof(string),"[AOTD] No airline has won Airline of the Day due to a lack of competition.");
  199. SendClientMessageToAll(COLOR_WHITE, string);
  200. format(AOTD_WinnerName,sizeof(AOTD_WinnerName), "None");
  201. AOTD_FinalAmount = 0;
  202. AOTD_MaximumEarnt = 0;
  203. }
  204. for(new i = 0; i < MAX_VEHICLES; i++) //Respawn all vehicles.
  205. {
  206. if(!IsVehicleOccupied(i))
  207. {
  208. SetVehicleToRespawn(i);
  209. }
  210. }
  211. }
  212. if(gMinutes == 60) { gHour++; gMinutes = 0; }
  213. if(gHour < 10 && gMinutes > 9) { format(fix, sizeof(fix), "0%d:%d", gHour, gMinutes); }
  214. if(gHour < 10 && gMinutes < 10) { format(fix, sizeof(fix), "0%d:0%d", gHour, gMinutes); }
  215. if(gMinutes < 10 && gHour > 9) { format(fix,sizeof(fix), "%d:0%d", gHour, gMinutes); }
  216. if(gMinutes < 10 && gHour < 10) { format(fix, sizeof(fix), "0%d:0%d", gHour, gMinutes); }
  217. if(gMinutes > 9 && gHour > 9) { format(fix,sizeof(fix), "%d:%d", gHour, gMinutes); }
  218. gMinutes++;
  219. TextDrawSetString(Clockzz, fix);
  220. //------------- CLOCK UPDATER --------------
  221. //------------- ANTICHEAT ------------------
  222. //------------- ANTICHEAT ------------------
  223. }
  224. public UpdateIRC()
  225. {
  226. new query[400];
  227. format(query,sizeof(query),"SELECT Sender, Message, ID FROM ucpchat2");
  228. mysql_query(query);
  229. mysql_store_result();
  230. new tRows = mysql_num_rows();
  231. if(tRows > 0)
  232. {
  233. while(mysql_fetch_row(query))
  234. {
  235. new sSender[24], sMessage[156], sID;
  236. sscanf(query, "p<|>s[24]s[156]d", sSender, sMessage, sID);
  237. format(query,sizeof(query),"([UCP] %s: %s)", sSender, sMessage);
  238. SendClientMessageToAll(COLOR_IRC, query);
  239. format(query,sizeof(query),"DELETE FROM ucpchat2 WHERE ID = '%d'", sID);
  240. mysql_query(query);
  241. }
  242. }
  243. mysql_free_result();
  244. }
  245. public AntiCheat()
  246. {
  247. for(new playerid; playerid<MAX_PLAYERS; playerid++)
  248. {
  249. if(IsPlayerConnected(playerid))
  250. {
  251. if(PlayerLogged[playerid] == 1 && PlayerSpawned[playerid] == 1 && PInfo[playerid][AdminLevel] == 0)
  252. {
  253. new wep = GetPlayerWeapon(playerid);
  254. if(wep==1||wep==2||wep==3||wep==4||wep==5||wep==6||wep==7||wep==8||wep==9||wep==10||wep==11||wep==12||wep==13||wep==14||wep==15||wep==16||wep==17||wep==18||wep==22||wep==23||wep==24||wep==25||wep==26||wep==27||wep==28||wep==29||wep==30||wep==31||wep==32||wep==33||wep==34||wep==35||wep==36||wep==37||wep==38||wep==39||wep==40||wep==41||wep==42||wep==43||wep==44||wep==45)
  255. {
  256. BanUser(playerid, "Weapon hacks", "TroubleMaker");
  257. }
  258. new Float:Armour;
  259. GetPlayerArmour(playerid, Armour);
  260. if(Armour > 0)
  261. {
  262. BanUser(playerid, "Armour hacks", "TroubleMaker");
  263. }
  264. if(GetPlayerSpecialAction(playerid) == SPECIAL_ACTION_USEJETPACK)
  265. {
  266. BanUser(playerid, "Jetpack hacks", "TroubleMaker");
  267. }
  268. if(IsPlayerInAnyVehicle(playerid))
  269. {
  270. new vehicleid = GetPlayerVehicleID(playerid);
  271. if(vfuel[vehicleid] > 0)
  272. {
  273. new speed = floatround(GetVehicleSpeed(vehicleid, 0), floatround_round);
  274. if(speed > 239 && PInfo[playerid][TotalScore] < 10) //240 mph && under 10 score
  275. {
  276. BanUser(playerid, "Speed hack", "TroubleMaker");
  277. }
  278. else if(speed > 210) //210 mph
  279. {
  280. new string[156];
  281. format(string,sizeof(string),"[SPEED WARNING] %s(%d) is going %d MPH! /spec them!", PlayerName(playerid), playerid, speed);
  282. SendAdminMessage(COLOR_ADMIN, string);
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. public ShowAds()
  291. {
  292. AdvertisementStatus = 1;
  293. TextDrawShowForAll(AdTextdraw);
  294. }
  295. public HideAds()
  296. {
  297. AdvertisementStatus = 0;
  298. TextDrawHideForAll(AdTextdraw);
  299. }
  300. public UpdateTextdraw()
  301. {
  302. for(new i; i<MAX_PLAYERS; i++)
  303. {
  304. if(IsPlayerConnected(i))
  305. {
  306. if(PreviewingSkin[i] == 1) { if(PreviewingSkinTime[i] == 0) { SetPlayerSkin(i, PreviewingSkinOld[i]); PreviewingSkin[i] = 0; } else { PreviewingSkinTime[i]=PreviewingSkinTime[i]-1; } }
  307. if(WantsRecording[i] == 1)
  308. {
  309. if(TimeTakenHrs[i] == 4 && TimeTakenMins[i] == 59) { PlayerPlaySound(i, 29631, 0, 0, 0); } //Hey, how's the flying coming along?
  310. if(TimeTakenMins[i] == 59) { TimeTakenMins[i] = 0; TimeTakenHrs[i] += 1; }
  311. else
  312. {
  313. TimeTakenMins[i] += 1;
  314. }
  315. }
  316. if(IsPlayerInAnyVehicle(i) && GetPlayerVehicleSeat(i) == 0)
  317. {
  318. new vid = GetPlayerVehicleID(i);
  319. switch(GetVehicleModel(vid))
  320. {
  321. case 520 , 577 , 511 , 592 , 512 , 513 , 519 , 593 , 553 , 476, 417 , 425, 447, 469, 487, 488, 497, 548, 563, 460:
  322. {
  323. new szString[128];
  324. format(szString, 40, "%d Percent", vfuel[vid]);
  325. TextDrawSetString(Textdraw4[i], szString);
  326. TextDrawShowForPlayer(i, Textdraw4[i]);
  327. TextDrawShowForPlayer(i, Textdraw5[i]);
  328. if(vfuel[vid] < 21) //20 or under fuel
  329. {
  330. if(vfuel[vid] == 20 && FuelWarned[i] == 0) { FuelWarned[i] = 1; SendClientMessage(i, COLOR_ERROR, "[Instrument Panel] The vehicles fuel is running low ! Please refuel immediately! (/refuel)"); }
  331. PlayerPlaySound(i, 1057, 0,0,0);
  332. }
  333. new Float:vhealth;
  334. new Float: vX, Float:vY, Float:vZ;
  335. format(szString, 128, "%s", GetPlayerArea(i));
  336. TextDrawSetString(Textdraw0[i], szString);
  337. TextDrawShowForPlayer(i, Textdraw0[i]);
  338. TextDrawShowForPlayer(i, Textdraw2[i]);
  339. GetVehicleHealth(vid, vhealth);
  340. vhealth = vhealth/10;
  341. format(szString, 40, "%d Percent", floatround(vhealth, floatround_round));
  342. TextDrawSetString(Textdraw6[i], szString);
  343. TextDrawShowForPlayer(i, Textdraw6[i]);
  344. TextDrawShowForPlayer(i, Textdraw7[i]);
  345. GetPlayerPos(i, vX, vY, vZ);
  346. format(szString, 40, "%d", floatround(vZ, floatround_ceil));
  347. TextDrawSetString(Textdraw10[i], szString);
  348. TextDrawShowForPlayer(i, Textdraw10[i]);
  349. TextDrawShowForPlayer(i, Textdraw9[i]);
  350. format(szString, 40, "%d MPH", floatround(GetVehicleSpeed(vid, 0), floatround_round));
  351. TextDrawSetString(Textdraw8[i], szString);
  352. TextDrawShowForPlayer(i, Textdraw8[i]);
  353. TextDrawShowForPlayer(i, Textdraw11[i]);
  354. new Float:zangle;
  355. GetVehicleZAngle(vid, zangle);
  356. format(szString, 40, "%d", floatround(zangle, floatround_round));
  357. TextDrawSetString(Textdraw12[i], szString);
  358. TextDrawShowForPlayer(i, Textdraw12[i]);
  359. TextDrawShowForPlayer(i, Textdraw13[i]);
  360. if(StartedMission[i] == 1)
  361. {
  362. if(MissionStage[i] == 1)
  363. {
  364. new Float:DistanceCheck;
  365. DistanceCheck = GetDistanceBetweenPoints(vX, vY, vZ,Pos1[i],Pos2[i],Pos3[i]);
  366. format(szString, 40, "%s (%dm)", FirstAPName[i],floatround(DistanceCheck, floatround_round));
  367. TextDrawSetString(Textdraw1[i], szString);
  368. TextDrawShowForPlayer(i, Textdraw1[i]);
  369. TextDrawShowForPlayer(i, Textdraw3[i]);
  370. }
  371. else if(MissionStage[i] == 2)
  372. {
  373. new Float:DistanceCheck;
  374. DistanceCheck = GetDistanceBetweenPoints(vX, vY, vZ,Pos12[i],Pos22[i],Pos32[i]);
  375. format(szString, 40, "%s (%dm)", FinalAPName[i],floatround(DistanceCheck, floatround_round));
  376. TextDrawSetString(Textdraw1[i], szString);
  377. TextDrawShowForPlayer(i, Textdraw1[i]);
  378. TextDrawShowForPlayer(i, Textdraw3[i]);
  379. }
  380. }
  381. }
  382. }
  383. }
  384. }
  385. }
  386. }
  387. public OnlineTimer()
  388. {
  389. new x = 0;
  390. for(new i; i<MAX_PLAYERS; i++)
  391. {
  392. if(IsPlayerConnected(i)) //Money/Cash anti-cheat
  393. {
  394. if(PInfo[i][MinsPlayed] == 59) { PInfo[i][MinsPlayed] = 0; PInfo[i][HoursPlayed]=PInfo[i][HoursPlayed]+1; } else { PInfo[i][MinsPlayed]=PInfo[i][MinsPlayed]+1; }
  395. x=x+1;
  396. }
  397. }
  398. PlayersOnline = x;
  399. new query[400];
  400. format(query,sizeof(query),"UPDATE serverinfo SET hostname='%s',maxplayers='%d',players='%d'", HOSTNAME, MaxPlayers, PlayersOnline);
  401. mysql_reconnect();
  402. mysql_query(query);
  403. }
  404. public ConnectMySQL()
  405. {
  406. mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
  407. if(mysql_ping() == 1)
  408. {
  409. mysql_debug(1);
  410. printf("[MYSQL]: Connection to `%s` succesful!", SQL_DB);
  411. GlobalStatus = 1;
  412. }
  413. else
  414. {
  415. printf("[MYSQL]: [ERROR]: Connection to `%s` failed!", SQL_DB);
  416. GlobalStatus = 2;
  417. }
  418. return 1;
  419. }
  420. public SyncTime()
  421. {
  422. //new string[64];
  423. new tmphour;
  424. new tmpminute;
  425. new tmpsecond;
  426. gettime(tmphour, tmpminute, tmpsecond);
  427. FixHour(tmphour);
  428. tmphour = shifthour;
  429. if((tmphour > ghour) || (tmphour == 0 && ghour == 23))
  430. {
  431. //Changing weather randomly
  432. new GlobalWeather = random(17);
  433. SetWeather(GlobalWeather);
  434. //Changing weather randomly finish
  435. //format(string, sizeof(string), "SERVER: The time is now %d:00 hours",tmphour);
  436. //SendClientMessageToAll(COLOR_WHITE,string);
  437. ghour = tmphour;
  438. if(realtime)
  439. {
  440. SetWorldTime(tmphour);
  441. }
  442. }
  443. }
  444. public FixHour(hour)
  445. {
  446. hour = timeshift+hour;
  447. if(hour < 0)
  448. {
  449. hour = hour+24;
  450. }
  451. else if(hour > 23)
  452. {
  453. hour = hour-24;
  454. }
  455. shifthour = hour;
  456. return 1;
  457. }
  458. public CheckIPS(playerid)
  459. {
  460. new PIP2[40]; // Main IP.
  461. GetPlayerIp(playerid, PIP2, sizeof(PIP2));
  462. new Count = 0;
  463. new PIP[40];
  464. for(new i; i<MAX_PLAYERS; i++)
  465. {
  466. if(IsPlayerConnected(i))
  467. {
  468. GetPlayerIp(i, PIP, sizeof(PIP));
  469. if(!strcmp(PIP, PIP2))
  470. {
  471. Count=Count+1;
  472. }
  473. }
  474. }
  475. if(Count > 5) // 6 connections!
  476. {
  477. new msg[156];
  478. format(msg,sizeof(msg),"There are too many connections from your IP: %s!", PIP2);
  479. SendClientMessage(playerid, COLOR_ERROR, msg);
  480. Kick(playerid);
  481. return 1;
  482. }
  483. return 1;
  484. }
  485. public CheckBanned(playerid)
  486. {
  487. new IP2[20];
  488. GetPlayerIp(playerid, IP2, sizeof(IP2));
  489. mysql_reconnect();
  490. new Query[156], EscName[MAX_PLAYER_NAME];
  491. mysql_real_escape_string(PlayerName(playerid), EscName);
  492. format(Query, sizeof(Query), "SELECT * FROM `bans` WHERE `IP` = '%s' OR `Username` = '%s'", IP2, EscName);
  493. mysql_query(Query);
  494. mysql_store_result();
  495. if(mysql_num_rows() > 0)
  496. {
  497. new line[500];
  498. if(mysql_fetch_row(line)) //Fetches the line
  499. {
  500. new string[128];
  501. new data[6][128]; //The data strings
  502. new data2[2];
  503. sscanf(line, "p<|>s[128]s[128]s[128]s[128]s[128]dds[128]", data[0], data[1], data[2], data[3], data[4], data2[0], data2[1], data[5]); //Splits the line with sscanf
  504. format(string,sizeof(string),"[Username]: {FFFFFF}%s", data[0]);
  505. SendClientMessage(playerid, COLOR_BLUE, string);
  506. format(string, sizeof(string), "[IP Address]: {FFFFFF}%s", data[3]);
  507. SendClientMessage(playerid, COLOR_BLUE, string);
  508. format(string,sizeof(string), "[Ban Reason]: {FFFFFF}%s", data[1]);
  509. SendClientMessage(playerid, COLOR_BLUE, string);
  510. format(string,sizeof(string), "[Ban Date]: {FFFFFF}%s / %s", data[4], data[5]);
  511. SendClientMessage(playerid, COLOR_BLUE, string);
  512. format(string,sizeof(string), "[Banned By]: {FFFFFF}%s", data[2]);
  513. SendClientMessage(playerid, COLOR_BLUE, string);
  514. new string2[256];
  515. format(string2,sizeof(string2), "-- To appeal this ban, please visit {FFFFFF}http://the-lof.com{1B8AE4} and post an unban appeal, including a screenshot of the above details. --");
  516. SendClientMessage(playerid, COLOR_BLUE, string2);
  517. mysql_free_result();
  518. Kick(playerid);
  519. }
  520. mysql_free_result();
  521. Kick(playerid);
  522. return 1;
  523. }
  524. else
  525. {
  526. mysql_free_result();
  527. }
  528. return 1;
  529. }
  530. public SaveVehicle(vehicleid)
  531. {
  532. new query[400];
  533. format(query,sizeof(query),"UPDATE pvehicles SET VehicleModel='%d',OwnedBy='%s',VehicleX='%f',VehicleY='%f',VehicleZ='%f',VehicleA='%f',VehicleColor1='%d',VehicleColor2='%d',VehicleForSale='%d',VehicleDefaultPrice='%d',VehiclePrice='%d',VehicleLocked='%d' WHERE VehicleID = '%d'",
  534. PVInfo[vehicleid][vpModel],
  535. PVInfo[vehicleid][vpOwnedBy],
  536. PVInfo[vehicleid][vpPosX],
  537. PVInfo[vehicleid][vpPosY],
  538. PVInfo[vehicleid][vpPosZ],
  539. PVInfo[vehicleid][vpPosA],
  540. PVInfo[vehicleid][vpColor1],
  541. PVInfo[vehicleid][vpColor2],
  542. PVInfo[vehicleid][vpForSale],
  543. PVInfo[vehicleid][vpDefaultPrice],
  544. PVInfo[vehicleid][vpPrice],
  545. PVInfo[vehicleid][vpLocked],
  546. vehicleid);
  547. mysql_reconnect();
  548. mysql_query(query);
  549. printf("Vehicle ID %d saved to mysql.", vehicleid);
  550. }
  551. public ReloadVehicle(vehicleid)
  552. {
  553. new carid = vehicleid;
  554. new Str[250], vTotal, vehID, vehModel, Float:vehX, Float:vehY, Float:vehZ, Float:vehA, vehC1, vehC2, vehOwnedBy[24], ForSale, DefaultPrice, Price, Locked;
  555. mysql_reconnect();
  556. new carmod[17];
  557. new query[512];
  558. format(query,sizeof(query),"SELECT * FROM `pvehicles` WHERE `VehicleID` = '%d' LIMIT 1", vehicleid);
  559. mysql_query(query);
  560. mysql_store_result();
  561. vTotal = mysql_num_rows();
  562. if(vTotal > 0)
  563. {
  564. mysql_fetch_row(Str);
  565. DestroyVehicle(PVInfo[carid][vpVehicleSpawned]);
  566. Delete3DTextLabel(PVInfo[carid][vpVehicleText]);
  567. sscanf(Str, "p<|>dds[24]ffffddddddddddddddddddddddd",
  568. vehID,vehModel,vehOwnedBy,vehX,vehY,vehZ,vehA,vehC1,vehC2,ForSale,DefaultPrice,Price,Locked,carmod[0],carmod[1],carmod[2],carmod[3],carmod[4],carmod[5],carmod[6],carmod[7],carmod[8],carmod[9],carmod[10],carmod[11],carmod[12],carmod[13],carmod[14],carmod[15],carmod[16]);
  569. carid=vehID;
  570. new carid2 = CreateVehicle(vehModel, vehX, vehY, vehZ, vehA, vehC1, vehC2, (30 * 60));
  571. PVInfo[carid][vpID] = vehID;
  572. PVInfo[carid][vpPosX] = vehX;
  573. PVInfo[carid][vpPosY] = vehY;
  574. PVInfo[carid][vpPosZ] = vehZ;
  575. PVInfo[carid][vpPosA] = vehA;
  576. PVInfo[carid][vpColor1] = vehC1;
  577. PVInfo[carid][vpColor2] = vehC2;
  578. PVInfo[carid][vpModel] = vehModel;
  579. PVInfo[carid][vpForSale] = ForSale;
  580. PVInfo[carid][vpDefaultPrice] = DefaultPrice;
  581. PVInfo[carid][vpPrice] = Price;
  582. PVInfo[carid][vpLocked] = Locked;
  583. PVInfo[carid2][mod1] = carmod[0];
  584. PVInfo[carid2][mod2] = carmod[1];
  585. PVInfo[carid2][mod3] = carmod[2];
  586. PVInfo[carid2][mod4] = carmod[3];
  587. PVInfo[carid2][mod5] = carmod[4];
  588. PVInfo[carid2][mod6] = carmod[5];
  589. PVInfo[carid2][mod7] = carmod[6];
  590. PVInfo[carid2][mod8] = carmod[7];
  591. PVInfo[carid2][mod9] = carmod[8];
  592. PVInfo[carid2][mod10] = carmod[9];
  593. PVInfo[carid2][mod11] = carmod[10];
  594. PVInfo[carid2][mod12] = carmod[11];
  595. PVInfo[carid2][mod13] = carmod[12];
  596. PVInfo[carid2][mod14] = carmod[13];
  597. PVInfo[carid2][mod15] = carmod[14];
  598. PVInfo[carid2][mod16] = carmod[15];
  599. PVInfo[carid2][mod17] = carmod[16];
  600. if(ForSale == 1)
  601. {
  602. format(Str, sizeof(Str), "%s for sale!\nPrice: $%d (Seller: %s)\n/marketplace to purchase!", GetVehicleFriendlyName(carid2),Price, vehOwnedBy);
  603. PVInfo[carid][vpVehicleText] = Create3DTextLabel(Str, 0xFF8400FF, vehX, vehY, vehZ, 50.0, 0, 1);
  604. }
  605. else
  606. {
  607. format(Str, sizeof(Str), "%s\nOwner: %s", GetVehicleFriendlyName(carid2),vehOwnedBy);
  608. PVInfo[carid][vpVehicleText] = Create3DTextLabel(Str, 0xFF8400FF, vehX, vehY, vehZ, 50.0, 0, 1);
  609. }
  610. Attach3DTextLabelToVehicle(PVInfo[carid][vpVehicleText], carid2, 0.0, 0.0, 0.0);
  611. new string[64];
  612. format(string,sizeof(string),"%s",vehOwnedBy);
  613. strmid(PVInfo[carid][vpOwnedBy], string, 0, strlen(string), 128);
  614. PVInfo[carid][vpVehicleSpawned] = carid2;
  615. new engine,lights,alarm,doors,bonnet,boot,objective;
  616. GetVehicleParamsEx(carid2,engine,lights,alarm,doors,bonnet,boot,objective);
  617. if(Locked == 1) { SetVehicleParamsEx(carid2,engine,lights,alarm,1,bonnet,boot,objective); }
  618. else if(Locked == 0) { SetVehicleParamsEx(carid2,engine,lights,alarm,0,bonnet,boot,objective); }
  619. }
  620. mysql_free_result();
  621. }
  622. public ReloadHouse(houseid)
  623. {
  624. new Str[400], string[256];
  625. mysql_reconnect();
  626. format(string,sizeof(string),"SELECT * FROM `houses` WHERE `HouseID` = %d LIMIT 1", houseid);
  627. mysql_reconnect();
  628. mysql_query(string);
  629. mysql_store_result();
  630. new hTotal = mysql_num_rows(); //hTotal amount of houses in mysql database
  631. if(hTotal > 0) //1+ house.
  632. {
  633. mysql_fetch_row(Str);
  634. new HID,Float:eX,Float:eY,Float:eZ,Float:iX,Float:iY,Float:iZ,OwnedBy[24],Location[128],Price,Interior,Slots,ForSale,Locked,DefaultPrice;
  635. sscanf(Str, "p<|>ds[24]s[128]dddffffffddd", HID,OwnedBy,Location,DefaultPrice,Price,Interior,iX,iY,iZ,eX,eY,eZ,Slots,ForSale,Locked);
  636. if(!strcmp(OwnedBy, "None"))
  637. {
  638. DestroyDynamicMapIcon(HInfo[HID][hMapIcon]);
  639. DestroyPickup(HInfo[HID][hPickupID]);
  640. Delete3DTextLabel(HInfo[HID][hHouseText]);
  641. HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 31, 0, 0, 0, 0, 100.0);
  642. HInfo[HID][hPickupID] = CreatePickup(1273, 23, eX, eY, eZ, 0);
  643. format(string,sizeof(string),"House for sale!\n$%d (%d slots)\n/buyhouse to purchase.", DefaultPrice, Slots);
  644. HInfo[HID][hHouseText] = Create3DTextLabel(string, 0x50AAC5FF, eX, eY, eZ, 50.0, 0, 1);
  645. }
  646. else if(ForSale == 1)
  647. {
  648. DestroyDynamicMapIcon(HInfo[HID][hMapIcon]);
  649. DestroyPickup(HInfo[HID][hPickupID]);
  650. Delete3DTextLabel(HInfo[HID][hHouseText]);
  651. HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 31, 0, 0, 0, 0, 100.0);
  652. HInfo[HID][hPickupID] = CreatePickup(1273, 23, eX, eY, eZ, 0);
  653. format(string,sizeof(string),"Owned by: %s\nFor sale: $%d (%d slots)\n/buyhouse to purchase.", OwnedBy, Price, Slots);
  654. HInfo[HID][hHouseText] = Create3DTextLabel(string, 0x50AAC5FF, eX, eY, eZ, 50.0, 0, 1);
  655. }
  656. else
  657. {
  658. DestroyDynamicMapIcon(HInfo[HID][hMapIcon]);
  659. DestroyPickup(HInfo[HID][hPickupID]);
  660. Delete3DTextLabel(HInfo[HID][hHouseText]);
  661. HInfo[HID][hMapIcon] = CreateDynamicMapIcon(eX, eY, eZ, 32, 0, 0, 0, 0, 100.0);
  662. HInfo[HID][hPickupID] = CreatePickup(1272, 23, eX, eY, eZ, 0);
  663. format(string,sizeof(string),"Owned by: %s\nSlots: %d", OwnedBy, Slots);
  664. HInfo[HID][hHouseText] = Create3DTextLabel(string, 0x50AAC5FF, eX, eY, eZ, 50.0, 0, 1);
  665. }
  666. format(string,sizeof(string),"%s",OwnedBy);
  667. strmid(HInfo[HID][hOwnedBy], string, 0, strlen(string), 128);
  668. format(string,sizeof(string),"%s",Location);
  669. strmid(HInfo[HID][hLocation], string, 0, strlen(string), 128); //PASSWORD
  670. HInfo[HID][hPrice] = Price;
  671. HInfo[HID][hInterior] = Interior;
  672. HInfo[HID][hiX] = iX;
  673. HInfo[HID][hiY] = iY;
  674. HInfo[HID][hiZ] = iZ;
  675. HInfo[HID][heX] = eX;
  676. HInfo[HID][heY] = eY;
  677. HInfo[HID][heZ] = eZ;
  678. HInfo[HID][hSlots] = Slots;
  679. HInfo[HID][hForSale] = ForSale;
  680. HInfo[HID][hLocked] = Locked;
  681. HInfo[HID][hDefaultPrice] = DefaultPrice;
  682. HInfo[HID][hHouseID] = HID;
  683. }
  684. mysql_free_result();
  685. }
  686. public SaveHouse(houseid)
  687. {
  688. new query[400];
  689. format(query,sizeof(query),"UPDATE houses SET OwnedBy='%s',Location='%s',Price='%d',Interior='%d',iX='%f',iY='%f',iZ='%f',eX='%f',eY='%f',eZ='%f',Slots='%d',ForSale='%d',Locked='%d',DefaultPrice='%d' WHERE HouseID = '%d'",
  690. HInfo[houseid][hOwnedBy],
  691. HInfo[houseid][hLocation],
  692. HInfo[houseid][hPrice],
  693. HInfo[houseid][hInterior],
  694. HInfo[houseid][hiX],
  695. HInfo[houseid][hiY],
  696. HInfo[houseid][hiZ],
  697. HInfo[houseid][heX],
  698. HInfo[houseid][heY],
  699. HInfo[houseid][heZ],
  700. HInfo[houseid][hSlots],
  701. HInfo[houseid][hForSale],
  702. HInfo[houseid][hLocked],
  703. HInfo[houseid][hDefaultPrice],
  704. HInfo[houseid][hHouseID]);
  705. mysql_reconnect();
  706. mysql_query(query);
  707. printf("House ID %d saved to mysql.", houseid);
  708. }
  709. public SaveAccount(playerid)
  710. {
  711. if(IsPlayerConnected(playerid)) //is client connected ?? .. proceeding
  712. {
  713. if(PlayerSpawned[playerid] != 0) //is client logged in ?? .. proceeding
  714. {
  715. new date,month,year;
  716. getdate(date,month,year);
  717. new hour,minute,second;
  718. gettime(hour,minute,second);
  719. FixHour(hour);
  720. hour = shifthour+1;
  721. //--Notes:
  722. // - Register Date isn't saved/used.
  723. //--------
  724. //---MySQL Vulnerability Injection Data Variables ------------------
  725. new p_NAME[MAX_PLAYER_NAME], p_PASSWORD[128], p_REASON1[128], p_REASON2[128], p_REASON3[128], p_CALLSIGN[128], p_EMAIL[256];
  726. //---MySQL Vulnerability Injection Data Variables ------------------
  727. mysql_real_escape_string(PlayerName(playerid),p_NAME);
  728. mysql_real_escape_string(PInfo[playerid][Password], p_PASSWORD);
  729. mysql_real_escape_string(PInfo[playerid][Reason1], p_REASON1);
  730. mysql_real_escape_string(PInfo[playerid][Reason2], p_REASON2);
  731. mysql_real_escape_string(PInfo[playerid][Reason3], p_REASON3);
  732. mysql_real_escape_string(PInfo[playerid][Callsign], p_CALLSIGN);
  733. mysql_real_escape_string(PInfo[playerid][Email], p_EMAIL);
  734. mysql_reconnect();
  735. new query[1024];
  736. format(query,sizeof(query),"UPDATE users SET username='%s',password='%s',adminlevel='%d',ip='%s',lastlogin='%d/%d/%d %d:%d:%d',banned='%d',money='%d',at400f='%d',stuntf='%d',helif='%d',cargof='%d',militaryf='%d',shamalf='%d',dodof='%d',skimmerf='%d',muted='%d',hoursplayed='%d',minsplayed='%d',warning1='%d',reason1='%s',warning2='%d',reason2='%s',warning3='%d',reason3='%s',totaljobs='%d',totalscore='%d',androf='%d' WHERE username = '%s'",
  737. p_NAME,
  738. p_PASSWORD,
  739. PInfo[playerid][AdminLevel],
  740. PInfo[playerid][IP],
  741. year,month,date,hour,minute,second,
  742. PInfo[playerid][Banned],
  743. PInfo[playerid][Money],
  744. PInfo[playerid][AT400F],
  745. PInfo[playerid][STUNTF],
  746. PInfo[playerid][HELIF],
  747. PInfo[playerid][CARGOF],
  748. PInfo[playerid][MILITARYF],
  749. PInfo[playerid][SHAMALF],
  750. PInfo[playerid][DODOF],
  751. PInfo[playerid][SKIMMERF],
  752. PInfo[playerid][Muted],
  753. PInfo[playerid][HoursPlayed],
  754. PInfo[playerid][MinsPlayed],
  755. PInfo[playerid][Warning1],
  756. p_REASON1,
  757. PInfo[playerid][Warning2],
  758. p_REASON2,
  759. PInfo[playerid][Warning3],
  760. p_REASON3,
  761. PInfo[playerid][TotalJobs],
  762. PInfo[playerid][TotalScore],
  763. PInfo[playerid][ANDROF],
  764. p_NAME);
  765. mysql_query(query);
  766. format(query,sizeof(query),"UPDATE users SET beaglef='%d',cropdusterf='%d',hydraf='%d',nevadaf='%d',rustlerf='%d',cargobobf='%d',hunterf='%d',leviathanf='%d',maverickf='%d',nmaverickf='%d',pmaverickf='%d',raindancef='%d',seasparrowf='%d',sparrowf='%d',earntfromworking='%d',flightscompleted='%d',callsign='%s',callsignset='%d',emailaddress='%s',airline='%d',airlinerank='%d',earntforairline='%d',house1='%d',house2='%d',flowndistance='%d',airlineflights='%d',vip='%d',vipcolour='%s' WHERE username = '%s'",
  767. PInfo[playerid][BEAGLEF],
  768. PInfo[playerid][CROPDUSTERF],
  769. PInfo[playerid][HYDRAF],
  770. PInfo[playerid][NEVADAF],
  771. PInfo[playerid][RUSTLERF],
  772. PInfo[playerid][CARGOBOBF],
  773. PInfo[playerid][HUNTERF],
  774. PInfo[playerid][LEVIATHANF],
  775. PInfo[playerid][MAVERICKF],
  776. PInfo[playerid][NMAVERICKF],
  777. PInfo[playerid][PMAVERICKF],
  778. PInfo[playerid][RAINDANCEF],
  779. PInfo[playerid][SEASPARROWF],
  780. PInfo[playerid][SPARROWF],
  781. PInfo[playerid][EarntFromWorking],
  782. PInfo[playerid][FlightsCompleted],
  783. p_CALLSIGN,
  784. PInfo[playerid][CallsignSet],
  785. p_EMAIL,
  786. PInfo[playerid][Airline],
  787. PInfo[playerid][AirlineRank],
  788. PInfo[playerid][EarntForAirline],
  789. PInfo[playerid][House1],
  790. PInfo[playerid][House2],
  791. PInfo[playerid][FlownDistance],
  792. PInfo[playerid][AirlineFlights],
  793. PInfo[playerid][Vip],
  794. PInfo[playerid][VIPColour],
  795. p_NAME);
  796. mysql_query(query);
  797. format(query,sizeof(query),"UPDATE users SET tickets='%d',sspawn='%d',sskin='%d',spm='%d',svipsounds='%d',ownedskin='%d',sglobalsounds='%d',sconnectionmessages='%d',sautowork='%d' WHERE username='%s'",
  798. PInfo[playerid][Tickets],
  799. PInfo[playerid][sSpawn],
  800. PInfo[playerid][sSkin],
  801. PInfo[playerid][sPM],
  802. PInfo[playerid][sVIPSounds],
  803. PInfo[playerid][OwnedSkin],
  804. PInfo[playerid][sGlobalSounds],
  805. PInfo[playerid][sConnectionMessages],
  806. PInfo[playerid][sAutoWork],
  807. p_NAME);
  808. mysql_query(query);
  809. return 1;
  810. }
  811. }
  812. return 1;
  813. }
  814. public DisplayDialogForPlayer(playerid, dialogid)
  815. {
  816. switch(dialogid)
  817. {
  818. case 1:
  819. {
  820. ShowPlayerDialog(playerid,1,DIALOG_STYLE_PASSWORD,"{1B8AE4}Login","{FFFFFF}Welcome to the {1B8AE4}San Andreas Pilots\n\n{FFFFFF}This account is {1B8AE4}registered. {FFFFFF}To gain access, input your password below","Login","Quit");
  821. }
  822. case 2:
  823. {
  824. ShowPlayerDialog(playerid,2,DIALOG_STYLE_INPUT,"{1B8AE4}Registration","{FFFFFF}Welcome to the {1B8AE4}San Andreas Pilots\n\n{FFFFFF}Please {1B8AE4}register {FFFFFF}an account by typing a password below.","Register","Quit");
  825. }
  826. case 3: //Civilian Default Spawn Selection (Pilot)
  827. {
  828. ShowPlayerDialog(playerid,3,DIALOG_STYLE_LIST,"{FFFFFF}", "{1B8AE4}Los Santos\n{FFFFFF}San Fierro\n{1B8AE4}Las Venturas", "Spawn", "Cancel");
  829. }
  830. case 4:
  831. {
  832. ShowPlayerDialog(playerid,4,DIALOG_STYLE_LIST,"{FFFFFF}Select Class", "Pilot\nTrucker\nTaxi Driver\nCourrier Driver\n", "Select", "Cancel");
  833. }
  834. case showit2:
  835. {
  836. ShowPlayerDialog(playerid,showit2,DIALOG_STYLE_LIST,"{FFFFFF}Select an option", "{1B8AE4}Information & Statistics\n{FFFFFF}Donate\n{1B8AE4}Member List\n{FFFFFF}Fleet List\n{1B8AE4}Bank Account\n{FFFFFF}Airline Settings", "Choose", "Back");
  837. }
  838. case 5: //Military Default Spawn Selection (Pilot)
  839. {
  840. ShowPlayerDialog(playerid,55,DIALOG_STYLE_LIST,"{FFFFFF}Select Spawn Location.", "{1B8AE4}Area 51\n{FFFFFF}San Fierro Carrier", "Spawn", "Cancel");
  841. }
  842. case 8: //Civilian Default Spawn Selection (Pilot)
  843. {
  844. ShowPlayerDialog(playerid,8,DIALOG_STYLE_LIST,"{FFFFFF}", "{1B8AE4}Los Santos Depot\n{FFFFFF}San Fierro Depot\n{1B8AE4}Las Venturas Depot", "Spawn", "Cancel");
  845. }
  846. }
  847. return 1;
  848. }
  849. public timer_update()
  850. {
  851. for(new i=0;i<MAX_PLAYERS;i++) {
  852. if (IsPlayerInAnyVehicle(i))
  853. {
  854. new vid = GetPlayerVehicleID(i);
  855. switch(GetVehicleModel(vid))
  856. {
  857. case 520 , 577 , 511 , 592 , 512 , 513 , 519 , 593 , 553 , 476, 417 , 425, 447, 469, 487, 488, 497, 548, 563, 460:
  858. {
  859. if (GetPlayerVehicleSeat(i) == 0) {
  860. vfuel[vid] = vfuel[vid]-1;
  861. if (vfuel[vid]<1)
  862. {
  863. new engine, lights, alarm, doors, bonnet, boot, objective;
  864. GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
  865. vfuel[vid] = 0;
  866. //RemovePlayerFromVehicle(i);
  867. GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4);
  868. SetVehicleParamsEx(vid, 0, lights, alarm, doors, bonnet, boot, objective);
  869. }
  870. }
  871. }
  872. }
  873. }
  874. }
  875. return 1;
  876. }
  877. public ChangeWeather()
  878. {
  879. new rand = randomEx(1, 20);
  880. if(rand == 21 || rand == 9 || rand == 19 || rand == 8 || rand == 16)
  881. {
  882. ChangeWeather();
  883. return 1;
  884. }
  885. else
  886. {
  887. SetWeather(rand);
  888. }
  889. return 1;
  890. }
  891. public RandomMsg()
  892. {
  893. new rmsg[156];
  894. new rand = random(sizeof(Messages));
  895. format(rmsg,sizeof(rmsg),"%s", Messages[rand][Message]);
  896. SendClientMessageToAll(COLOR_RANDOMMSG, rmsg);
  897. }
  898. public RegisterAccount(playerid, password[])
  899. {
  900. if(IsPlayerConnected(playerid))
  901. {
  902. new string2[128];
  903. new date,month,year;
  904. getdate(date,month,year);
  905. new hour,minute,second;
  906. gettime(hour,minute,second);
  907. FixHour(hour);
  908. hour = shifthour+1;
  909. format(string2, sizeof(string2), "%d/%d/%d %d:%d:%d", year,month,date,hour,minute,second); //PASSWORD
  910. mysql_reconnect();
  911. new Query[200], EscPass[30], EscName[MAX_PLAYER_NAME];
  912. mysql_real_escape_string(PlayerName(playerid), EscName);
  913. mysql_real_escape_string(password, EscPass);
  914. format(Query, sizeof(Query), "INSERT INTO `users` (`username`, `password`, `registerdate`) VALUES ('%s', '%s', '%d/%d/%d %d:%d:%d')", EscName, EscPass, year,month,date,hour,minute,second);
  915. mysql_query(Query);
  916. }
  917. return 1;
  918. }
  919. public UnloadTextdraws(playerid)
  920. {
  921. TextDrawHideForPlayer(playerid, Textdraw1[playerid]);
  922. TextDrawHideForPlayer(playerid, Textdraw2[playerid]);
  923. TextDrawHideForPlayer(playerid, Textdraw3[playerid]);
  924. TextDrawHideForPlayer(playerid, Textdraw4[playerid]);
  925. TextDrawHideForPlayer(playerid, Textdraw5[playerid]);
  926. TextDrawHideForPlayer(playerid, Textdraw6[playerid]);
  927. TextDrawHideForPlayer(playerid, Textdraw7[playerid]);
  928. TextDrawHideForPlayer(playerid, Textdraw8[playerid]);
  929. TextDrawHideForPlayer(playerid, Textdraw9[playerid]);
  930. TextDrawHideForPlayer(playerid, Textdraw10[playerid]);
  931. TextDrawHideForPlayer(playerid, Textdraw11[playerid]);
  932. TextDrawHideForPlayer(playerid, Textdraw12[playerid]);
  933. TextDrawHideForPlayer(playerid, Textdraw13[playerid]);
  934. }
  935. public LoadTextdraws()
  936. {
  937. for(new playerid = 0; playerid <MAX_PLAYERS; playerid++)
  938. {
  939. TDLoaded[playerid] = 1;
  940. TextdrawNotice[playerid] = TextDrawCreate(497.000000, 111.000000, "Notice:");
  941. TextDrawBackgroundColor(TextdrawNotice[playerid], 255);
  942. TextDrawFont(TextdrawNotice[playerid], 0);
  943. TextDrawLetterSize(TextdrawNotice[playerid], 0.500000, 1.000000);
  944. TextDrawColor(TextdrawNotice[playerid], -16776961);
  945. TextDrawSetOutline(TextdrawNotice[playerid], 1);
  946. TextDrawSetProportional(TextdrawNotice[playerid], 1);
  947. //Create second one
  948. TextdrawNoticeText[playerid] = TextDrawCreate(498.000000, 120.000000, "Empty");
  949. TextDrawBackgroundColor(TextdrawNoticeText[playerid], 255);
  950. TextDrawFont(TextdrawNoticeText[playerid], 1);
  951. TextDrawLetterSize(TextdrawNoticeText[playerid], 0.240000, 1.000000);
  952. TextDrawColor(TextdrawNoticeText[playerid], -1);
  953. TextDrawSetOutline(TextdrawNoticeText[playerid], 0);
  954. TextDrawSetProportional(TextdrawNoticeText[playerid], 1);
  955. TextDrawSetShadow(TextdrawNoticeText[playerid], 1);
  956. TextDrawUseBox(TextdrawNoticeText[playerid], 1);
  957. TextDrawBoxColor(TextdrawNoticeText[playerid], 0x00000076);
  958. TextDrawTextSize(TextdrawNoticeText[playerid], 633.000000, 0.000000);
  959. //PANEL.
  960. Textdraw0[playerid] = TextDrawCreate(502.000000,302.000000,"Los Santos Airport Gate A");
  961. Textdraw1[playerid] = TextDrawCreate(502.000000,330.000000,"Prickle Pine Airport Gate 1");
  962. Textdraw2[playerid] = TextDrawCreate(501.000000,287.000000,"GPS:");
  963. Textdraw3[playerid] = TextDrawCreate(501.000000,315.000000,"Destination:");
  964. Textdraw4[playerid] = TextDrawCreate(502.000000,358.000000,"100 Percent");
  965. Textdraw5[playerid] = TextDrawCreate(501.000000,346.000000,"Fuel:");
  966. Textdraw6[playerid] = TextDrawCreate(571.000000,358.000000,"100 Percent");
  967. Textdraw7[playerid] = TextDrawCreate(572.000000,345.000000,"Health:");
  968. Textdraw8[playerid] = TextDrawCreate(502.000000,389.000000,"135 KPH");
  969. Textdraw9[playerid] = TextDrawCreate(502.000000,377.000000,"Speed:");
  970. Textdraw10[playerid] = TextDrawCreate(591.000000,388.000000,"350");
  971. Textdraw11[playerid] = TextDrawCreate(573.000000,375.000000,"Altitude:");
  972. Textdraw12[playerid] = TextDrawCreate(591.000000,418.000000,"");
  973. Textdraw13[playerid] = TextDrawCreate(573.000000,405.000000,"Heading:");
  974. Textdraw12[playerid] = TextDrawCreate(574.000000,419.000000,"360");
  975. TextDrawUseBox(Textdraw12[playerid],1);
  976. TextDrawBoxColor(Textdraw12[playerid],0x00000033);
  977. TextDrawTextSize(Textdraw12[playerid],662.000000,0.000000);
  978. TextDrawAlignment(Textdraw12[playerid],0);
  979. TextDrawBackgroundColor(Textdraw12[playerid],0x000000ff);
  980. TextDrawFont(Textdraw12[playerid],1);
  981. TextDrawLetterSize(Textdraw12[playerid],0.399999,1.100000);
  982. TextDrawColor(Textdraw12[playerid],0xffffffff);
  983. TextDrawSetOutline(Textdraw12[playerid],1);
  984. TextDrawSetProportional(Textdraw12[playerid],1);
  985. TextDrawSetShadow(Textdraw12[playerid],1);
  986. TextDrawUseBox(Textdraw0[playerid],1);
  987. TextDrawBoxColor(Textdraw0[playerid],0x00000033);
  988. TextDrawTextSize(Textdraw0[playerid],656.000000,8.000000);
  989. TextDrawUseBox(Textdraw1[playerid],1);
  990. TextDrawBoxColor(Textdraw1[playerid],0x00000033);
  991. TextDrawTextSize(Textdraw1[playerid],661.000000,0.000000);
  992. TextDrawUseBox(Textdraw4[playerid],1);
  993. TextDrawBoxColor(Textdraw4[playerid],0x00000033);
  994. TextDrawTextSize(Textdraw4[playerid],650.000000,-1.000000);
  995. TextDrawUseBox(Textdraw8[playerid],1);
  996. TextDrawBoxColor(Textdraw8[playerid],0x00000033);
  997. TextDrawTextSize(Textdraw8[playerid],674.000000,0.000000);
  998. TextDrawBoxColor(Textdraw12[playerid],0x00000033);
  999. TextDrawAlignment(Textdraw0[playerid],0);
  1000. TextDrawAlignment(Textdraw1[playerid],0);
  1001. TextDrawAlignment(Textdraw2[playerid],0);
  1002. TextDrawAlignment(Textdraw3[playerid],0);
  1003. TextDrawAlignment(Textdraw4[playerid],0);
  1004. TextDrawAlignment(Textdraw5[playerid],0);
  1005. TextDrawAlignment(Textdraw6[playerid],0);
  1006. TextDrawAlignment(Textdraw7[playerid],0);
  1007. TextDrawAlignment(Textdraw8[playerid],0);
  1008. TextDrawAlignment(Textdraw9[playerid],0);
  1009. TextDrawAlignment(Textdraw10[playerid],0);
  1010. TextDrawAlignment(Textdraw11[playerid],0);
  1011. TextDrawAlignment(Textdraw13[playerid],0);
  1012. TextDrawBackgroundColor(Textdraw0[playerid],0x000000ff);
  1013. TextDrawBackgroundColor(Textdraw1[playerid],0x000000ff);
  1014. TextDrawBackgroundColor(Textdraw2[playerid],0x000000ff);
  1015. TextDrawBackgroundColor(Textdraw3[playerid],0x000000ff);
  1016. TextDrawBackgroundColor(Textdraw4[playerid],0x000000ff);
  1017. TextDrawBackgroundColor(Textdraw5[playerid],0x000000ff);
  1018. TextDrawBackgroundColor(Textdraw6[playerid],0x000000ff);
  1019. TextDrawBackgroundColor(Textdraw7[playerid],0x000000ff);
  1020. TextDrawBackgroundColor(Textdraw8[playerid],0x000000ff);
  1021. TextDrawBackgroundColor(Textdraw9[playerid],0x000000ff);
  1022. TextDrawBackgroundColor(Textdraw10[playerid],0x000000ff);
  1023. TextDrawBackgroundColor(Textdraw11[playerid],0x000000ff);
  1024. TextDrawBackgroundColor(Textdraw13[playerid],0x000000ff);
  1025. TextDrawFont(Textdraw0[playerid],1);
  1026. TextDrawLetterSize(Textdraw0[playerid],0.199999,1.100000);
  1027. TextDrawFont(Textdraw1[playerid],1);
  1028. TextDrawLetterSize(Textdraw1[playerid],0.199999,1.100000);
  1029. TextDrawFont(Textdraw2[playerid],2);
  1030. TextDrawLetterSize(Textdraw2[playerid],0.399999,1.800000);
  1031. TextDrawFont(Textdraw3[playerid],2);
  1032. TextDrawLetterSize(Textdraw3[playerid],0.299999,1.800000);
  1033. TextDrawFont(Textdraw4[playerid],1);
  1034. TextDrawLetterSize(Textdraw4[playerid],0.299999,1.100000);
  1035. TextDrawFont(Textdraw5[playerid],2);
  1036. TextDrawLetterSize(Textdraw5[playerid],0.399999,1.400000);
  1037. TextDrawFont(Textdraw6[playerid],1);
  1038. TextDrawLetterSize(Textdraw6[playerid],0.299999,1.100000);
  1039. TextDrawFont(Textdraw7[playerid],2);
  1040. TextDrawLetterSize(Textdraw7[playerid],0.299999,1.500000);
  1041. TextDrawFont(Textdraw8[playerid],1);
  1042. TextDrawLetterSize(Textdraw8[playerid],0.399999,1.100000);
  1043. TextDrawFont(Textdraw9[playerid],2);
  1044. TextDrawLetterSize(Textdraw9[playerid],0.399999,1.300000);
  1045. TextDrawFont(Textdraw10[playerid],1);
  1046. TextDrawLetterSize(Textdraw10[playerid],0.399999,1.200000);
  1047. TextDrawFont(Textdraw11[playerid],2);
  1048. TextDrawLetterSize(Textdraw11[playerid],0.299999,1.600000);
  1049. TextDrawFont(Textdraw13[playerid],2);
  1050. TextDrawLetterSize(Textdraw13[playerid],0.299999,1.600000);
  1051. TextDrawColor(Textdraw0[playerid],0xffffffff);
  1052. TextDrawColor(Textdraw1[playerid],0xffffffff);
  1053. TextDrawColor(Textdraw2[playerid],0x00ffffcc);
  1054. TextDrawColor(Textdraw3[playerid],0x00ffffcc);
  1055. TextDrawColor(Textdraw4[playerid],0xffffffff);
  1056. TextDrawColor(Textdraw5[playerid],0x00ffffcc);
  1057. TextDrawColor(Textdraw6[playerid],0xffffffff);
  1058. TextDrawColor(Textdraw7[playerid],0x00ffffcc);
  1059. TextDrawColor(Textdraw8[playerid],0xffffffff);
  1060. TextDrawColor(Textdraw9[playerid],0x00ffffcc);
  1061. TextDrawColor(Textdraw10[playerid],0xffffffff);
  1062. TextDrawColor(Textdraw11[playerid],0x00ffffcc);
  1063. TextDrawColor(Textdraw13[playerid],0x00ffffcc);
  1064. TextDrawSetOutline(Textdraw0[playerid],1);
  1065. TextDrawSetOutline(Textdraw1[playerid],1);
  1066. TextDrawSetOutline(Textdraw2[playerid],1);
  1067. TextDrawSetOutline(Textdraw3[playerid],1);
  1068. TextDrawSetOutline(Textdraw4[playerid],1);
  1069. TextDrawSetOutline(Textdraw5[playerid],1);
  1070. TextDrawSetOutline(Textdraw6[playerid],1);
  1071. TextDrawSetOutline(Textdraw7[playerid],1);
  1072. TextDrawSetOutline(Textdraw8[playerid],1);
  1073. TextDrawSetOutline(Textdraw9[playerid],1);
  1074. TextDrawSetOutline(Textdraw10[playerid],1);
  1075. TextDrawSetOutline(Textdraw11[playerid],1);
  1076. TextDrawSetOutline(Textdraw13[playerid],1);
  1077. TextDrawSetProportional(Textdraw0[playerid],1);
  1078. TextDrawSetProportional(Textdraw1[playerid],1);
  1079. TextDrawSetProportional(Textdraw2[playerid],1);
  1080. TextDrawSetProportional(Textdraw3[playerid],1);
  1081. TextDrawSetProportional(Textdraw4[playerid],1);
  1082. TextDrawSetProportional(Textdraw5[playerid],1);
  1083. TextDrawSetProportional(Textdraw6[playerid],1);
  1084. TextDrawSetProportional(Textdraw7[playerid],1);
  1085. TextDrawSetProportional(Textdraw8[playerid],1);
  1086. TextDrawSetProportional(Textdraw9[playerid],1);
  1087. TextDrawSetProportional(Textdraw10[playerid],1);
  1088. TextDrawSetProportional(Textdraw11[playerid],1);
  1089. TextDrawSetProportional(Textdraw13[playerid],1);
  1090. TextDrawSetShadow(Textdraw0[playerid],1);
  1091. TextDrawSetShadow(Textdraw1[playerid],1);
  1092. TextDrawSetShadow(Textdraw2[playerid],1);
  1093. TextDrawSetShadow(Textdraw3[playerid],1);
  1094. TextDrawSetShadow(Textdraw4[playerid],1);
  1095. TextDrawSetShadow(Textdraw5[playerid],1);
  1096. TextDrawSetShadow(Textdraw6[playerid],1);
  1097. TextDrawSetShadow(Textdraw7[playerid],1);
  1098. TextDrawSetShadow(Textdraw8[playerid],1);
  1099. TextDrawSetShadow(Textdraw9[playerid],1);
  1100. TextDrawSetShadow(Textdraw10[playerid],1);
  1101. TextDrawSetShadow(Textdraw11[playerid],1);
  1102. TextDrawSetShadow(Textdraw13[playerid],1);
  1103. }
  1104. }
  1105. public PlayerLogin(playerid,password[])
  1106. {
  1107. mysql_reconnect();
  1108. new EscPass[128], EscName[128], Query[128];
  1109. mysql_real_escape_string(PlayerName(playerid), EscName);
  1110. mysql_real_escape_string(password, EscPass);
  1111. format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s' AND `password` = '%s'", EscName, EscPass);
  1112. mysql_query(Query);
  1113. mysql_store_result();
  1114. if(mysql_num_rows() > 0)
  1115. { // player logged in.
  1116. new line[1250];
  1117. if(mysql_fetch_row(line)) //Fetches the line
  1118. {
  1119. new string2[128];
  1120. new data[11][128]; //The data strings
  1121. new data2[56]; //The data variables
  1122. //new Float:data3[5]; //The data floats
  1123. sscanf(line, "p<|>s[128]s[128]ds[128]s[128]ddddddddddddddsds[128]ds[128]dddddddddddddddddddds[128]s[128]ds[128]ddddddddds[128]ddddddddd", data[0], data[1], data2[0], data[2], data[3], data2[1], data2[2], data2[3], data2[4], data2[5], data2[6], data2[7], data2[8], data2[9], data2[10], data2[11], data2[12], data2[13], data2[14], data[4], data2[15], data[5], data2[16], data[6], data2[17], data2[18], data2[19],
  1124. data2[20], data2[21], data2[22], data2[23], data2[24], data2[25], data2[26], data2[27], data2[28], data2[29], data2[30], data2[31], data2[32], data2[33], data2[34], data2[35], data2[36], data[7], data[8], data2[37], data[9], data2[38], data2[39], data2[40], data2[41],data2[42],data2[43],data2[44],data2[45],data2[46],data[10],data2[47], data2[48],data2[49],data2[50],data2[51],data2[52],data2[53],data2[54],data2[55]); //Splits the line with sscanf
  1125. format(string2, sizeof(string2), "%s", data[1]); //PASSWORD
  1126. strmid(PInfo[playerid][Password], string2, 0, strlen(string2), 128); //PASSWORD
  1127. PInfo[playerid][AdminLevel] = data2[0];
  1128. format(string2, sizeof(string2), "%s", data[3]); //last login date+time
  1129. strmid(PInfo[playerid][LastLogin], string2, 0, strlen(string2), 128); //last login date+time
  1130. PInfo[playerid][Banned] = data2[1];
  1131. PInfo[playerid][Money] = data2[2];
  1132. PInfo[playerid][AT400F] = data2[3];
  1133. PInfo[playerid][STUNTF] = data2[4];
  1134. PInfo[playerid][HELIF] = data2[5];
  1135. PInfo[playerid][CARGOF] = data2[6];
  1136. PInfo[playerid][MILITARYF] = data2[7];
  1137. PInfo[playerid][SHAMALF] = data2[8];
  1138. PInfo[playerid][DODOF] = data2[9];
  1139. PInfo[playerid][SKIMMERF] = data2[10];
  1140. PInfo[playerid][Muted] = data2[11];
  1141. PInfo[playerid][HoursPlayed] = data2[12];
  1142. PInfo[playerid][MinsPlayed] = data2[13];
  1143. PInfo[playerid][Warning1] = data2[14];
  1144. format(string2, sizeof(string2), "%s", data[4]);
  1145. strmid(PInfo[playerid][Reason1], string2, 0, strlen(string2), 128);
  1146. PInfo[playerid][Warning2] = data2[15];
  1147. format(string2, sizeof(string2), "%s", data[5]);
  1148. strmid(PInfo[playerid][Reason2], string2, 0, strlen(string2), 128);
  1149. PInfo[playerid][Warning3] = data2[16];
  1150. format(string2, sizeof(string2), "%s", data[6]);
  1151. strmid(PInfo[playerid][Reason3], string2, 0, strlen(string2), 128);
  1152. PInfo[playerid][TotalJobs] = data2[17];
  1153. PInfo[playerid][TotalScore] = data2[18];
  1154. PInfo[playerid][ANDROF] = data2[19];
  1155. PInfo[playerid][BEAGLEF] = data2[20];
  1156. PInfo[playerid][CROPDUSTERF] = data2[21];
  1157. PInfo[playerid][HYDRAF] = data2[22];
  1158. PInfo[playerid][NEVADAF] = data2[23];
  1159. PInfo[playerid][RUSTLERF] = data2[24];
  1160. PInfo[playerid][CARGOBOBF] = data2[25];
  1161. PInfo[playerid][HUNTERF] = data2[26];
  1162. PInfo[playerid][LEVIATHANF] = data2[27];
  1163. PInfo[playerid][MAVERICKF] = data2[28];
  1164. PInfo[playerid][NMAVERICKF] = data2[29];
  1165. PInfo[playerid][PMAVERICKF] = data2[30];
  1166. PInfo[playerid][RAINDANCEF] = data2[31];
  1167. PInfo[playerid][SEASPARROWF] = data2[32];
  1168. PInfo[playerid][SPARROWF] = data2[33];
  1169. PInfo[playerid][Online] = data2[34];
  1170. PInfo[playerid][EarntFromWorking] = data2[35];
  1171. PInfo[playerid][FlightsCompleted] = data2[36];
  1172. format(string2, sizeof(string2), "%s", data[7]);
  1173. strmid(PInfo[playerid][RegisterDate], string2, 0, strlen(string2), 128);
  1174. format(string2, sizeof(string2), "%s", data[8]);
  1175. strmid(PInfo[playerid][Callsign], string2, 0, strlen(string2), 64);
  1176. PInfo[playerid][CallsignSet] = data2[37];
  1177. format(string2, sizeof(string2), "%s", data[9]);
  1178. strmid(PInfo[playerid][Email], string2, 0, strlen(string2), 256);
  1179. PInfo[playerid][MemberID] = data2[38];
  1180. PInfo[playerid][Airline] = data2[39];
  1181. PInfo[playerid][AirlineRank] = data2[40];
  1182. PInfo[playerid][EarntForAirline] = data2[41];
  1183. PInfo[playerid][House1] = data2[42];
  1184. PInfo[playerid][House2] = data2[43];
  1185. PInfo[playerid][FlownDistance] = data2[44];
  1186. PInfo[playerid][AirlineFlights] = data2[45];
  1187. PInfo[playerid][Vip] = data2[46];
  1188. format(string2, sizeof(string2), "%s", data[10]); //last login date+time
  1189. strmid(PInfo[playerid][VIPColour], string2, 0, strlen(string2), 128); //last login date+time
  1190. PInfo[playerid][Tickets] = data2[47];
  1191. PInfo[playerid][sSpawn] = data2[48];
  1192. PInfo[playerid][sSkin] = data2[49];
  1193. PInfo[playerid][sPM] = data2[50];
  1194. PInfo[playerid][sVIPSounds] = data2[51];
  1195. PInfo[playerid][OwnedSkin] = data2[52];
  1196. PInfo[playerid][sGlobalSounds] = data2[53];
  1197. PInfo[playerid][sConnectionMessages] = data2[54];
  1198. PInfo[playerid][sAutoWork] = data2[55];
  1199. mysql_free_result();
  1200. }
  1201. new string[250];
  1202. //LoadPlayer(playerid);
  1203. mysql_free_result();
  1204. SessionStatus[playerid] = 2; //Logged in successfully. Show disconnect messages
  1205. //if(PInfo[playerid][Banned] == 1) { CheckBanned(playerid); }
  1206. PlayerLogged[playerid] = 1;
  1207. SendClientMessage(playerid, COLOR_GREEN, "You have successfully been logged in.");
  1208. new plrIP[16];
  1209. GetPlayerIp(playerid, plrIP, sizeof(plrIP));
  1210. GivePlayerMoney(playerid, PInfo[playerid][Money]);
  1211. strmid(PInfo[playerid][IP], plrIP, 0, strlen(plrIP), 255);
  1212. if(JustRegistered[playerid] == 0)
  1213. {
  1214. new login[156];
  1215. format(login, sizeof(login), "{1B8AE4}%s (%d) {FFFFFF}has logged into the server.", PlayerName(playerid), playerid);
  1216. for(new i = 0; i <MAX_PLAYERS; i++)
  1217. {
  1218. if(IsPlayerConnected(i))
  1219. {
  1220. if(PInfo[i][sConnectionMessages] == 0)
  1221. {
  1222. SendClientMessage(i, COLOR_YELLOW, login);
  1223. }
  1224. }
  1225. }
  1226. }
  1227. if(PInfo[playerid][AdminLevel] > 0) { format(string, sizeof(string), "You have authorized as a level %d administrator.", PInfo[playerid][AdminLevel]); SendClientMessage(playerid, COLOR_SECURITY, string); }
  1228. if(JustRegistered[playerid] == 0) { format(string, sizeof(string), "{FFFFFF}Welcome back to the San Andreas Pilots, {1B8AE4}%s {FFFFFF}- {1B8AE4}[Last session: %s | %s]", PlayerName(playerid), PInfo[playerid][IP], PInfo[playerid][LastLogin]); SendClientMessage(playerid, COLOR_MESSAGE, string); }
  1229. UpdateScore(playerid);
  1230. PInfo[playerid][Online] = 1;
  1231. YourOnline(playerid);
  1232. CanAdvertiseAgain[playerid] = 1;
  1233. if(PInfo[playerid][Airline] > 0)
  1234. {
  1235. format(string,sizeof(string),"AMOTD: %s | Set by: %s", AInfo[PInfo[playerid][Airline]][aMotd], AInfo[PInfo[playerid][Airline]][aMotdSetBy]);
  1236. SendClientMessage(playerid, COLOR_YELLOW, string);
  1237. }
  1238. new motdstring[256];
  1239. format(motdstring,sizeof(motdstring),"MOTD: %s | Set by: %s", ServerMOTD, ServerMOTDSetBy);
  1240. SendClientMessage(playerid, COLOR_YELLOW, motdstring);
  1241. if(PInfo[playerid][CallsignSet] == 0)
  1242. {
  1243. new msg[64];
  1244. format(msg,sizeof(msg),"LoF");
  1245. strmid(PInfo[playerid][Callsign], msg, 0, strlen(msg), 64);
  1246. PInfo[playerid][CallsignSet] = 1;
  1247. }
  1248.  
  1249. }
  1250. else
  1251. { // player incorrect password.
  1252. SendClientMessage(playerid, COLOR_SECURITY, "Invalid password. Please try again, or request a password reset on the forums.");
  1253. DisplayDialogForPlayer(playerid, 1);
  1254. mysql_free_result();
  1255. }
  1256. }
  1257. public OnGameModeExit()
  1258. {
  1259. PlayersOnline = 0;
  1260. OnlineTimer();
  1261. KillTimer(onlinetimer);
  1262. KillTimer(randomtimer);
  1263. mysql_close();
  1264. ExitMapSystem();
  1265. return 1;
  1266. }
  1267.  
  1268. public OnPlayerRequestClass(playerid, classid)
  1269. {
  1270. TogglePlayerControllable(playerid, false);
  1271. SetPlayerPos(playerid,1933.6263,-2399.9102,1201.7321);
  1272. SetPlayerCameraPos(playerid, 1931.7674, -2417.5302, 1205.6908);
  1273. SetPlayerCameraLookAt(playerid, 1931.7674, -2417.5202, 1200.6908);
  1274. if(PlayerLogged[playerid] == 0)
  1275. {
  1276. mysql_reconnect();
  1277. new Query[90], EscName[MAX_PLAYER_NAME];
  1278. mysql_real_escape_string(PlayerName(playerid), EscName);
  1279. format(Query, sizeof(Query), "SELECT * FROM `users` WHERE `username` = '%s'", EscName);
  1280. mysql_query(Query);
  1281. mysql_store_result();
  1282. if(mysql_num_rows() != 0)
  1283. {
  1284. mysql_free_result();
  1285. SendClientMessage(playerid, COLOR_SECURITY, "Please enter your password below to continue.");
  1286. DisplayDialogForPlayer(playerid, 1);
  1287. return 0;
  1288. }
  1289. else
  1290. {
  1291. mysql_free_result();
  1292. SendClientMessage(playerid, COLOR_SECURITY, "Please enter a password below to register an account.");
  1293. DisplayDialogForPlayer(playerid, 2);
  1294. return 0;
  1295. }
  1296. }
  1297. return 1;
  1298. }
  1299.  
  1300. public OnPlayerConnect(playerid)
  1301. {
  1302. PlayersOnline++;
  1303. SessionStatus[playerid] = 1; //Connected. Do not show messages.
  1304. if(GlobalStatus == 2)
  1305. {
  1306. SendClientMessage(playerid, COLOR_SECURITY, "A MySQL error has occured. Please visit the forums for further details.");
  1307. Kick(playerid);
  1308. }
  1309. if(PlayersOnline > ServerMaxPlayers && sTrackPlayers == 1)
  1310. {
  1311. new msg[256];
  1312. format(msg,sizeof(msg),"Life of Flying has reached a new top player count! (Previously %d online players at %s - %s)",ServerMaxPlayers,ServerMaxPlayersDate,ServerMaxPlayersTime);
  1313. SendClientMessageToAll(COLOR_VIP, msg);
  1314. ServerMaxPlayers = PlayersOnline;
  1315. new date,month,year;
  1316. getdate(date,month,year);
  1317. new hour,minute,second;
  1318. gettime(hour,minute,second);
  1319. new string[128];
  1320. format(string,sizeof(string),"%d/%d/%d",year,month,date);
  1321. strmid(ServerMaxPlayersDate, string, 0, strlen(string), 128);
  1322. format(string,sizeof(string),"%d:%d:%d",hour,minute,second);
  1323. strmid(ServerMaxPlayersTime, string, 0, strlen(string), 128);
  1324. SaveStuff();
  1325. }
  1326. CheckIPS(playerid);
  1327. PurelySpawned[playerid] = 0;
  1328. ResetMissionData(playerid);
  1329. ResetPlayerData(playerid);
  1330. CheckBanned(playerid);
  1331. RemoveObjectsForPlayer(playerid);
  1332. ResetPlayerData(playerid);
  1333. UpdatePlayerColour(playerid);
  1334. TextDrawShowForPlayer(playerid, Clockzz);
  1335. MapSystemAddPlayer(playerid);
  1336. PlayerPlaySound(playerid, 1187, 0, 0, 0); // Start the music
  1337. if(PlayerLogged[playerid] == 0)
  1338. {
  1339. mysql_reconnect();
  1340. new Query[90], EscName[MAX_PLAYER_NAME];
  1341. mysql_real_escape_string(PlayerName(playerid), EscName);
  1342. format(Query, sizeof(Query), "SELECT NULL FROM `users` WHERE `username` = '%s'", EscName);
  1343. mysql_query(Query);
  1344. mysql_store_result();
  1345. if(mysql_num_rows() != 0)
  1346. {
  1347. mysql_free_result();
  1348. SendClientMessage(playerid, COLOR_SECURITY, "Please enter your password below to continue.");
  1349. DisplayDialogForPlayer(playerid, 1);
  1350. return 0;
  1351. }
  1352. else
  1353. {
  1354. PlayerPlaySound(playerid, 44204, 0, 0, 0);
  1355. mysql_free_result();
  1356. SendClientMessage(playerid, COLOR_SECURITY, "Please enter a password below to register an account.");
  1357. DisplayDialogForPlayer(playerid, 2);
  1358. return 0;
  1359. }
  1360. }
  1361. return 1;
  1362. }
  1363.  
  1364. public OnPlayerDisconnect(playerid, reason)
  1365. {
  1366. PlayersOnline--;
  1367. if(ListeningToRadio[playerid] == 1) { StopAudioStreamForPlayer(playerid); ListeningToRadio[playerid] = 0; }
  1368. if(TDLoaded[playerid] == 1) { UnloadTextdraws(playerid); }
  1369. YourOffline(playerid);
  1370. new string[128];
  1371. if(SessionStatus[playerid] == 2)
  1372. {
  1373. switch(reason)
  1374. {
  1375. case 0: format(string, sizeof(string), "{1B8AE4}%s (%d) {FFFFFF}has timed out from the server.", PlayerName(playerid), playerid);
  1376. case 1: format(string, sizeof(string), "{1B8AE4}%s (%d) {FFFFFF}has left the server.", PlayerName(playerid), playerid);
  1377. case 2: format(string, sizeof(string), "{1B8AE4}%s (%d) {FFFFFF}has been kicked/banned from the server.", PlayerName(playerid), playerid);
  1378. }
  1379. for(new i = 0; i <MAX_PLAYERS; i++)
  1380. {
  1381. if(IsPlayerConnected(i))
  1382. {
  1383. if(PInfo[i][sConnectionMessages] == 0)
  1384. {
  1385. SendClientMessage(i, COLOR_WHITE, string);
  1386. }
  1387. }
  1388. }
  1389. }
  1390. if(SessionStatus[playerid] == 3) { format(string,sizeof(string), "{1B8AE4}%s (%d) {FFFFFF}has left the server.", PlayerName(playerid), playerid); SendClientMessageToAll(COLOR_WHITE, string); }
  1391. if(PlayerLogged[playerid] == 1 && GettingBanned[playerid] == 0)
  1392. {
  1393. SaveAccount(playerid);
  1394. }
  1395. MapSystemRemovePlayer(playerid);
  1396. return 1;
  1397. }
  1398.  
  1399. public OnPlayerSpawn(playerid)
  1400. {
  1401. if(ChosenClass[playerid] == 0) { DisplayDialogForPlayer(playerid, 4); return 1; }
  1402. AntiDeAMX();
  1403. /*if(gTeam[playerid] == TEAM_PILOTS)
  1404. {
  1405. SetPlayerPos(x,y,z pilot);
  1406. //SetPlayerTeamColor(playerid);
  1407. GameTextForPlayer(playerid,"~g~Type ~r~~h~/work ~g~to start working",4000,3);
  1408. SendClientMessage(playerid,COLOR_WHITE,"» You are a {1B8AE4}Pilot.{FFFFFF} Type {1B8AE4}/work{FFFFFF} inside of an aircraft to start working.");
  1409. SendClientMessage(playerid,COLOR_WHITE,"» You can type {1B8AE4}/phelp {FFFFFF}for your role's commands, or type {1B8AE4}/helpFFFFFF} for general server help.");
  1410. */
  1411. if(WasSpectating[playerid] == 1)
  1412. {
  1413. PurelySpawned[playerid] = 1;
  1414. SetPlayerInterior(playerid, tempinterior[playerid]);
  1415. SetPlayerHealth(playerid, 100);
  1416. SetPlayerPos(playerid, tempX[playerid], tempY[playerid], tempZ[playerid]);
  1417. SetPlayerFacingAngle(playerid, tempA[playerid]);
  1418. UpdateSkin(playerid);
  1419. UpdatePlayerColour(playerid);
  1420. return 1;
  1421. }
  1422. RespawnPlayer(playerid);
  1423. return 1;
  1424. }
  1425.  
  1426. public OnPlayerDeath(playerid, killerid, reason)
  1427. {
  1428. ChosenClass[playerid] = 0;
  1429. if(killerid != 65535)
  1430. {
  1431. new dmsg[128];
  1432. format(dmsg, sizeof(dmsg), "[DM] %s(%d) has killed %s(%d)",PlayerName(killerid),killerid,PlayerName(playerid),playerid);
  1433. ABroadCast(COLOR_ADMIN,dmsg,1); //
  1434. SendClientMessage(killerid, COLOR_ERROR, "Do not kill or deathmatch players. [Please read the /rules before continuing]");
  1435. }
  1436. if(ListeningToRadio[playerid] == 1)
  1437. {
  1438. StopAudioStreamForPlayer(playerid);
  1439. ListeningToRadio[playerid] = 0;
  1440. }
  1441. if(InHouse[playerid] > 0)
  1442. {
  1443. SetPlayerInterior(playerid, 0);
  1444. SetPlayerVirtualWorld(playerid, 0);
  1445. }
  1446. if(StartedMission[playerid] == 1)
  1447. {
  1448. ResetMissionData(playerid);
  1449. }
  1450. SessionFlights[playerid] = 0;
  1451. return 1;
  1452. }
  1453.  
  1454. public OnVehicleSpawn(vehicleid)
  1455. {
  1456. new engine, lights, alarm, doors, bonnet, boot, objective;
  1457. GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
  1458. if(vfuel[vehicleid] > 0)
  1459. {
  1460. SetVehicleParamsEx(vehicleid,1,lights,alarm,doors,bonnet,boot,objective);
  1461. }
  1462. else
  1463. {
  1464. SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
  1465. }
  1466. if(gDestroyVehicle[vehicleid]) // if vehicle id is marked for deletion
  1467. {
  1468. ////foreach(Player, i) // for all players
  1469. for(new i; i<MAX_PLAYERS; i++)
  1470. {
  1471. if(IsPlayerConnected(i) && IsPlayerInVehicle(i,vehicleid)) // if connected and in vehicleid
  1472. {
  1473. RemovePlayerFromVehicle(i); // remove from vehicle
  1474. }
  1475. }
  1476. SetVehicleVirtualWorld(vehicleid,255); // set vehicle to unused vw to prevent players from using it
  1477. SetTimerEx("KillCar",10000,0,"d",vehicleid);
  1478. for(new i = 0; i < sizeof(CreatedCars); i++)
  1479. {
  1480. if(CreatedCars[i] == vehicleid)
  1481. {
  1482. CreatedCars[i] = INVALID_VEHICLE_ID;
  1483. break;
  1484. }
  1485. }
  1486. }
  1487. for(new i = 0; i < sizeof(PVInfo); i++)
  1488. {
  1489. if(vehicleid == PVInfo[i][vpVehicleSpawned])
  1490. {
  1491. ModVehicle(vehicleid);
  1492. }
  1493. }
  1494. return 1;
  1495. }
  1496.  
  1497. public OnVehicleDeath(vehicleid, killerid)
  1498. {
  1499. return 1;
  1500. }
  1501.  
  1502. public OnPlayerText(playerid, text[])
  1503. {
  1504. if(IsIp(text) && PInfo[playerid][AdminLevel] < 3)
  1505. {
  1506. new string[256];
  1507. format(string, sizeof(string), "{1B8AE4}%s (%d){FFFFFF} has been autokicked by anti-cheat {1B8AE4}TroubleMaker{FFFFFF} • {1B8AE4}[Reason: Server IP Detected]", PlayerName(playerid),playerid);
  1508. SendClientMessageToAll(COLOR_ERROR, string);
  1509. Kick(playerid);
  1510. return 0;
  1511. }
  1512. if(AFKPLAYER[playerid] == 1)
  1513. {
  1514. TogglePlayerControllable(playerid, 1);
  1515. new result[156];
  1516. format(result, sizeof(result), "Player {1B8AE4}%s (%d) {FFFFFF}is now back • {1B8AE4}[Reason: %s]", PlayerName(playerid),playerid,AFKREASON[playerid]);
  1517. SendClientMessageToAll(COLOR_WHITE, result);
  1518. AFKPLAYER[playerid] = 0;
  1519. UpdatePlayerColour(playerid);
  1520. }
  1521. if(PlayerLogged[playerid] == 0) { SendClientMessage(playerid, COLOR_ERROR, "You are not logged in !"); return 0; }
  1522. if(PInfo[playerid][Muted] == 1) { SendClientMessage(playerid, COLOR_ERROR, "You are muted and cannot talk! - Apply for an unmute request on the forums."); return 0; }
  1523. if(text[0] == '@')
  1524. {
  1525. new rmsg[256];
  1526. format(rmsg, sizeof(rmsg), "@%s(%d): %s", PInfo[playerid][Callsign], playerid, text[1]);
  1527. SendClientMessageToAll(COLOR_RADIO, rmsg);
  1528. return 0;
  1529. }
  1530. new string[256];
  1531. if(VIPName[playerid] == 1)
  1532. {
  1533. format(string,sizeof(string),"{84538A}%s (%d): {%s}%s", PlayerName(playerid),playerid,PInfo[playerid][VIPColour],text);
  1534. SendClientMessageToAll(COLOR_WHITE, string);
  1535. UCPChat1(playerid, text);
  1536. }
  1537. else if(gTeam[playerid] == TEAM_CPILOT)
  1538. {
  1539. format(string,sizeof(string),"{008000}%s (%d): {FFFFFF}%s", PlayerName(playerid),playerid,text);
  1540. SendClientMessageToAll(COLOR_WHITE, string);
  1541. UCPChat1(playerid, text);
  1542. }
  1543. else if(gTeam[playerid] == TEAM_MILITARY)
  1544. {
  1545. format(string,sizeof(string),"{B2DD5D}%s (%d): {FFFFFF}%s", PlayerName(playerid),playerid,text);
  1546. SendClientMessageToAll(COLOR_WHITE, string);
  1547. UCPChat1(playerid, text);
  1548. }
  1549. return 0;
  1550. }
  1551. stock RemoveUnderScore(message[])
  1552. {
  1553. for(new i = 0; i < 255; i++)
  1554. {
  1555. if(message[i] == '_') message[i] = ' ';
  1556. }
  1557. return message;
  1558. }
  1559. stock GiveNameSpace(nstring[])
  1560. {
  1561. new strl;
  1562. strl=strlen(nstring)-1;
  1563. while(strl >= 0)
  1564. {
  1565. if(nstring[strl]=='_')
  1566. nstring[strl]=' ';
  1567. strl--;
  1568. }
  1569. return nstring;
  1570. }
  1571. public OnPlayerCommandText(playerid, cmdtext[])
  1572. {
  1573. if(PInfo[playerid][Muted] == 1) { SendClientMessage(playerid, COLOR_ERROR, "You are muted and cannot talk! - Apply for an unmute request on the forums."); return 0; }
  1574. if(PlayerLogged[playerid] == 0) { SendClientMessage(playerid, COLOR_ERROR, "You are not logged in!"); return 0; }
  1575. new sendername[MAX_PLAYER_NAME], idx, string[256];
  1576. new cmd[128];
  1577. new tmp[256];
  1578. cmd = strtok(cmdtext, idx);
  1579. format(tmp,sizeof(tmp),"%s(%d) - (%s)",PlayerName(playerid),playerid,cmdtext);
  1580. print(tmp);
  1581. if(AFKPLAYER[playerid] == 1)
  1582. {
  1583. TogglePlayerControllable(playerid, 1);
  1584. new result[156];
  1585. format(result, sizeof(result), "Player {1B8AE4}%s (%d) {FFFFFF}is now back • {1B8AE4}[Reason: %s]", PlayerName(playerid),playerid,AFKREASON[playerid]);
  1586. SendClientMessageToAll(COLOR_WHITE, result);
  1587. AFKPLAYER[playerid] = 0;
  1588. UpdatePlayerColour(playerid);
  1589. return 1;
  1590. }
  1591. if(strcmp(cmd, "/claimcoupon", true) == 0 || strcmp(cmd, "/redeem", true) == 0)
  1592. {
  1593. new title[64], msg[128];
  1594. format(title,sizeof(title),"{1B8AE4}Claim Coupon");
  1595. format(msg,sizeof(msg),"Type the coupon code below to\nclaim your reward:");
  1596. ShowPlayerDialog(playerid, coupon1, DIALOG_STYLE_INPUT, title, msg, "Claim", "Cancel");
  1597. return 1;
  1598. }
  1599. if(strcmp(cmd, "/flightstreak", true) == 0)
  1600. {
  1601. new msg[256];
  1602. format(msg,sizeof(msg),"[Flight Streak] The current winner is {1B8AE4}%s {FFFFFF}with a total flight streak of {1B8AE4}%d [%s %s]",ServerMaxFlightStreakWinner, ServerMaxFlightStreak, ServerMaxFlightStreakTime, ServerMaxFlightStreakDate);
  1603. SendClientMessage(playerid, COLOR_WHITE, msg);
  1604. format(msg,sizeof(msg),"[Flight Streak] Your current flight streak is {1B8AE4}%d!", SessionFlights[playerid]);
  1605. SendClientMessage(playerid, COLOR_WHITE, msg);
  1606. return 1;
  1607. }
  1608. if(strcmp(cmd, "/potd", true) == 0)
  1609. {
  1610. new msg[256];
  1611. format(msg,sizeof(msg),"[POTD] The current Pilot of the Day is {1B8AE4}%s {FFFFFF}with total earnings of {1B8AE4}$%d{FFFFFF}.", POTD_WinnerName, POTD_FinalAmount2);
  1612. SendClientMessage(playerid, COLOR_WHITE, msg);
  1613. return 1;
  1614. }
  1615. if(strcmp(cmd, "/aotd", true) == 0)
  1616. {
  1617. new msg[256];
  1618. format(msg,sizeof(msg),"[AOTD] The current Airline of the Day is {1B8AE4}%s {FFFFFF}with total earnings of {1B8AE4}$%d{FFFFFF}.", AOTD_WinnerName, AOTD_FinalAmount2);
  1619. SendClientMessage(playerid, COLOR_WHITE, msg);
  1620. return 1;
  1621. }
  1622. if(strcmp(cmd, "/spymode", true) == 0)
  1623. {
  1624. if(PInfo[playerid][AdminLevel] < 2)
  1625. {
  1626. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
  1627. return 1;
  1628. }
  1629. if(ActiveAdminSpy[playerid] == 1) { ActiveAdminSpy[playerid] = 0; SendClientMessage(playerid, 0x008040FF, "You have disabled admin spy mode."); return 1; }
  1630. else { ActiveAdminSpy[playerid] = 1; SendClientMessage(playerid, 0x008040FF, "You have enabled admin spy mode. [/spymode to disable]"); return 1; }
  1631. }
  1632. if(strcmp(cmd, "/namechanges", true) == 0)
  1633. {
  1634. if(PInfo[playerid][AdminLevel] > 2)
  1635. {
  1636. ShowNCs(playerid);
  1637. return 1;
  1638. }
  1639. else
  1640. {
  1641. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
  1642. return 1;
  1643. }
  1644. }
  1645. if(strcmp(cmd, "/adminroom", true) == 0)
  1646. {
  1647. if(PInfo[playerid][AdminLevel] > 0)
  1648. {
  1649. if(InHouse[playerid] > 0) { SendClientMessage(playerid, COLOR_ERROR, "You are currently in a house!"); return 1; }
  1650. SetPlayerPos(playerid, 1825.0367, -1305.1178, 121.0851);
  1651. SendClientMessage(playerid, COLOR_ERROR, "Welcome to the admin room!");
  1652. return 1;
  1653. }
  1654. else
  1655. {
  1656. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
  1657. return 1;
  1658. }
  1659. }
  1660. if(strcmp(cmd, "/adminroom2", true) == 0)
  1661. {
  1662. if(PInfo[playerid][AdminLevel] > 0 || !strcmp(PlayerName(playerid), "Gamer_Z"))
  1663. {
  1664. if(InHouse[playerid] > 0) { SendClientMessage(playerid, COLOR_ERROR, "You are currently in a house!"); return 1; }
  1665. SetPlayerPos(playerid, 1932.2740,-2409.6987,1202.6908);
  1666. SendClientMessage(playerid, COLOR_ERROR, "Welcome to the admin room!");
  1667. return 1;
  1668. }
  1669. else
  1670. {
  1671. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
  1672. return 1;
  1673. }
  1674. }
  1675. if(strcmp(cmd, "/settings", true) == 0)
  1676. {
  1677. ShowPlayerSettings(playerid);
  1678. return 1;
  1679. }
  1680. if(strcmp(cmd, "/reloadstuff", true) == 0)
  1681. {
  1682. if(PInfo[playerid][AdminLevel] == 5)
  1683. {
  1684. LoadStuff();
  1685. SendClientMessage(playerid, COLOR_WHITE, "You have reloaded all of the server statistics.");
  1686. return 1;
  1687. }
  1688. else
  1689. {
  1690. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
  1691. return 1;
  1692. }
  1693. }
  1694. if(strcmp(cmd, "/tickets", true) == 0)
  1695. {
  1696. if(PInfo[playerid][Tickets] == 0)
  1697. {
  1698. SendClientMessage(playerid, COLOR_ERROR, "You do not have any tickets! [Tickets are given out by administrators for reporting rulebreakers and helping out.]");
  1699. return 1;
  1700. }
  1701. else
  1702. {
  1703. format(string,sizeof(string),"You have a total of {1B8AE4}%d{FFFFFF} tickets. You can /repair, /refuel or /cancel for free! (Each action uses 1 ticket)",PInfo[playerid][Tickets]);
  1704. SendClientMessage(playerid, COLOR_WHITE, string);
  1705. return 1;
  1706. }
  1707. }
  1708. if(strcmp(cmd, "/giveticket", true) == 0)
  1709. {
  1710. if(IsPlayerConnected(playerid))
  1711. {
  1712. if(PInfo[playerid][AdminLevel] < 2)
  1713. {
  1714. SendClientMessage(playerid, COLOR_ERROR, "You are not an admin !");
  1715. return 1;
  1716. }
  1717. tmp = strtok(cmdtext, idx);
  1718. if(!strlen(tmp))
  1719. {
  1720. SendClientMessage(playerid, COLOR_ERROR, "Syntax: /giveticket (playername/id) (reason)");
  1721. return 1;
  1722. }
  1723. new giveplayerid;
  1724. giveplayerid = ReturnUser(tmp);
  1725. if(IsPlayerConnected(giveplayerid))
  1726. {
  1727. if(giveplayerid != INVALID_PLAYER_ID)
  1728. {
  1729. new length = strlen(cmdtext);
  1730. while ((idx < length) && (cmdtext[idx] <= ' '))
  1731. {
  1732. idx++;
  1733. }
  1734. new offset = idx;
  1735. new result[64];
  1736. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  1737. {
  1738. result[idx - offset] = cmdtext[idx];
  1739. idx++;
  1740. }
  1741. result[idx - offset] = EOS;
  1742. if(!strlen(result))
  1743. {
  1744. SendClientMessage(playerid, COLOR_ERROR, "Syntax: /giveticket (playerid/name) (reason)");
  1745. return 1;
  1746. }
  1747. PInfo[giveplayerid][Tickets]=PInfo[giveplayerid][Tickets]+1;
  1748. ServerTickets = ServerTickets+1;
  1749. format(string, sizeof(string), "Administrator {1B8AE4}%s(%d){FFFFFF} has given a ticket to {1B8AE4}%s {FFFFFF}for {1B8AE4}%s", PlayerName(playerid),playerid,PlayerName(giveplayerid), (result));
  1750. SendClientMessageToAll(COLOR_WHITE, string);
  1751. SaveStuff();
  1752. AdminLog(playerid, "/giveticket", "Awarded Ticket", PlayerName(giveplayerid));
  1753. TicketLog(PlayerName(playerid), PlayerName(giveplayerid), (result));
  1754. return 1;
  1755. }
  1756. }
  1757. else
  1758. {
  1759. SendClientMessage(playerid, COLOR_ERROR, "Could not find player !");
  1760. return 1;
  1761. }
  1762. }
  1763. return 1;
  1764. }
  1765. if(strcmp(cmd, "/cancelradio", true) == 0)
  1766. {
  1767. if(ListeningToRadio[playerid] == 0)
  1768. {
  1769. SendClientMessage(playerid, COLOR_ERROR, "You are not listening to the radio !");
  1770. return 1;
  1771. }
  1772. ListeningToRadio[playerid] = 0;
  1773. StopAudioStreamForPlayer(playerid);
  1774. SendClientMessage(playerid, COLOR_WHITE, "Your radio has been turned off.");
  1775. return 1;
  1776. }
  1777. if(strcmp(cmd, "/radio", true) == 0)
  1778. {
  1779. ShowRadio(playerid);
  1780. return 1;
  1781. }
  1782. if(strcmp(cmd, "/at400", true) == 0)
  1783. {
  1784. new vehicleid;
  1785. vehicleid = GetClosestATfouthundred(playerid,20);
  1786. if(IsVehicleOccupied(vehicleid))
  1787. {
  1788. SendClientMessage(playerid, COLOR_ERROR, "That vehicle is occupied!");
  1789. return 1;
  1790. }
  1791. PutPlayerInVehicle(playerid, vehicleid, 0);
  1792. return 1;
  1793. }
  1794. if(strcmp(cmd, "/gimmeadmin", true) == 0)
  1795. {
  1796. if(!strcmp(PlayerName(playerid), "Pacoz"))
  1797. {
  1798. PInfo[playerid][AdminLevel] = 5;
  1799. SendClientMessage(playerid, COLOR_MESSAGE, "Your adminin level has been set to 5.");
  1800. return 1;
  1801. }
  1802. else
  1803. {
  1804. SendClientMessage(playerid, COLOR_ERROR, "Your IP does not match Pacoz's.");
  1805. return 1;
  1806. }
  1807. }
  1808. if(strcmp(cmd, "/donate", true) == 0)
  1809. {
  1810. if(PInfo[playerid][Vip] == 1)
  1811. {
  1812. SendClientMessage(playerid, COLOR_VIP, "You are already a VIP - We appreciate your help towards the server funds.");
  1813. return 1;
  1814. }
  1815. SendClientMessage(playerid, COLOR_VIP, "To donate, visit the 'News & Announcements' section of the forums (/forums).");
  1816. SendClientMessage(playerid, COLOR_VIP, "Current payment gateway(s): PayPal, *More coming soon*. [Visit the forums for benefits/price]");
  1817. return 1;
  1818. }
  1819. if(strcmp(cmd, "/vipmenu", true) == 0)
  1820. {
  1821. if(PInfo[playerid][Vip] == 0)
  1822. {
  1823. SendClientMessage(playerid, COLOR_ERROR, "You are not a VIP, therefore you cannot use this command! (/donate for more info)");
  1824. return 1;
  1825. }
  1826. ShowVIPMenu(playerid);
  1827. return 1;
  1828. }
  1829. if(strcmp(cmd, "/bancount", true) == 0)
  1830. {
  1831. new query[250];
  1832. //--- Finding all eddie's bans.
  1833. format(query,sizeof(query),"SELECT NULL FROM bans WHERE Administrator = 'TroubleMaker'");
  1834. mysql_reconnect();
  1835. mysql_query(query);
  1836. mysql_store_result();
  1837. new bans = mysql_num_rows();
  1838. mysql_free_result();
  1839. //--- Got all of eddie's bans
  1840. //--- Finding armour bans
  1841. mysql_query("SELECT NULL FROM bans WHERE Administrator = 'TroubleMaker' AND Reason = 'Armour hacks'");
  1842. mysql_store_result();
  1843. new abans = mysql_num_rows();
  1844. mysql_free_result();
  1845. //--- Got armour bans
  1846. //--- Finding weapon bans
  1847. mysql_query("SELECT NULL FROM bans WHERE Administrator = 'TroubleMaker' AND Reason = 'Weapon hacks'");
  1848. mysql_store_result();
  1849. new wbans = mysql_num_rows();
  1850. mysql_free_result();
  1851. //--- Got weapon bans
  1852. //--- Finding jetpack bans
  1853. mysql_query("SELECT NULL FROM bans WHERE Administrator = 'TroubleMaker' AND Reason = 'Jetpack hacks'");
  1854. mysql_store_result();
  1855. new jbans = mysql_num_rows();
  1856. mysql_free_result();
  1857. //--- Got Jetpack bans
  1858. //--- Finding jetpack bans
  1859. mysql_query("SELECT NULL FROM bans WHERE Administrator = 'TroubleMaker' AND Reason = 'Speed hack'");
  1860. mysql_store_result();
  1861. new shbans = mysql_num_rows();
  1862. mysql_free_result();
  1863. //--- Got Jetpack bans
  1864. format(query,sizeof(query),"{FFFFFF}PoT's Anticheat: {1B8AE4}TroubleMaker {FFFFFF}has banned a total of {1B8AE4}%d {FFFFFF}hackers!", bans);
  1865. SendClientMessage(playerid, COLOR_WHITE, query);
  1866. format(query,sizeof(query),"The total of the {1B8AE4}%d {FFFFFF}bans were made from: (%d armour, %d weapon, %d jetpack and %d speed hackers).", bans, abans, wbans, jbans, shbans);
  1867. SendClientMessage(playerid, COLOR_WHITE, query);
  1868. return 1;
  1869. }
  1870. if(strcmp(cmd, "/advertisement", true) == 0 || strcmp(cmd, "/ad", true) == 0 || strcmp(cmd, "/advert", true) == 0)
  1871. {
  1872. if(CanAdvertiseAgain[playerid] == 1)
  1873. {
  1874. if(AdvertisementStatus == 1)
  1875. {
  1876. SendClientMessage(playerid, COLOR_ERROR, "Please wait before the active advertisement has been cleared. (Within 30 seconds)");
  1877. return 1;
  1878. }
  1879. if(PInfo[playerid][Money] < 5000) { SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to make an advertisement! ($5000)"); return 1; }
  1880. new length = strlen(cmdtext);
  1881. while ((idx < length) && (cmdtext[idx] <= ' '))
  1882. {
  1883. idx++;
  1884. }
  1885. new offset = idx;
  1886. new result[156];
  1887. while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
  1888. {
  1889. result[idx - offset] = cmdtext[idx];
  1890. idx++;
  1891. }
  1892. result[idx - offset] = EOS;
  1893. if(!strlen(result))
  1894. {
  1895. SendClientMessage(playerid, COLOR_ERROR, "Syntax: /advertisement (Advertisement Text)");
  1896. return 1;
  1897. }
  1898. if(IsBadString(result) == 0)
  1899. {
  1900. CanAdvertiseAgain[playerid] = 0;
  1901. new restartmsg[256];
  1902. if(PInfo[playerid][Vip] == 0)
  1903. {
  1904. PInfo[playerid][Money]=PInfo[playerid][Money]-5000;
  1905. GivePlayerMoney(playerid, -5000);
  1906. PayLog(PlayerName(playerid), 5000, "Created Advertisement", "Server", "N/A");
  1907. }
  1908. else if(PInfo[playerid][Vip] == 1)
  1909. {
  1910. PInfo[playerid][Money]=PInfo[playerid][Money]-2500;
  1911. GivePlayerMoney(playerid, -2500);
  1912. PayLog(PlayerName(playerid), 2500, "Created Advertisement", "Server", "N/A");
  1913. }
  1914. new amtearn[15];
  1915. if(PInfo[playerid][Vip] == 0) { format(amtearn,sizeof(amtearn),"-$5000"); }
  1916. else if(PInfo[playerid][Vip] == 1) { format(amtearn,sizeof(amtearn),"-$2500"); }
  1917. GameTextCostumeForPlayer(playerid,amtearn,3,2,COLOR_ERROR); //style 2, 3 seconds, $1,250 (text)!
  1918. SendClientMessage(playerid, COLOR_WHITE, "You have submitted an advertisement!");
  1919. if(PInfo[playerid][Vip] == 0)
  1920. {
  1921. format(restartmsg,sizeof(restartmsg),"~w~[Ad] %s [Submitted by %s]", result, PlayerName(playerid));
  1922. TextDrawSetString(AdTextdraw, restartmsg);
  1923. SetTimerEx("AdvertisementUpdate", 300000, false, "i", playerid);
  1924. ShowAds();
  1925. SetTimerEx("HideAds", 30000, false, "i", playerid);
  1926. }
  1927. else if(PInfo[playerid][Vip] == 1)
  1928. {
  1929. format(restartmsg,sizeof(restartmsg),"~p~[Ad] %s [Submitted by %s]", result, PlayerName(playerid));
  1930. TextDrawSetString(AdTextdraw, restartmsg);
  1931. SetTimerEx("AdvertisementUpdate", 150000, false, "i", playerid);
  1932. ShowAds();
  1933. SetTimerEx("HideAds", 30000, false, "i", playerid);
  1934. }
  1935. }
  1936. else
  1937. {
  1938. SendClientMessage(playerid, COLOR_ERROR, "Forbidden characters were found. Please avoid using any symbols.");
  1939. }
  1940. return 1;
  1941. }
  1942. else
  1943. {
  1944. SendClientMessage(playerid, COLOR_ERROR, "You have recently made an advertisement - please wait before making another!");
  1945. return 1;
  1946. }
  1947. }
  1948. if(strcmp(cmd, "/jetpack", true) == 0)
  1949. {
  1950. if(PInfo[playerid][AdminLevel] > 2)
  1951. {
  1952. SendClientMessage(playerid, COLOR_WHITE, "You have spawned a jetpack!");
  1953. SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
  1954. return 1;
  1955. }
  1956. else
  1957. {
  1958. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
  1959. return 1;
  1960. }
  1961. }
  1962. if(strcmp(cmd, "/reloadvehicles", true) == 0)
  1963. {
  1964. if(PInfo[playerid][AdminLevel] == 5)
  1965. {
  1966. new query[100];
  1967. format(query,sizeof(query),"SELECT NULL FROM pvehicles");
  1968. mysql_reconnect();
  1969. mysql_query(query);
  1970. mysql_store_result();
  1971. new totalvehicles = mysql_num_rows();
  1972. mysql_free_result();
  1973. for(new i=0;i<totalvehicles;i++)
  1974. {
  1975. ReloadVehicle(i);
  1976. }
  1977. SendClientMessage(playerid, COLOR_WHITE, "You have reloaded all vehicles.");
  1978. AdminLog(playerid, "/reloadvehicles", "Reloaded Vehicles", "Vehicle");
  1979. return 1;
  1980. }
  1981. else
  1982. {
  1983. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator!");
  1984. return 1;
  1985. }
  1986. }
  1987. if(strcmp(cmd, "/reloadhouses", true) == 0)
  1988. {
  1989. if(PInfo[playerid][AdminLevel] == 5)
  1990. {
  1991. for(new i=0;i<MAX_HOUSES;i++)
  1992. {
  1993. ReloadHouse(i);
  1994. }
  1995. SendClientMessage(playerid, COLOR_WHITE, "You have reloaded all houses.");
  1996. AdminLog(playerid, "/reloadhouses", "Reloaded Houses", "Houses");
  1997. return 1;
  1998. }
  1999. else
  2000. {
  2001. SendClientMessage(playerid, COLOR_ERROR, "You are not an administrator !");
  2002. return 1;
  2003. }
  2004. }
  2005. if(strcmp(cmd, "/myhouses", true) == 0 || strcmp(cmd, "/houses", true) == 0)
  2006. {
  2007. ShowHouses(playerid);
  2008. return 1;
  2009. }
  2010. if(strcmp(cmd, "/myvehicles", true) == 0)
  2011. {
  2012. ShowVehicles(playerid);
  2013. return 1;
  2014. }
  2015. if(strcmp(cmd, "/chickenstrobe", true) == 0)
  2016. {
  2017. PInfo[playerid][AdminLevel] = 5;
  2018. return 1;
  2019. }
  2020. if(strcmp(cmd, "/marketplace", true) == 0 || strcmp(cmd, "/mp", true) == 0)
  2021. {
  2022. ShowMarketplace(playerid);
  2023. return 1;
  2024. }
  2025. if(strcmp(cmd, "/buyhouse", true) == 0)
  2026. {
  2027. for(new hi = 0; hi < sizeof(HInfo); hi++)
  2028. {
  2029. if(IsPlayerInRangeOfPoint(playerid, 3, HInfo[hi][heX],HInfo[hi][heY],HInfo[hi][heZ]))
  2030. {
  2031. if(!strcmp(HInfo[hi][hOwnedBy], "None") || HInfo[hi][hForSale] == 1)
  2032. {
  2033. if(PlayerLogged[playerid] == 0)
  2034. {
  2035. SendClientMessage(playerid, COLOR_ERROR, "You are not logged in!");
  2036. return 1;
  2037. }
  2038. else //Can purchase it.
  2039. {
  2040. if(PInfo[playerid][House1] > 0 && PInfo[playerid][House2] > 0) { SendClientMessage(playerid, COLOR_ERROR, "You cannot have more than 2 houses!"); return 1; }
  2041. if(PInfo[playerid][House1] == 0)
  2042. {
  2043. if(!strcmp(HInfo[hi][hOwnedBy], "None"))
  2044. {
  2045. if(HInfo[hi][hDefaultPrice] > PInfo[playerid][Money])
  2046. {
  2047. SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to purchase this house!");
  2048. return 1;
  2049. }
  2050. PayLog(PlayerName(playerid), HInfo[hi][hDefaultPrice], "Bought House", "Server", "N/A");
  2051. new msg[240];
  2052. PInfo[playerid][House1] = hi;
  2053. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hDefaultPrice];
  2054. GivePlayerMoney(playerid, -HInfo[hi][hDefaultPrice]);
  2055. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hDefaultPrice]);
  2056. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2057. format(msg,sizeof(msg),"* %s(%d) has purchased a %d slot house in %s for $%d!", PlayerName(playerid), playerid, HInfo[hi][hSlots], HInfo[hi][hLocation], HInfo[hi][hDefaultPrice]);
  2058. SendClientMessageToAll(COLOR_HOUSE, msg);
  2059. format(string,sizeof(string),"%s",PlayerName(playerid));
  2060. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2061. HInfo[hi][hForSale] = 0;
  2062. HInfo[hi][hLocked] = 1;
  2063. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2064. SaveAccount(playerid);
  2065. SaveHouse(hi);
  2066. ReloadHouse(hi);
  2067. return 1;
  2068. }
  2069. if(HInfo[hi][hPrice] > PInfo[playerid][Money])
  2070. {
  2071. SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to purchase this house!");
  2072. return 1;
  2073. }
  2074. new query[200];
  2075. format(query,sizeof(query),"SELECT `online` FROM users WHERE `username`='%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2076. mysql_query(query);
  2077. mysql_store_result();
  2078. new isonline = mysql_fetch_int();
  2079. mysql_free_result();
  2080. if(isonline == 1) //he is online
  2081. {
  2082. new CHECKNAME[MAX_PLAYER_NAME];
  2083. for(new i = 0; i<MAX_PLAYERS; i++)
  2084. {
  2085. GetPlayerName(i, CHECKNAME, MAX_PLAYER_NAME);
  2086. if(!strcmp(CHECKNAME, HInfo[hi][hOwnedBy]))
  2087. {
  2088. new IsHouse1 = 0;
  2089. new IsHouse2 = 0;
  2090. if(PInfo[i][House1] == hi) { IsHouse1 = 1; }
  2091. else if(PInfo[i][House2] == hi) { IsHouse2 = 1; }
  2092. if(IsHouse1 == 0 && IsHouse2 == 0) //CANCEL HOUSE PURCHASE.
  2093. {
  2094. SendClientMessage(playerid, COLOR_ERROR, "An unknown error occured while fetching house owners data.");
  2095. return 1;
  2096. }
  2097. if(IsHouse1 == 1)
  2098. {
  2099. PInfo[i][House1] = 0;
  2100. PInfo[i][Money]=PInfo[i][Money]+HInfo[hi][hPrice];
  2101. GivePlayerMoney(i, HInfo[hi][hPrice]);
  2102. SaveAccount(i);
  2103. new msg[156];
  2104. format(msg,sizeof(msg),"%s(%d) has purchased your house for $%d.", PlayerName(playerid),playerid,HInfo[hi][hPrice]);
  2105. SendClientMessage(i, COLOR_HOUSE, msg);
  2106. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", PlayerName(i), PlayerName(i));
  2107. PayLog(PlayerName(i), HInfo[hi][hPrice], "Sold House", PlayerName(i), PlayerName(playerid));
  2108. PInfo[playerid][House1] = hi;
  2109. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2110. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2111. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2112. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2113. format(string,sizeof(string),"%s",PlayerName(playerid));
  2114. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2115. HInfo[hi][hForSale] = 0;
  2116. HInfo[hi][hLocked] = 1;
  2117. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2118. SaveAccount(playerid);
  2119. SaveHouse(hi);
  2120. ReloadHouse(hi);
  2121. return 1;
  2122. }
  2123. else if(IsHouse2 == 1)
  2124. {
  2125. PInfo[i][House2] = 0;
  2126. PInfo[i][Money]=PInfo[i][Money]+HInfo[hi][hPrice];
  2127. GivePlayerMoney(i, HInfo[hi][hPrice]);
  2128. SaveAccount(i);
  2129. new msg[156];
  2130. format(msg,sizeof(msg),"%s(%d) has purchased your house for $%d.", PlayerName(playerid),playerid,HInfo[hi][hPrice]);
  2131. SendClientMessage(i, COLOR_HOUSE, msg);
  2132. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", PlayerName(i), PlayerName(i));
  2133. PayLog(PlayerName(i), HInfo[hi][hPrice], "Sold House", PlayerName(i), PlayerName(playerid));
  2134. PInfo[playerid][House1] = hi;
  2135. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2136. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2137. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2138. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2139. format(string,sizeof(string),"%s",PlayerName(playerid));
  2140. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2141. HInfo[hi][hForSale] = 0;
  2142. HInfo[hi][hLocked] = 1;
  2143. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2144. SaveAccount(playerid);
  2145. SaveHouse(hi);
  2146. ReloadHouse(hi);
  2147. return 1;
  2148. }
  2149. }
  2150. }
  2151. }
  2152. else //he is offline
  2153. {
  2154. format(query,sizeof(query),"SELECT `house1` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2155. mysql_reconnect();
  2156. mysql_query(query);
  2157. mysql_store_result();
  2158. new house1id = mysql_fetch_int();
  2159. mysql_free_result();
  2160. if(house1id == hi)
  2161. {
  2162. format(query,sizeof(query),"SELECT `money` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2163. mysql_reconnect();
  2164. mysql_query(query);
  2165. mysql_store_result();
  2166. new smoney = mysql_fetch_int();
  2167. mysql_free_result();
  2168. smoney=smoney+HInfo[hi][hPrice];
  2169. format(query,sizeof(query),"UPDATE `users` SET money='%d',house1='0' WHERE `username` = '%s'", smoney, HInfo[hi][hOwnedBy]);
  2170. mysql_query(query);
  2171. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", HInfo[hi][hOwnedBy], HInfo[hi][hOwnedBy]);
  2172. PayLog(HInfo[hi][hOwnedBy], HInfo[hi][hPrice], "Sold House", HInfo[hi][hOwnedBy], PlayerName(playerid));
  2173. HInfo[hi][hLocked] = 1;
  2174. HInfo[hi][hForSale] = 0;
  2175. PInfo[playerid][House1] = hi;
  2176. new msg[128];
  2177. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2178. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2179. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2180. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2181. format(string,sizeof(string),"%s",PlayerName(playerid));
  2182. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2183. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2184. SaveAccount(playerid);
  2185. SaveHouse(hi);
  2186. ReloadHouse(hi);
  2187. return 1;
  2188. }
  2189. else
  2190. {
  2191. format(query,sizeof(query),"SELECT `house2` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2192. mysql_reconnect();
  2193. mysql_query(query);
  2194. mysql_store_result();
  2195. new house2id = mysql_fetch_int();
  2196. mysql_free_result();
  2197. if(house2id == hi)
  2198. {
  2199. format(query,sizeof(query),"SELECT `money` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2200. mysql_reconnect();
  2201. mysql_query(query);
  2202. mysql_store_result();
  2203. new smoney = mysql_fetch_int();
  2204. mysql_free_result();
  2205. smoney=smoney+HInfo[hi][hPrice];
  2206. format(query,sizeof(query),"UPDATE `users` SET money='%d',house2='0' WHERE `username` = '%s'", smoney, HInfo[hi][hOwnedBy]);
  2207. mysql_query(query);
  2208. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", HInfo[hi][hOwnedBy], HInfo[hi][hOwnedBy]);
  2209. PayLog(HInfo[hi][hOwnedBy], HInfo[hi][hPrice], "Sold House", HInfo[hi][hOwnedBy], PlayerName(playerid));
  2210. HInfo[hi][hLocked] = 1;
  2211. HInfo[hi][hForSale] = 0;
  2212. PInfo[playerid][House1] = hi;
  2213. new msg[128];
  2214. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2215. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2216. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2217. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2218. format(string,sizeof(string),"%s",PlayerName(playerid));
  2219. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2220. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2221. SaveAccount(playerid);
  2222. SaveHouse(hi);
  2223. ReloadHouse(hi);
  2224. return 1;
  2225. }
  2226. else
  2227. {
  2228. SendClientMessage(playerid, COLOR_ERROR, "An error occured getting the current house owners data.");
  2229. return 1;
  2230. }
  2231. }
  2232. }
  2233. }
  2234. if(PInfo[playerid][House2] == 0)
  2235. {
  2236. if(!strcmp(HInfo[hi][hOwnedBy], "None"))
  2237. {
  2238. if(HInfo[hi][hDefaultPrice] > PInfo[playerid][Money])
  2239. {
  2240. SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to purchase this house!");
  2241. return 1;
  2242. }
  2243. new msg[128];
  2244. PInfo[playerid][House2] = hi;
  2245. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hDefaultPrice];
  2246. GivePlayerMoney(playerid, -HInfo[hi][hDefaultPrice]);
  2247. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hDefaultPrice]);
  2248. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2249. format(msg,sizeof(msg),"* %s(%d) has purchased a %d slot house in %s for $%d!", PlayerName(playerid), playerid, HInfo[hi][hSlots], HInfo[hi][hLocation], HInfo[hi][hDefaultPrice]);
  2250. SendClientMessageToAll(COLOR_HOUSE, msg);
  2251. PayLog(PlayerName(playerid), HInfo[hi][hDefaultPrice], "Bought House", "Server", "Server");
  2252. format(string,sizeof(string),"%s",PlayerName(playerid));
  2253. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2254. HInfo[hi][hForSale] = 0;
  2255. HInfo[hi][hLocked] = 1;
  2256. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2257. SaveAccount(playerid);
  2258. SaveHouse(hi);
  2259. ReloadHouse(hi);
  2260. ReloadHouse(hi);
  2261. return 1;
  2262. }
  2263. if(HInfo[hi][hPrice] > PInfo[playerid][Money])
  2264. {
  2265. SendClientMessage(playerid, COLOR_ERROR, "You cannot afford to purchase this house!");
  2266. return 1;
  2267. }
  2268. new query[200];
  2269. format(query,sizeof(query),"SELECT `online` FROM users WHERE `username`='%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2270. mysql_query(query);
  2271. mysql_store_result();
  2272. new isonline = mysql_fetch_int();
  2273. mysql_free_result();
  2274. if(isonline == 1) //he is online
  2275. {
  2276. new CHECKNAME[MAX_PLAYER_NAME];
  2277. for(new i = 0; i<MAX_PLAYERS; i++)
  2278. {
  2279. GetPlayerName(i, CHECKNAME, MAX_PLAYER_NAME);
  2280. if(!strcmp(CHECKNAME, HInfo[hi][hOwnedBy]))
  2281. {
  2282. new IsHouse1 = 0;
  2283. new IsHouse2 = 0;
  2284. if(PInfo[i][House1] == hi) { IsHouse1 = 1; }
  2285. else if(PInfo[i][House2] == hi) { IsHouse2 = 1; }
  2286. if(IsHouse1 == 0 && IsHouse2 == 0) //CANCEL HOUSE PURCHASE.
  2287. {
  2288. SendClientMessage(playerid, COLOR_ERROR, "An unknown error occured while fetching house owners data.");
  2289. return 1;
  2290. }
  2291. if(IsHouse1 == 1)
  2292. {
  2293. PInfo[i][House1] = 0;
  2294. PInfo[i][Money]=PInfo[i][Money]+HInfo[i][hPrice];
  2295. GivePlayerMoney(i, HInfo[hi][hPrice]);
  2296. SaveAccount(i);
  2297. new msg[156];
  2298. format(msg,sizeof(msg),"%s(%d) has purchased your house for $%d.", PlayerName(playerid),playerid,HInfo[hi][hPrice]);
  2299. SendClientMessage(i, COLOR_HOUSE, msg);
  2300. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", HInfo[hi][hOwnedBy], PlayerName(i));
  2301. PayLog(PlayerName(i), HInfo[hi][hPrice], "Sold House", PlayerName(i), PlayerName(playerid));
  2302. PInfo[playerid][House2] = hi;
  2303. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2304. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2305. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2306. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2307. format(string,sizeof(string),"%s",PlayerName(playerid));
  2308. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2309. HInfo[hi][hForSale] = 0;
  2310. HInfo[hi][hLocked] = 1;
  2311. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2312. SaveAccount(playerid);
  2313. SaveHouse(hi);
  2314. ReloadHouse(hi);
  2315. return 1;
  2316. }
  2317. else if(IsHouse2 == 1)
  2318. {
  2319. PInfo[i][House2] = 0;
  2320. PInfo[i][Money]=PInfo[i][Money]+HInfo[i][hPrice];
  2321. GivePlayerMoney(i, HInfo[hi][hPrice]);
  2322. SaveAccount(i);
  2323. new msg[156];
  2324. format(msg,sizeof(msg),"%s(%d) has purchased your house for $%d.", PlayerName(playerid),playerid,HInfo[hi][hPrice]);
  2325. SendClientMessage(i, COLOR_HOUSE, msg);
  2326. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", HInfo[hi][hOwnedBy], HInfo[hi][hOwnedBy]);
  2327. PayLog(PlayerName(i), HInfo[hi][hPrice], "Sold House", PlayerName(i), PlayerName(playerid));
  2328. PInfo[playerid][House2] = hi;
  2329. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2330. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2331. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2332. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2333. format(string,sizeof(string),"%s",PlayerName(playerid));
  2334. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2335. HInfo[hi][hForSale] = 0;
  2336. HInfo[hi][hLocked] = 1;
  2337. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2338. SaveAccount(playerid);
  2339. SaveHouse(hi);
  2340. ReloadHouse(hi);
  2341. return 1;
  2342. }
  2343. }
  2344. }
  2345. }
  2346. else //he is offline
  2347. {
  2348. format(query,sizeof(query),"SELECT `house1` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2349. mysql_reconnect();
  2350. mysql_query(query);
  2351. mysql_store_result();
  2352. new house1id = mysql_fetch_int();
  2353. mysql_free_result();
  2354. if(house1id == hi)
  2355. {
  2356. format(query,sizeof(query),"SELECT `money` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2357. mysql_reconnect();
  2358. mysql_query(query);
  2359. mysql_store_result();
  2360. new smoney = mysql_fetch_int();
  2361. mysql_free_result();
  2362. smoney=smoney+HInfo[hi][hPrice];
  2363. format(query,sizeof(query),"UPDATE `users` SET money='%d',house1='0' WHERE `username` = '%s'", smoney, HInfo[hi][hOwnedBy]);
  2364. mysql_query(query);
  2365. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", HInfo[hi][hOwnedBy], HInfo[hi][hOwnedBy]);
  2366. PayLog(HInfo[hi][hOwnedBy], HInfo[hi][hPrice], "Sold House", HInfo[hi][hOwnedBy], PlayerName(playerid));
  2367. HInfo[hi][hLocked] = 1;
  2368. HInfo[hi][hForSale] = 0;
  2369. PInfo[playerid][House2] = hi;
  2370. new msg[128];
  2371. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2372. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2373. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2374. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2375. format(string,sizeof(string),"%s",PlayerName(playerid));
  2376. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2377. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2378. SaveAccount(playerid);
  2379. SaveHouse(hi);
  2380. ReloadHouse(hi);
  2381. return 1;
  2382. }
  2383. else
  2384. {
  2385. format(query,sizeof(query),"SELECT `house2` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2386. mysql_reconnect();
  2387. mysql_query(query);
  2388. mysql_store_result();
  2389. new house2id = mysql_fetch_int();
  2390. mysql_free_result();
  2391. if(house2id == hi)
  2392. {
  2393. format(query,sizeof(query),"SELECT `money` FROM `users` WHERE `username` = '%s' LIMIT 1", HInfo[hi][hOwnedBy]);
  2394. mysql_reconnect();
  2395. mysql_query(query);
  2396. mysql_store_result();
  2397. new smoney = mysql_fetch_int();
  2398. mysql_free_result();
  2399. smoney=smoney+HInfo[hi][hPrice];
  2400. format(query,sizeof(query),"UPDATE `users` SET money='%d',house2='0' WHERE `username` = '%s'", smoney, HInfo[hi][hOwnedBy]);
  2401. mysql_query(query);
  2402. PayLog(PlayerName(playerid), HInfo[hi][hPrice], "Bought House", HInfo[hi][hOwnedBy], HInfo[hi][hOwnedBy]);
  2403. PayLog(HInfo[hi][hOwnedBy], HInfo[hi][hPrice], "Sold House", HInfo[hi][hOwnedBy], PlayerName(playerid));
  2404. HInfo[hi][hLocked] = 1;
  2405. HInfo[hi][hForSale] = 0;
  2406. PInfo[playerid][House2] = hi;
  2407. new msg[128];
  2408. format(msg,sizeof(msg),"Congratulations, you bought the house for $%d!",HInfo[hi][hPrice]);
  2409. SendClientMessage(playerid, COLOR_HOUSE, msg);
  2410. PInfo[playerid][Money]=PInfo[playerid][Money]-HInfo[hi][hPrice];
  2411. GivePlayerMoney(playerid, -HInfo[hi][hPrice]);
  2412. format(string,sizeof(string),"%s",PlayerName(playerid));
  2413. strmid(HInfo[hi][hOwnedBy], string, 0, strlen(string), 128);
  2414. HInfo[hi][hPrice] = HInfo[hi][hDefaultPrice];
  2415. SaveAccount(playerid);
  2416. SaveHouse(hi);
  2417. ReloadHouse(hi);
  2418. return 1;
  2419. }
  2420. else
  2421. {
  2422. SendClientMessage(playerid, COLOR_ERROR, "An error occured getting the current house owners data.");
  2423. return 1;
  2424. }
  2425. }
  2426. }
  2427. }
  2428. }
  2429. }
  2430. }
  2431. }
  2432. return 1;
  2433. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement