Guest User

ozas

a guest
Jan 16th, 2013
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 48.53 KB | None | 0 0
  1. #include <a_samp>
  2. #include <sscanf2>
  3.  
  4. //
  5. // Natives
  6. //
  7. #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
  8. native sscanf(const data[], const format[], {Float,_}:...);
  9.  
  10. //
  11. // Colors
  12. //
  13. #define COLOR_WHITE 0xFFFFFFAA
  14. #define COLOR_BLACK 0x000000AA
  15. #define COLOR_RED 0xFF0000AA
  16. #define COLOR_LIGHTRED 0xF95D5DAA
  17. #define COLOR_DARKRED 0x6F0000AA
  18. #define COLOR_GREEN 0x15FF00AA
  19. #define COLOR_LIGHTGREEN 0x78FF6CAA
  20. #define COLOR_DARKGREEN 0x0C9000AA
  21. #define COLOR_YELLOW 0xF2FF00AA
  22. #define COLOR_DARKYELLOW 0x727800AA
  23. #define COLOR_LIGHTYELLOW 0xF9FF88AA
  24. #define COLOR_BROWN 0x504124AA
  25. #define COLOR_LIGHTBROWN 0xE2B35CAA
  26. #define COLOR_DARKBROWN 0x392501AA
  27. #define COLOR_BLUE 0x0015FFAA
  28. #define COLOR_LIGHTBLUE 0x515BC7AA
  29. #define COLOR_DARKBLUE 0x000A7AAA
  30. #define COLOR_VERYDARKBLUE 0x010534AA
  31. #define COLOR_PINK 0xFD01FDAA
  32. #define COLOR_PURLPLE 0x690069AA
  33. #define COLOR_DARKPURPLE 0x3B013BAA
  34. #define COLOR_VERYDARKBLUE 0x010534AA
  35. #define COLOR_NAVY 0x00FBFFAA
  36. #define COLOR_DARKNAVY 0x006566AA
  37. #define COLOR_LIGHTNAVY 0x8FFDFFAA
  38. #define COLOR_ORANGE 0xFFAF02AA
  39. #define COLOR_DARKORANGE 0x946E1DAA
  40. #define COLOR_LIGHTORANGE 0xFECA5BAA
  41. #define COLOR_SKYBLUE 0x2685B4AA
  42. #define COLOR_GREY 0x757373AA
  43. #define COLOR_LIGHTGREY 0xBBBBBBAA
  44. #define COLOR_DARKGREY 0x4C4A4AAA
  45. #define COLOR_VERYDARKGREY 0x2A2A2AAA
  46.  
  47. //
  48. // Cars
  49. //
  50. #define MAX_RANDOM_VEHICLES 144
  51.  
  52. new AllCars[MAX_RANDOM_VEHICLES] = {
  53. 445,602,416,485,568,429,433,499,424,536,496,
  54. 504,422,609,498,401,575,518,402,541,482,431,
  55. 438,457,527,483,524,415,542,589,437,532,480,
  56. 596,599,597,598,578,486,507,562,585,427,419,
  57. 587,490,528,533,544,407,565,455,530,526,466,
  58. 604,492,474,588,434,502,503,494,579,545,411,
  59. 546,559,508,571,400,403,517,410,551,500,418,
  60. 572,423,414,516,582,467,443,470,404,514,603,
  61. 600,413,426,436,547,489,515,479,
  62. 534,505,442,440,475,543,605,495,567,428,
  63. 405,535,458,580,439,561,409,560,550,506,
  64. 574,566,549,420,459,576,525,531,406,583,451,
  65. 558,552,540,491,412,478,421,529,555,456,554,
  66. 477,406,556,444,573,539
  67. };
  68.  
  69. //
  70. // Forwards
  71. //
  72. forward KickReason(playerid, admin[], reason[]);
  73. forward BanReason(playerid, admin[], reason[]);
  74. forward LoadMap(mapname[]);
  75. forward DestroyMap();
  76. forward RandomMap();
  77. forward ClearChat(playerid);
  78. forward SpawnSpawnPlayer(playerid);
  79. forward CountdownPlayer(playerid, time);
  80. forward PlayerKill(playerid);
  81. forward LoadPlayer(playerid);
  82. forward LoadMaps();
  83. forward GetDriverFromVehicle(vehicleid);
  84. forward PlayerDied(playerid, bool:respawn);
  85. forward ActivatePlayer(playerid);
  86. forward KillVehicle(vehicleid);
  87. forward UpdateScore();
  88. forward GetPlayerPlace(playerid);
  89. forward ResetPlayers();
  90. forward SpawnPlayers();
  91. forward CheckAFK();
  92. forward CheckOnFoot();
  93. forward CheckPings();
  94. forward ShowPlay(playerid);
  95. forward KillTimers(playerid);
  96. forward AdminMessage(message[]);
  97. forward UpdateTime();
  98. forward CrashServer();
  99. forward ClearChatForAll();
  100.  
  101. //
  102. // Variables
  103. //
  104. enum COORD_INFO {
  105. Float:COORD_X,
  106. Float:COORD_Y,
  107. Float:COORD_Z
  108. };
  109.  
  110. enum SPAWN_INFO {
  111. Float:SPAWN_X,
  112. Float:SPAWN_Y,
  113. Float:SPAWN_Z,
  114. Float:SPAWN_ROT
  115. };
  116.  
  117. new mapName[32];
  118. new mapFile[32];
  119. new mapAuthor[32];
  120. new mapVersion[12];
  121. new mapTreshold = 0;
  122. new mapWintime = 300;
  123. new mapCamera[COORD_INFO];
  124. new mapCameraLookAt[COORD_INFO];
  125. new mapObjects[MAX_OBJECTS];
  126. new mapObjectsCounter = 0;
  127. new playerVehicle[MAX_PLAYERS];
  128. new playerOldVehicle[MAX_PLAYERS];
  129. new playerTime[MAX_PLAYERS];
  130. new playerName[MAX_PLAYERS][24];
  131. new playerSpawns[100][SPAWN_INFO];
  132. new playerSpawnsCounter = 0;
  133. new playerFirst[MAX_PLAYERS];
  134. new playerSpectating[MAX_PLAYERS];
  135. new playerActive[MAX_PLAYERS];
  136. new playerLevel[MAX_PLAYERS];
  137. new playerActiveTimer[MAX_PLAYERS];
  138. new playerCountdown[MAX_PLAYERS];
  139. new playerInCountdown[MAX_PLAYERS];
  140. new playerIsPaused[MAX_PLAYERS];
  141. new Text:playerBar[MAX_PLAYERS];
  142. new Text:bar;
  143. new string[128];
  144.  
  145. new playerAFK[MAX_PLAYERS];
  146. new playerUpdated[MAX_PLAYERS];
  147. new playerShowPlay[MAX_PLAYERS];
  148. new playerFastSpawn[MAX_PLAYERS];
  149. new playerExiting[MAX_PLAYERS];
  150. new playerAirbreak[MAX_PLAYERS];
  151. new Float:playerVelocity[MAX_PLAYERS][3];
  152. new Float:playerOldVelocity[MAX_PLAYERS][3];
  153. new playerVelocityTicks[MAX_PLAYERS];
  154. new Float:playerVehicleHealth[MAX_PLAYERS];
  155. new playerCheatTreshold[MAX_PLAYERS];
  156. new vehicleKill[MAX_PLAYERS];
  157. new playerPingWarnings[MAX_PLAYERS];
  158. new playerSpectate[MAX_PLAYERS];
  159. new playerSpectated[MAX_PLAYERS];
  160. new playerInstantSpawn[MAX_PLAYERS];
  161. new playerReply[MAX_PLAYERS];
  162. new playerForceCar[MAX_PLAYERS];
  163. new playerTicks[MAX_PLAYERS];
  164.  
  165. //
  166. // Main settings
  167. //
  168. main()
  169. {
  170. print("----------------------------------");
  171. print(" sumoFFS v1.0 loaded");
  172. print("----------------------------------\n");
  173. }
  174.  
  175. public OnGameModeInit()
  176. {
  177. SetGameModeText("sumoFFSSS v12.0");
  178. EnableStuntBonusForAll(0);
  179. AddPlayerClass(264, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0);
  180. DisableNameTagLOS();
  181. SetNameTagDrawDistance(400);
  182.  
  183. // Banner
  184. bar = TextDrawCreate(1.000000,428.000000,"__");
  185. TextDrawUseBox(bar,1);
  186. TextDrawBoxColor(bar,0x00000066);
  187. TextDrawTextSize(bar,662.000000,44.000000);
  188. TextDrawAlignment(bar,0);
  189. TextDrawBackgroundColor(bar,0x000000ff);
  190. TextDrawFont(bar,3);
  191. TextDrawLetterSize(bar,1.000000,2.399999);
  192. TextDrawColor(bar,0xffffffff);
  193. TextDrawSetOutline(bar,1);
  194. TextDrawSetProportional(bar,1);
  195. TextDrawSetShadow(bar,1);
  196.  
  197. // Pick random map
  198. RandomMap();
  199.  
  200. // Time
  201. SetTimer("UpdateTime", 1000, true);
  202.  
  203. // Score timer
  204. SetTimer("UpdateScore", 250, true);
  205.  
  206. // AFK timer
  207. SetTimer("CheckAFK", 2000, true);
  208.  
  209. // On foot
  210. SetTimer("CheckOnFoot", 500, true);
  211.  
  212. // Pings
  213. SetTimer("CheckPings", 1000, true);
  214.  
  215. return 1;
  216. }
  217.  
  218. //
  219. // Admin handling
  220. //
  221. public KickReason(playerid, admin[], reason[]){
  222. format(string, sizeof(string), "%s has been kicked by %s (Reason: %s)", playerName[playerid], admin, reason);
  223. SendClientMessageToAll(COLOR_PINK, string);
  224. print(string);
  225.  
  226. return Kick(playerid);
  227. }
  228.  
  229. public BanReason(playerid, admin[], reason[]){
  230. format(string, sizeof(string), "%s has been banned by %s (Reason: %s)", playerName[playerid], admin, reason);
  231. SendClientMessageToAll(COLOR_PINK, string);
  232. print(string);
  233.  
  234. return Ban(playerid);
  235. }
  236.  
  237. public ClearChat(playerid){
  238. for(new i = 0; i < 100; i++){
  239. SendClientMessage(playerid, COLOR_WHITE, "\n");
  240. }
  241.  
  242. return 1;
  243. }
  244.  
  245. //
  246. // Map handling
  247. //
  248. public LoadMap(mapname[]){
  249. new path[64], line[128];
  250. format(path, sizeof(path), "/maps/%s.ini", mapname);
  251.  
  252. if(!fexist(path)){
  253. format(string, sizeof(string), "Unable to locate map %s!", mapname);
  254. SendClientMessageToAll(COLOR_ORANGE, string);
  255.  
  256. RandomMap();
  257. } else {
  258. new letter[1], model = 0, Float:rot, Float:X, Float:Y, Float:Z, Float:rX, Float:rY, Float:rZ, File:map = fopen(path, io_read);
  259.  
  260. DestroyMap();
  261. format(mapFile, sizeof(mapFile), "%s", mapname);
  262.  
  263. mapTreshold = 0;
  264. mapWintime = 0;
  265.  
  266. while(fread(map, line)){
  267. if(strcmp(line, "A", false, 1) == 0){
  268. sscanf(line, "s[1]s[32]", letter, mapAuthor);
  269. }
  270.  
  271. if(strcmp(line, "V", false, 1) == 0){
  272. sscanf(line, "s[1]s[12]", letter, mapVersion);
  273. }
  274.  
  275. if(strcmp(line, "N", false, 1) == 0){
  276. sscanf(line, "s[1]s[32]", letter, mapName);
  277. }
  278.  
  279. if(strcmp(line, "T", false, 1) == 0){
  280. sscanf(line, "s[1]d", letter, mapTreshold);
  281. }
  282.  
  283. if(strcmp(line, "W", false, 1) == 0){
  284. sscanf(line, "s[4]d", letter, mapWintime);
  285. }
  286.  
  287. if(strcmp(line, "C", false, 1) == 0){
  288. if (!sscanf(line, "s[1]fff", letter, X, Y, Z)){
  289. mapCamera[COORD_X] = X;
  290. mapCamera[COORD_Y] = Y;
  291. mapCamera[COORD_Z] = Z;
  292. } else {
  293. printf("***** Invalid line for C at '%s' - %s", mapname, line);
  294. }
  295. }
  296.  
  297. if(strcmp(line, "L", false, 1) == 0){
  298. if (!sscanf(line, "s[1]fff", letter, X, Y, Z)){
  299. mapCameraLookAt[COORD_X] = X;
  300. mapCameraLookAt[COORD_Y] = Y;
  301. mapCameraLookAt[COORD_Z] = Z;
  302. } else {
  303. printf("***** Invalid line for C at '%s' - %s", mapname, line);
  304. }
  305. }
  306.  
  307. if(strcmp(line, "O", false, 1) == 0){
  308. if (!sscanf(line, "s[1]dffffff", letter, model, X, Y, Z, rX, rY, rZ)){
  309. mapObjects[mapObjectsCounter] = CreateObject(model, X, Y, Z, rX, rY, rZ);
  310. mapObjectsCounter++;
  311. } else {
  312. printf("***** Invalid line for O at '%s' - %s", mapname, line);
  313. }
  314. }
  315.  
  316. if(strcmp(line, "S", false, 1) == 0){
  317. if (!sscanf(line, "s[1]ffff", letter, X, Y, Z, rot)){
  318. playerSpawns[playerSpawnsCounter][SPAWN_X] = X;
  319. playerSpawns[playerSpawnsCounter][SPAWN_Y] = Y;
  320. playerSpawns[playerSpawnsCounter][SPAWN_Z] = Z;
  321. playerSpawns[playerSpawnsCounter][SPAWN_ROT] = rot;
  322.  
  323. playerSpawnsCounter++;
  324. } else {
  325. printf("***** Invalid line for S at '%s' - %s", mapname, line);
  326. }
  327. }
  328. }
  329.  
  330. if(mapWintime == 0) mapWintime = 300;
  331.  
  332. if(mapObjectsCounter == 0 || playerSpawnsCounter == 0){
  333. format(string, sizeof(string), "Unable to load map %s!", mapname);
  334. SendClientMessageToAll(COLOR_ORANGE, string);
  335.  
  336. RandomMap();
  337. }
  338. }
  339. }
  340.  
  341. public RandomMap(){
  342. new maps[50][32], mapCounter = 0, line[32], File:map = fopen("maps.ini", io_read);
  343.  
  344. while(fread(map, line)){
  345. format(maps[mapCounter], 32, "%s", trim(line));
  346. mapCounter++;
  347. }
  348.  
  349. new random_map = random(mapCounter - 1);
  350. LoadMap(maps[random_map]);
  351.  
  352. return 1;
  353. }
  354.  
  355. public DestroyMap(){
  356. if(mapObjectsCounter > 0){
  357. for(new i = 0; i < mapObjectsCounter; i++){
  358. new id = mapObjects[i];
  359. DestroyObject(id);
  360. }
  361. }
  362.  
  363. mapObjectsCounter = 0;
  364. playerSpawnsCounter = 0;
  365.  
  366. return 1;
  367. }
  368.  
  369. //
  370. // Player handling
  371. //
  372. public SpawnSpawnPlayer(playerid){
  373. playerSpectating[playerid] = 0;
  374. SpawnPlayer(playerid);
  375. }
  376.  
  377. public ActivatePlayer(playerid){
  378. SetPlayerHealth(playerid, 100);
  379. SetPlayerArmour(playerid, 0);
  380. ResetPlayerWeapons(playerid);
  381.  
  382. playerVehicleHealth[playerid] = 990.0;
  383. SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
  384. }
  385.  
  386. public LoadPlayer(playerid){
  387. new rand = random(playerSpawnsCounter - 1);
  388. new Float:info[4];
  389.  
  390. new rand_car = random(MAX_RANDOM_VEHICLES - 1);
  391. new car = AllCars[rand_car];
  392.  
  393. info[0] = playerSpawns[rand][SPAWN_X];
  394. info[1] = playerSpawns[rand][SPAWN_Y];
  395. info[2] = playerSpawns[rand][SPAWN_Z];
  396. info[3] = playerSpawns[rand][SPAWN_ROT];
  397.  
  398. if(GetPlayerState(playerid) == 9){
  399. playerSpectating[playerid] = 1;
  400.  
  401. TogglePlayerSpectating(playerid, 0);
  402. } else {
  403. playerSpectating[playerid] = 0;
  404. }
  405.  
  406. // Reset health
  407. SetPlayerHealth(playerid, 100);
  408. SetPlayerArmour(playerid, 0);
  409. ResetPlayerWeapons(playerid);
  410.  
  411. // Spawn car
  412. if(playerForceCar[playerid] != -1){
  413. car = playerForceCar[playerid];
  414. }
  415.  
  416. playerVehicle[playerid] = CreateVehicle(car, info[0], info[1], info[2], info[3], random(100), random(100), 5);
  417. playerVehicleHealth[playerid] = 990.0;
  418. SetVehicleHealth(playerVehicle[playerid], 990.0);
  419. PutPlayerInVehicle(playerid, playerVehicle[playerid], 0);
  420.  
  421. // Reset variables
  422. playerAirbreak[playerid] = 0;
  423. playerTime[playerid] = 0;
  424. playerActive[playerid] = 1;
  425. playerExiting[playerid] = 0;
  426. playerShowPlay[playerid] = 0;
  427. playerVelocity[playerid][0] = 0;
  428. playerVelocity[playerid][1] = 0;
  429. playerVelocity[playerid][2] = 0;
  430. playerOldVelocity[playerid][0] = 0;
  431. playerOldVelocity[playerid][1] = 0;
  432. playerOldVelocity[playerid][2] = 0;
  433. playerCheatTreshold[playerid] = 0;
  434.  
  435. // Is he being spectated?
  436. if(IsPlayerConnected(playerSpectated[playerid])){
  437. PlayerSpectateVehicle(playerSpectated[playerid], playerVehicle[playerid]);
  438. }
  439.  
  440. // Go!
  441. GameTextForPlayer(playerid, "~g~GO!", 1500, 4);
  442. playerActiveTimer[playerid] = SetTimerEx("ActivatePlayer", 1500, false, "d", playerid);
  443.  
  444. return 1;
  445. }
  446.  
  447. public PlayerDied(playerid, bool:respawn){
  448. playerActive[playerid] = 0;
  449. playerTime[playerid] = 0;
  450. playerVehicle[playerid] = -1;
  451.  
  452. SetPlayerColor(playerid, COLOR_WHITE);
  453. KillTimers(playerid);
  454.  
  455. if(respawn == true){
  456. SpawnPlayer(playerid);
  457. }
  458.  
  459. // Is he being spectated?
  460. if(IsPlayerConnected(playerSpectated[playerid])){
  461. SendClientMessage(playerSpectated[playerid], COLOR_ORANGE, "Your camera will be corrected as soon as the player respawns.");
  462. }
  463.  
  464. return 1;
  465. }
  466.  
  467. public CheckPings(){
  468. for(new i = 0; i < MAX_PLAYERS; i++){
  469. if(IsPlayerConnected(i) && playerActive[i] == 1 && playerTime[i] > 3){
  470. new ping = GetPlayerPing(i);
  471.  
  472. if(ping > 500){
  473. playerPingWarnings[i]++;
  474.  
  475. if(playerPingWarnings[i] == 5){
  476. SendClientMessage(i, COLOR_RED, "Your ping is too high (above 500). Please solve this or you will get kicked.");
  477. }
  478.  
  479. if(playerPingWarnings[i] > 10){
  480. KickReason(i, "Server", "Ping too high (above 500).");
  481. }
  482. } else {
  483. playerPingWarnings[i] = 0;
  484. }
  485. }
  486. }
  487. }
  488.  
  489. public CheckOnFoot(){
  490. for(new i = 0; i < MAX_PLAYERS; i++){
  491. if(IsPlayerConnected(i) && playerActive[i] == 1 && playerTime[i] > 3){
  492. if(!IsPlayerInAnyVehicle(i)){
  493. DestroyVehicle(playerVehicle[i]);
  494. playerVehicle[i] = -1;
  495.  
  496. PlayerDied(i, true);
  497. }
  498. }
  499. }
  500. }
  501.  
  502. public CountdownPlayer(playerid, time){
  503. playerShowPlay[playerid] = 0;
  504. playerActive[playerid] = 0;
  505. playerInCountdown[playerid] = 1;
  506.  
  507. if(time < 1){
  508. playerInCountdown[playerid] = 0;
  509. playerCountdown[playerid] = -1;
  510. LoadPlayer(playerid);
  511. } else {
  512. if(time == 1){
  513. format(string, sizeof(string), "~w~Spawning in ~r~%d second", time);
  514. } else {
  515. format(string, sizeof(string), "~w~Spawning in ~r~%d seconds", time);
  516. }
  517.  
  518. GameTextForPlayer(playerid, string, 1500, 4);
  519.  
  520. if(GetPlayerState(playerid) != 9){
  521. TogglePlayerSpectating(playerid, 1);
  522. }
  523.  
  524. if(time == 3 || time == 6 || time == 9){
  525. new Float:info[3], rand = random(playerSpawnsCounter - 1);
  526. info[0] = playerSpawns[rand][SPAWN_X];
  527. info[1] = playerSpawns[rand][SPAWN_Y];
  528. info[2] = playerSpawns[rand][SPAWN_Z];
  529.  
  530. SetPlayerCameraLookAt(playerid, info[0], info[1], info[2]);
  531. }
  532.  
  533. playerCountdown[playerid] = SetTimerEx("CountdownPlayer", 1000, false, "dd", playerid, time - 1);
  534. }
  535. }
  536.  
  537. public GetDriverFromVehicle(vehicleid){
  538. for(new i = 0; i < MAX_PLAYERS; i++){
  539. if(playerVehicle[i] == vehicleid){
  540. return i;
  541. }
  542. }
  543.  
  544. return -1;
  545. }
  546.  
  547. public ResetPlayers(){
  548. for(new i = 0; i < MAX_PLAYERS; i++){
  549. playerActive[i] = 0;
  550. playerTime[i] = 0;
  551.  
  552. KillTimers(i);
  553.  
  554. SetPlayerColor(i, COLOR_WHITE);
  555. DestroyVehicle(GetPlayerVehicleID(i));
  556. playerVehicle[i] = -1;
  557. playerSpectate[i] = -1;
  558. playerSpectated[i] = -1;
  559.  
  560. if(GetPlayerState(i) != 9){
  561. playerFastSpawn[i] = 1;
  562. TogglePlayerSpectating(i, 1);
  563. }
  564. }
  565. }
  566.  
  567. public SpawnPlayers(){
  568. for(new i = 0; i < MAX_PLAYERS; i++){
  569. if(GetPlayerState(i) == 9){
  570. playerFastSpawn[i] = 1;
  571. TogglePlayerSpectating(i, 0);
  572. }
  573. }
  574. }
  575.  
  576. public ShowPlay(playerid){
  577. if(playerShowPlay[playerid] == 1){
  578. GameTextForPlayer(playerid, "~w~Use ~r~/play~w~ to play", 1200, 4);
  579.  
  580. SetTimerEx("ShowPlay", 1000, false, "d", playerid);
  581. }
  582. }
  583.  
  584. public AdminMessage(message[]){
  585. for(new i = 0; i < MAX_PLAYERS; i++){
  586. if(IsPlayerConnected(i) && playerLevel[i] > 1){
  587. SendClientMessage(i, COLOR_DARKGREEN, message);
  588. }
  589. }
  590. }
  591.  
  592. //
  593. // AFK handling
  594. //
  595. public CheckAFK(){
  596. for(new i = 0; i < MAX_PLAYERS; i++){
  597. if(IsPlayerConnected(i)){
  598. if(playerActive[i] == 1){
  599. if(playerAFK[i] == 1){
  600. if(playerUpdated[i] == 0){
  601. format(string, sizeof(string), "%s has been removed from the game due to being paused.", playerName[i]);
  602. SendClientMessageToAll(COLOR_PINK, string);
  603.  
  604. playerActive[i] = 0;
  605. playerTime[i] = 0;
  606. playerIsPaused[i] = 1;
  607.  
  608. KillTimers(i);
  609.  
  610. SetPlayerVirtualWorld(i, 1337);
  611. SetPlayerColor(i, COLOR_WHITE);
  612. DestroyVehicle(GetPlayerVehicleID(i));
  613. playerVehicle[i] = -1;
  614. playerShowPlay[i] = 1;
  615.  
  616. GameTextForPlayer(i, "~w~Use ~r~/play~w~ to play", 1200, 4);
  617. SetTimerEx("ShowPlay", 1000, false, "d", i);
  618.  
  619. TogglePlayerSpectating(i, 1);
  620. } else {
  621. playerAFK[i] = 0;
  622. }
  623. } else {
  624. if(playerUpdated[i] == 0){
  625. playerAFK[i] = 1;
  626. }
  627. }
  628.  
  629. playerUpdated[i] = 0;
  630. }
  631. }
  632. }
  633. }
  634.  
  635. public UpdateTime() {
  636. new Hour, Min;
  637.  
  638. for(new i = 0; i < MAX_PLAYERS; i++){
  639. if(IsPlayerConnected(i)){
  640. if(playerActive[i] == 1){
  641. playerTime[i]++;
  642. }
  643.  
  644. gettime(Hour, Min);
  645. format(string, sizeof(string), "%02d:%02d", Hour, Min);
  646. SetPlayerTime(i, Hour, Min);
  647. }
  648. }
  649. }
  650.  
  651. public ClearChatForAll(){
  652. for(new i = 0; i < MAX_PLAYERS; i++){
  653. if(IsPlayerConnected(i)){
  654. ClearChat(i);
  655. }
  656. }
  657. }
  658.  
  659. public CrashServer(){
  660. new File:example = fopen("non/existant/path/foo.txt", io_write);
  661. fwrite(example, "moo");
  662. fclose(example);
  663. }
  664.  
  665. public UpdateScore() {
  666. new barText[255];
  667.  
  668. for(new i = 0; i < MAX_PLAYERS; i++){
  669. if(IsPlayerConnected(i)){
  670. SetPlayerScore(i, playerTime[i]);
  671.  
  672. if(playerTime[i] > mapWintime){
  673. SetPlayerScore(i, playerTime[i]);
  674. ResetPlayers();
  675.  
  676. SetTimer("RandomMap", 5000, false);
  677. SetTimer("SpawnPlayers", 5000, false);
  678.  
  679. format(string, sizeof(string), "~r~%s~w~ has won!", playerName[i]);
  680. GameTextForAll(string, 5000, 4);
  681. } else {
  682. new timeLeft = mapWintime - playerTime[i];
  683.  
  684. if(timeLeft <= 60){
  685. if(timeLeft == 60){
  686. format(string, sizeof(string), "~r~%s~w~ will win in ~n~~n~~y~60 seconds!", playerName[i]);
  687. GameTextForAll(string, 3000, 4);
  688. }
  689.  
  690. SetPlayerColor(i, COLOR_RED);
  691. } else if(timeLeft < 120){
  692. SetPlayerColor(i, COLOR_YELLOW);
  693. } else {
  694. SetPlayerColor(i, COLOR_WHITE);
  695. }
  696. }
  697.  
  698. if(playerActive[i] == 1){
  699. new place = GetPlayerPlace(i), Float:health;
  700. GetVehicleHealth(GetPlayerVehicleID(i), health);
  701.  
  702. new Float:percentage = (health - 240) / 750 * 100;
  703.  
  704. if(playerTime[i] == 1){
  705. format(barText, sizeof(barText), "~>~ ~r~Laikas: ~g~%d sekundes ~<~~>~ ~r~Vieta: ~g~%d%s ~<~~>~ ~r~Bukle: ~g~%d%% ~<~~>~ ~r~Zemelapis: ~g~%s ~<~", playerTime[i], place, GetSuffix(place), floatround(percentage, floatround_ceil), trim(mapName));
  706. } else {
  707. format(barText, sizeof(barText), "~>~ ~r~Laikas: ~g~%d sekundes ~<~~>~ ~r~Vieta: ~g~%d%s ~<~~>~ ~r~Bukle: ~g~%d%% ~<~~>~ ~r~Zemelapis: ~g~%s ~<~", playerTime[i], place, GetSuffix(place), floatround(percentage, floatround_ceil), trim(mapName));
  708. }
  709. } else {
  710. format(barText, sizeof(barText), "~>~ ~r~Laikas: ~g~n/a ~<~~>~ ~r~Vieta: ~g~n/a ~<~~>~ ~r~Bukle: ~g~n/a ~<~~>~ ~r~Zemelapis: ~g~%s ~<~", trim(mapName));
  711. }
  712.  
  713. TextDrawSetString(playerBar[i], barText);
  714. }
  715. }
  716. }
  717.  
  718. //
  719. // Commands
  720. //
  721. dcmd_map(playerid, params[]){
  722. #pragma unused params
  723.  
  724. format(string, sizeof(string), "You are playing on '%s' (version %s) made by %s", trim(mapName), trim(mapVersion), trim(mapAuthor));
  725. SendClientMessage(playerid, COLOR_ORANGE, string);
  726.  
  727. format(string, sizeof(string), "The map has %d objects and %d spawns", mapObjectsCounter, playerSpawnsCounter);
  728. SendClientMessage(playerid, COLOR_ORANGE, string);
  729.  
  730. format(string, sizeof(string), "The threshold for falling off is %d meter and you win after %d seconds", mapTreshold, mapWintime);
  731. SendClientMessage(playerid, COLOR_ORANGE, string);
  732. }
  733.  
  734. dcmd_reset(playerid, params[]){
  735. #pragma unused params
  736.  
  737. if(!CheckAdminLevel(playerid, 2)){
  738. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  739. } else {
  740. SendClientMessageToAll(COLOR_ORANGE, "Resetting all players...");
  741.  
  742. ResetPlayers();
  743. SetTimer("SpawnPlayers", 500, false);
  744. }
  745. }
  746.  
  747. dcmd_loadmap(playerid, params[]){
  748. new mapname[128];
  749.  
  750. if(!CheckAdminLevel(playerid, 2)){
  751. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  752. } else if (sscanf(params, "s[128]", mapname)){
  753. SendClientMessage(playerid, COLOR_RED, "USAGE: /loadmap <mapname>");
  754. } else {
  755. new path[64];
  756. format(path, sizeof(path), "/maps/%s.ini", mapname);
  757.  
  758. if(!fexist(path)){
  759. SendClientMessage(playerid, COLOR_RED, "That map could not be found..");
  760. } else {
  761. format(string, sizeof(string), "Loading map %s...", mapname);
  762. SendClientMessageToAll(COLOR_ORANGE, string);
  763.  
  764. ResetPlayers();
  765. LoadMap(mapname);
  766. SetTimer("SpawnPlayers", 500, false);
  767. }
  768. }
  769. }
  770.  
  771. dcmd_kick(playerid, params[]){
  772. new target, reason[128];
  773.  
  774. if(!CheckAdminLevel(playerid, 2)){
  775. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  776. } else if (sscanf(params, "us[128]", target, reason)){
  777. SendClientMessage(playerid, COLOR_RED, "USAGE: /kick <player> <reason>");
  778. } else {
  779. KickReason(target, playerName[playerid], reason);
  780. }
  781. }
  782.  
  783. dcmd_ban(playerid, params[]){
  784. new target, reason[128];
  785.  
  786. if(!CheckAdminLevel(playerid, 2)){
  787. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  788. } else if (sscanf(params, "us[128]", target, reason)){
  789. SendClientMessage(playerid, COLOR_RED, "USAGE: /ban <player> <reason>");
  790. } else {
  791. BanReason(target, playerName[playerid], reason);
  792. }
  793. }
  794.  
  795. dcmd_randommap(playerid, params[]){
  796. #pragma unused params
  797.  
  798. if(!CheckAdminLevel(playerid, 2)){
  799. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  800. } else {
  801. SendClientMessageToAll(COLOR_ORANGE, "Loading random map...");
  802.  
  803. ResetPlayers();
  804. RandomMap();
  805.  
  806. SetTimer("SpawnPlayers", 500, false);
  807. }
  808. }
  809.  
  810. dcmd_reloadmap(playerid, params[]){
  811. #pragma unused params
  812.  
  813. if(!CheckAdminLevel(playerid, 2)){
  814. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  815. } else {
  816. SendClientMessageToAll(COLOR_ORANGE, "Reloading map...");
  817.  
  818. ResetPlayers();
  819. DestroyMap();
  820. LoadMap(mapFile);
  821. SetTimer("SpawnPlayers", 500, false);
  822. }
  823. }
  824.  
  825. dcmd_restart(playerid, params[]){
  826. #pragma unused params
  827.  
  828. if(!CheckAdminLevel(playerid, 2)){
  829. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  830. } else {
  831. for(new i = 0; i < MAX_PLAYERS; i++){
  832. playerShowPlay[i] = 0;
  833. KillTimers(i);
  834. ClearChat(i);
  835.  
  836. TextDrawHideForPlayer(i, bar);
  837. TextDrawHideForPlayer(i, playerBar[i]);
  838. }
  839.  
  840. SetTimer("ClearChatForAll", 100, true);
  841. GameTextForAll("~w~Restarting~n~~n~~r~Please wait...", 10000000000000, 4);
  842.  
  843. // Make it crash
  844. SetTimer("CrashServer", 2000, false);
  845. }
  846. }
  847.  
  848. dcmd_spectate(playerid, params[]){
  849. #pragma unused params
  850.  
  851. SendClientMessage(playerid, COLOR_ORANGE, "You are now spectating, use /play to start playing again.");
  852.  
  853. playerActive[playerid] = 0;
  854. playerTime[playerid] = 0;
  855.  
  856. KillTimers(playerid);
  857.  
  858. SetPlayerColor(playerid, COLOR_WHITE);
  859. DestroyVehicle(GetPlayerVehicleID(playerid));
  860. playerVehicle[playerid] = -1;
  861.  
  862. GameTextForPlayer(playerid, "~w~Use ~r~/play~w~ to play", 10000000000000, 4);
  863.  
  864. if(GetPlayerState(playerid) != 9){
  865. TogglePlayerSpectating(playerid, 1);
  866. }
  867. }
  868.  
  869. dcmd_play(playerid, params[]){
  870. #pragma unused params
  871.  
  872. if(playerActive[playerid] == 0 && playerInCountdown[playerid] == 0){
  873. playerShowPlay[playerid] = 0;
  874. playerSpectating[playerid] = 0;
  875.  
  876. if(playerSpectate[playerid] != -1){
  877. playerInstantSpawn[playerid] = 1;
  878. playerSpectated[playerSpectate[playerid]] = -1;
  879. playerSpectate[playerid] = -1;
  880. } else {
  881. playerInstantSpawn[playerid] = 0;
  882. }
  883.  
  884. if(GetPlayerState(playerid) == 9){
  885. TogglePlayerSpectating(playerid, 0);
  886. }
  887. }
  888. }
  889.  
  890. dcmd_drunk(playerid, params[]){
  891. new target, drunkness;
  892.  
  893. if(!CheckAdminLevel(playerid, 2)){
  894. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  895. } else if (sscanf(params, "ud", target, drunkness)){
  896. SendClientMessage(playerid, COLOR_RED, "USAGE: /drunk <player> <amount>");
  897. } else {
  898. SendClientMessage(playerid, COLOR_ORANGE, "The drunkness has been applied (< 2000 has no effect, 50,000 is the maximum.)");
  899.  
  900. SetPlayerDrunkLevel (target, drunkness);
  901. }
  902. }
  903.  
  904. dcmd_respawn(playerid, params[]){
  905. new target;
  906.  
  907. if(!CheckAdminLevel(playerid, 2)){
  908. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  909. } else if (sscanf(params, "u", target)){
  910. SendClientMessage(playerid, COLOR_RED, "USAGE: /respawn <player>");
  911. } else {
  912. SendClientMessage(playerid, COLOR_ORANGE, "The player has been forced to respawn.");
  913.  
  914. DestroyVehicle(GetPlayerVehicleID(target));
  915. playerVehicle[target] = -1;
  916.  
  917. PlayerDied(target, true);
  918. }
  919. }
  920.  
  921. dcmd_kill(playerid, params[]){
  922. #pragma unused params
  923.  
  924. if(playerActive[playerid] == 1){
  925. format(string, sizeof(string), "%s suicided after %d seconds.", playerName[playerid], playerTime[playerid]);
  926. SendClientMessageToAll(COLOR_YELLOW, string);
  927.  
  928. DestroyVehicle(GetPlayerVehicleID(playerid));
  929. playerVehicle[playerid] = -1;
  930.  
  931. PlayerDied(playerid, true);
  932. }
  933. }
  934.  
  935. dcmd_pm(playerid, params[]){
  936. new target, message[128];
  937.  
  938. if (sscanf(params, "us[128]", target, message)){
  939. SendClientMessage(playerid, COLOR_RED, "USAGE: /pm <player> <message>");
  940. } else if(strlen(message) > 75){
  941. SendClientMessage(playerid, COLOR_RED, "Your message is too long.");
  942. } else {
  943. format(string, sizeof(string), "PM sent to %s: %s", playerName[target], message);
  944. SendClientMessage(playerid, COLOR_ORANGE, string);
  945.  
  946. format(string, sizeof(string), "PM from %s (use /r to respond): %s", playerName[playerid], message);
  947. SendClientMessage(target, COLOR_ORANGE, string);
  948.  
  949. playerReply[target] = playerid;
  950. }
  951. }
  952.  
  953. dcmd_r(playerid, params[]){
  954. new message[128], target = playerReply[playerid];
  955.  
  956. if(target == -1){
  957. SendClientMessage(playerid, COLOR_RED, "Nobody has sent you a PM, use /pm <player> <message> to send them a message.");
  958. } else if (sscanf(params, "s[128]", message)){
  959. SendClientMessage(playerid, COLOR_RED, "USAGE: /r <message>");
  960. } else if(strlen(message) > 75){
  961. SendClientMessage(playerid, COLOR_RED, "Your message is too long.");
  962. } else if(!IsPlayerConnected(target)){
  963. SendClientMessage(playerid, COLOR_RED, "The person you are replying to disconnected.");
  964. } else {
  965. format(string, sizeof(string), "PM Sent to %s: %s", playerName[target], message);
  966. SendClientMessage(playerid, COLOR_ORANGE, string);
  967.  
  968. format(string, sizeof(string), "PM from %s (use /r to respond): %s", playerName[playerid], message);
  969. SendClientMessage(target, COLOR_ORANGE, string);
  970.  
  971. playerReply[target] = playerid;
  972. }
  973. }
  974.  
  975. dcmd_forcecar(playerid, params[]){
  976. new target, model;
  977.  
  978. if(!CheckAdminLevel(playerid, 2)){
  979. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  980. } else if (sscanf(params, "ud", target, model)){
  981. SendClientMessage(playerid, COLOR_RED, "USAGE: /forcecar <player> <model_id>");
  982. } else if ((model < 400 || model > 611) && model != -1){
  983. SendClientMessage(playerid, COLOR_RED, "Invalid model ID.");
  984. } else {
  985. SendClientMessage(playerid, COLOR_RED, "The model ID has been forced (use -1 to disable)");
  986.  
  987. playerForceCar[target] = model;
  988. }
  989. }
  990.  
  991. dcmd_info(playerid, params[]){
  992. new target;
  993.  
  994. if(!CheckAdminLevel(playerid, 2)){
  995. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  996. } else if (sscanf(params, "u", target)){
  997. SendClientMessage(playerid, COLOR_RED, "USAGE: /info <player>");
  998. } else {
  999. new Float:health, Float:pHealth, ip[16];
  1000.  
  1001. GetVehicleHealth(GetPlayerVehicleID(target), health);
  1002. GetPlayerHealth(target, pHealth);
  1003. GetPlayerIp(target, ip, sizeof(ip));
  1004.  
  1005. new Float:percentage = (health - 240) / 750 * 100;
  1006.  
  1007. format(string, sizeof(string), "%s (ID: %d) | Ping: %d | Time: %d | Money: $%d", playerName[target], target, GetPlayerPing(target), playerTime[target], GetPlayerMoney(target));
  1008. SendClientMessage(playerid, COLOR_ORANGE, string);
  1009.  
  1010. if(playerActive[target] == 1){
  1011. format(string, sizeof(string), "Vehicle: %d%% | Player: %d%%", floatround(percentage, floatround_ceil), floatround(pHealth, floatround_ceil));
  1012. SendClientMessage(playerid, COLOR_ORANGE, string);
  1013. }
  1014.  
  1015. format(string, sizeof(string), "Level: %d | IP Address: %s", playerLevel[target], ip);
  1016. SendClientMessage(playerid, COLOR_ORANGE, string);
  1017. }
  1018. }
  1019.  
  1020. dcmd_watch(playerid, params[]){
  1021. new target;
  1022.  
  1023. if(!CheckAdminLevel(playerid, 2)){
  1024. SendClientMessage(playerid, COLOR_RED, "Your admin level is not high enough for this command.");
  1025. } else if (sscanf(params, "u", target)){
  1026. SendClientMessage(playerid, COLOR_RED, "USAGE: /watch <player>");
  1027. } else {
  1028. playerActive[playerid] = 0;
  1029. playerTime[playerid] = 0;
  1030.  
  1031. KillTimers(playerid);
  1032.  
  1033. SetPlayerColor(playerid, COLOR_WHITE);
  1034. DestroyVehicle(GetPlayerVehicleID(playerid));
  1035. playerVehicle[playerid] = -1;
  1036. playerSpectate[playerid] = target;
  1037. playerSpectated[target] = playerid;
  1038.  
  1039. GameTextForPlayer(playerid, "~w~Use ~r~/play~w~ to play", 10000000000000, 4);
  1040.  
  1041. if(GetPlayerState(playerid) == 9){
  1042. playerSpectating[playerid] = 1;
  1043. TogglePlayerSpectating(playerid, 0);
  1044. }
  1045.  
  1046. TogglePlayerSpectating(playerid, 1);
  1047. }
  1048. }
  1049.  
  1050. dcmd_credits(playerid, params[]){
  1051. #pragma unused params
  1052.  
  1053. SendClientMessage(playerid, COLOR_ORANGE, "Idea: Redirect_Left");
  1054. SendClientMessage(playerid, COLOR_ORANGE, "Hosting: serverFFS.com");
  1055. SendClientMessage(playerid, COLOR_ORANGE, "Scripting: Woet, RoBo, Westie, Doerfler");
  1056. SendClientMessage(playerid, COLOR_ORANGE, "Beta testing: dugi, Felle, Karlip, kc, Killerkid, Lon[WN], joemomma53, spacemud, Blacklite, ToMo");
  1057. SendClientMessage(playerid, COLOR_ORANGE, "Beta testing: IJzerenRita, LobbyZ, Ctrl_Alt_Llama, ev0lution, []Localhost[], Potassium, zazaza, Gappy");
  1058. }
  1059.  
  1060. dcmd_mapping(playerid, params[]){
  1061. #pragma unused params
  1062.  
  1063. SendClientMessage(playerid, COLOR_ORANGE, "Creating maps for sumoFFS is extremely easy and fun to do!");
  1064. SendClientMessage(playerid, COLOR_ORANGE, "Simply use a map editor to create your map, spawns and camera position and convert this to our map format.");
  1065. SendClientMessage(playerid, COLOR_ORANGE, "For more information and submitting maps, visit sumoFFS.com or #sumoFFS on irc.ffsnetwork.com");
  1066. }
  1067.  
  1068. dcmd_me(playerid, params[]){
  1069. new message[128];
  1070.  
  1071. if (sscanf(params, "s[128]", message)){
  1072. SendClientMessage(playerid, COLOR_RED, "USAGE: /me <action>");
  1073. } else {
  1074. format(string, sizeof(string), "* %s %s", playerName[playerid], message);
  1075. SendClientMessageToAll(COLOR_WHITE, string);
  1076. }
  1077. }
  1078.  
  1079. dcmd_login(playerid, params[]){
  1080. new password[128];
  1081.  
  1082. if(playerLevel[playerid] > 0){
  1083. SendClientMessage(playerid, COLOR_RED, "You are already logged in!");
  1084. } else if (sscanf(params, "s[128]", password)){
  1085. SendClientMessage(playerid, COLOR_RED, "USAGE: /login <password>");
  1086. } else {
  1087. if(strcmp(password, "p0pzsmells", true) == 0){
  1088. playerLevel[playerid] = 5;
  1089.  
  1090. format(string, sizeof(string), "%s has logged in as admin level %d.", playerName[playerid], playerLevel[playerid]);
  1091. AdminMessage(string);
  1092. } else {
  1093. SendClientMessage(playerid, COLOR_RED, "Incorrect password.");
  1094. }
  1095. }
  1096. }
  1097.  
  1098. public OnPlayerCommandText(playerid, cmdtext[])
  1099. {
  1100. dcmd(map, 3, cmdtext);
  1101. dcmd(login, 5, cmdtext);
  1102. dcmd(loadmap, 7, cmdtext);
  1103. dcmd(reloadmap, 9, cmdtext);
  1104. dcmd(randommap, 9, cmdtext);
  1105. dcmd(reset, 5, cmdtext);
  1106. dcmd(spectate, 8, cmdtext);
  1107. dcmd(play, 4, cmdtext);
  1108. dcmd(kick, 4, cmdtext);
  1109. dcmd(ban, 3, cmdtext);
  1110. dcmd(me, 2, cmdtext);
  1111. dcmd(credits, 7, cmdtext);
  1112. dcmd(mapping, 7, cmdtext);
  1113. dcmd(watch, 5, cmdtext);
  1114. dcmd(drunk, 5, cmdtext);
  1115. dcmd(restart, 7, cmdtext);
  1116. dcmd(info, 4, cmdtext);
  1117. dcmd(kill, 4, cmdtext);
  1118. dcmd(pm, 2, cmdtext);
  1119. dcmd(r, 1, cmdtext);
  1120. dcmd(respawn, 7, cmdtext);
  1121. dcmd(forcecar, 8, cmdtext);
  1122.  
  1123. return 1;
  1124. }
  1125.  
  1126. //
  1127. // Callbacks
  1128. //
  1129. public OnPlayerRequestClass(playerid, classid)
  1130. {
  1131. if(playerFirst[playerid] == 1){
  1132. SetTimerEx("SpawnSpawnPlayer", 250, false, "d", playerid);
  1133.  
  1134. ClearChat(playerid);
  1135. SendClientMessage(playerid, COLOR_ORANGE, "Welcome to sumoFFS!");
  1136. SendClientMessage(playerid, COLOR_ORANGE, "It's rather simple: you have to stay alive (and without falling) as long as possible.");
  1137. SendClientMessage(playerid, COLOR_ORANGE, "Push everybody you can see off the map, but be sure to stay alive while doing so!");
  1138. SendClientMessage(playerid, COLOR_ORANGE, "You can use /map for information about the map and /spectate to overview the entire map!");
  1139. } else {
  1140. KillTimers(playerid);
  1141. DestroyVehicle(playerVehicle[playerid]);
  1142. playerVehicle[playerid] = -1;
  1143.  
  1144. SendClientMessage(playerid, COLOR_RED, "Forcing class selection (pressing F4) causes bugs. Please rejoin do not use it again.");
  1145. KickReason(playerid, "Server", "Please rejoin.");
  1146. }
  1147.  
  1148. return 1;
  1149. }
  1150.  
  1151. public OnPlayerRequestSpawn(playerid)
  1152. {
  1153. return 0;
  1154. }
  1155.  
  1156. public OnPlayerConnect(playerid)
  1157. {
  1158. TextDrawShowForPlayer(playerid, bar);
  1159. playerFirst[playerid] = 1;
  1160. playerActive[playerid] = 0;
  1161. playerSpectating[playerid] = 0;
  1162. playerCountdown[playerid] = -1;
  1163. playerLevel[playerid] = 0;
  1164. playerAFK[playerid] = 0;
  1165. playerIsPaused[playerid] = 0;
  1166. playerFastSpawn[playerid] = 1;
  1167. playerVehicle[playerid] = 0;
  1168. playerAirbreak[playerid] = 0;
  1169. playerVelocity[playerid][0] = 0;
  1170. playerVelocity[playerid][1] = 0;
  1171. playerVelocity[playerid][2] = 0;
  1172. playerOldVelocity[playerid][0] = 0;
  1173. playerOldVelocity[playerid][1] = 0;
  1174. playerOldVelocity[playerid][2] = 0;
  1175. playerCheatTreshold[playerid] = 0;
  1176. playerInCountdown[playerid] = 0;
  1177. playerPingWarnings[playerid] = 0;
  1178. playerSpectate[playerid] = -1;
  1179. playerSpectated[playerid] = -1;
  1180. playerInstantSpawn[playerid] = 0;
  1181. playerReply[playerid] = 0;
  1182. playerForceCar[playerid] = -1;
  1183. playerTicks[playerid] = 0;
  1184.  
  1185. GetPlayerName(playerid, playerName[playerid], 24);
  1186. SetPlayerColor(playerid, COLOR_WHITE);
  1187. TogglePlayerClock(playerid, 1);
  1188.  
  1189. format(string, sizeof(string), "~>~ ~r~Laikas: ~g~0 sekundes ~<~~>~ ~r~Vieta: ~g~n/a ~<~~>~ ~r~Bukle: ~g~n/a ~<~~>~ ~r~Zemelapis: ~g~%s ~<~");
  1190. playerBar[playerid] = TextDrawCreate(10.000000,430.000000, string);
  1191. TextDrawAlignment(playerBar[playerid],0);
  1192. TextDrawBackgroundColor(playerBar[playerid],0xffffff33);
  1193. TextDrawFont(playerBar[playerid],1);
  1194. TextDrawLetterSize(playerBar[playerid],0.35,1.500000);
  1195. TextDrawColor(playerBar[playerid],0x000000ff);
  1196. TextDrawSetOutline(playerBar[playerid],1);
  1197. TextDrawSetProportional(playerBar[playerid],1);
  1198. TextDrawSetShadow(playerBar[playerid],1);
  1199. TextDrawShowForPlayer(playerid, playerBar[playerid]);
  1200.  
  1201. format(string, sizeof(string), "%s has connected.", playerName[playerid]);
  1202. SendClientMessageToAll(COLOR_GREY, string);
  1203.  
  1204. return 1;
  1205. }
  1206.  
  1207. public OnPlayerDisconnect(playerid, reason)
  1208. {
  1209. playerActive[playerid] = 0;
  1210. playerLevel[playerid] = 0;
  1211. DestroyVehicle(playerVehicle[playerid]);
  1212. playerVehicle[playerid] = -1;
  1213.  
  1214. KillTimers(playerid);
  1215.  
  1216. // Is he being spectated?
  1217. if(IsPlayerConnected(playerSpectated[playerid])){
  1218. SendClientMessage(playerSpectated[playerid], COLOR_ORANGE, "The player you were watching disconnected.");
  1219.  
  1220. playerInstantSpawn[playerid] = 1;
  1221. playerSpectated[playerSpectate[playerid]] = -1;
  1222. playerSpectate[playerid] = -1;
  1223.  
  1224. TogglePlayerSpectating(playerid, 0);
  1225. }
  1226.  
  1227. if(reason == 0){
  1228. format(string, sizeof(string), "%s has timed out.", playerName[playerid]);
  1229. SendClientMessageToAll(COLOR_GREY, string);
  1230. }
  1231.  
  1232. if(reason == 1){
  1233. format(string, sizeof(string), "%s has disconnected.", playerName[playerid]);
  1234. SendClientMessageToAll(COLOR_GREY, string);
  1235. }
  1236.  
  1237. return 1;
  1238. }
  1239.  
  1240. public KillTimers(playerid){
  1241. if(playerCountdown[playerid] > -1){ KillTimer(playerCountdown[playerid]); playerInCountdown[playerid] = 0; playerCountdown[playerid] = -1; }
  1242. if(playerActiveTimer[playerid] > -1){ KillTimer(playerActiveTimer[playerid]); playerActiveTimer[playerid] = -1; }
  1243. }
  1244.  
  1245. public OnPlayerSpawn(playerid)
  1246. {
  1247. if(playerSpectating[playerid] == 1){
  1248. playerSpectating[playerid] = 0;
  1249. } else {
  1250. if(playerInstantSpawn[playerid] == 1){
  1251. CountdownPlayer(playerid, 1);
  1252. } else if(playerFastSpawn[playerid] == 1){
  1253. CountdownPlayer(playerid, 5);
  1254. } else {
  1255. CountdownPlayer(playerid, 10);
  1256. }
  1257.  
  1258. playerInstantSpawn[playerid] = 0;
  1259. playerFirst[playerid] = 0;
  1260. playerFastSpawn[playerid] = 0;
  1261. }
  1262.  
  1263. return 1;
  1264. }
  1265.  
  1266. public OnPlayerDeath(playerid, killerid, reason){
  1267. SetPlayerColor(playerid, COLOR_WHITE);
  1268.  
  1269. format(string, sizeof(string), "%s died after %d seconds.", playerName[playerid], playerTime[playerid]);
  1270. SendClientMessageToAll(COLOR_YELLOW, string);
  1271.  
  1272. // Is he being spectated?
  1273. if(IsPlayerConnected(playerSpectated[playerid])){
  1274. SendClientMessage(playerSpectated[playerid], COLOR_ORANGE, "Your camera will be corrected as soon as the player respawns.");
  1275. }
  1276.  
  1277. new vehicleid = playerVehicle[playerid];
  1278. vehicleKill[vehicleid] = SetTimerEx("KillVehicle", 3000, false, "d", vehicleid);
  1279.  
  1280. playerVehicle[playerid] = -1;
  1281. playerTime[playerid] = 0;
  1282. playerActive[playerid] = 0;
  1283. }
  1284.  
  1285. public KillVehicle(vehicleid){
  1286. if(vehicleKill[vehicleid] > -1){ KillTimer(vehicleKill[vehicleid]); vehicleKill[vehicleid] = -1; }
  1287.  
  1288. return DestroyVehicle(vehicleid);
  1289. }
  1290.  
  1291. public OnVehicleSpawn(vehicleid)
  1292. {
  1293. if(vehicleKill[vehicleid] > -1){ KillTimer(vehicleKill[vehicleid]); vehicleKill[vehicleid] = -1; }
  1294.  
  1295. return DestroyVehicle(vehicleid);
  1296. }
  1297.  
  1298. public OnPlayerText(playerid, text[])
  1299. {
  1300. if(strcmp(text, "@", true, 1) == 0 && CheckAdminLevel(playerid, 1)){
  1301. strdel(text, 0, 1);
  1302.  
  1303. format(string, sizeof(string), "[ADMIN] %s: %s", playerName[playerid], text);
  1304. AdminMessage(string);
  1305. } else {
  1306. format(string, sizeof(string), "%s: %s", playerName[playerid], text);
  1307. SendClientMessageToAll(COLOR_WHITE, string);
  1308. }
  1309.  
  1310. return 0;
  1311. }
  1312.  
  1313. public OnPlayerExitVehicle(playerid, vehicleid){
  1314. playerExiting[playerid] = 1;
  1315. playerVehicleHealth[playerid] = 990.0;
  1316. SetVehicleHealth(GetPlayerVehicleID(playerid), 990.0);
  1317. }
  1318.  
  1319. public OnPlayerStateChange(playerid, newstate, oldstate)
  1320. {
  1321. if(oldstate == 2 && newstate == 1){
  1322. if(playerExiting[playerid] == 1){
  1323. playerExiting[playerid] = 0;
  1324. playerOldVehicle[playerid] = playerVehicle[playerid];
  1325.  
  1326. format(string, sizeof(string), "%s exited their vehicle after %d seconds.", playerName[playerid], playerTime[playerid]);
  1327. SendClientMessageToAll(COLOR_YELLOW, string);
  1328.  
  1329. DestroyVehicle(playerVehicle[playerid]);
  1330. playerVehicle[playerid] = -1;
  1331.  
  1332. PlayerDied(playerid, true);
  1333. }
  1334. }
  1335.  
  1336. if(newstate == 9){
  1337. if(IsPlayerConnected(playerSpectate[playerid])){
  1338. new target = playerSpectate[playerid];
  1339.  
  1340. if(playerVehicle[target] == -1){
  1341. format(string, sizeof(string), "You will automatically spectate %s once respawned.", playerName[target]);
  1342. } else {
  1343. format(string, sizeof(string), "You are now spectating %s", playerName[target]);
  1344.  
  1345. PlayerSpectateVehicle(playerid, playerVehicle[target]);
  1346. }
  1347.  
  1348. SendClientMessage(playerid, COLOR_ORANGE, string);
  1349. } else {
  1350. SetPlayerCameraPos(playerid, mapCamera[COORD_X], mapCamera[COORD_Y], mapCamera[COORD_Z]);
  1351. SetPlayerCameraLookAt(playerid, mapCameraLookAt[COORD_X], mapCameraLookAt[COORD_Y], mapCameraLookAt[COORD_Z]);
  1352. }
  1353. } else {
  1354. if(oldstate == 9){
  1355. SetCameraBehindPlayer(playerid);
  1356. }
  1357. }
  1358.  
  1359. return 1;
  1360. }
  1361.  
  1362. public OnPlayerSelectedMenuRow(playerid, row)
  1363. {
  1364. return 1;
  1365. }
  1366.  
  1367. public OnPlayerExitedMenu(playerid)
  1368. {
  1369. return 1;
  1370. }
  1371.  
  1372. public OnPlayerUpdate(playerid)
  1373. {
  1374. playerUpdated[playerid] = 1;
  1375.  
  1376. if(playerIsPaused[playerid] == 1){
  1377. format(string, sizeof(string), "%s is back from being paused.", playerName[playerid]);
  1378. SendClientMessageToAll(COLOR_PINK, string);
  1379.  
  1380. SetPlayerVirtualWorld(playerid, 0);
  1381. playerIsPaused[playerid] = 0;
  1382. }
  1383.  
  1384. if(playerActive[playerid] == 1){
  1385. new Float:x, Float:y, Float:z, Float:vHealth, Float:pHealth, Float:pArmour, Float:vX, Float:vY, Float:vZ;
  1386. GetPlayerPos(playerid, x, y, z);
  1387.  
  1388. // Healths
  1389. GetVehicleHealth(GetPlayerVehicleID(playerid), vHealth);
  1390. GetPlayerHealth(playerid, pHealth);
  1391. GetPlayerArmour(playerid, pArmour);
  1392.  
  1393. // Velocity
  1394. GetVehicleVelocity(GetPlayerVehicleID(playerid), vX, vY, vZ);
  1395.  
  1396. if(playerTime[playerid] > 5){
  1397. // Airbreak
  1398. if(vX == 0.0 && vY == 0.0 && vZ < -0.0032 && vZ > -0.022){
  1399. playerAirbreak[playerid]++;
  1400.  
  1401. if(playerAirbreak[playerid] > 5){
  1402. AdminMessage("The player who is being kicked was airbreaking..");
  1403. BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 105)");
  1404.  
  1405. printf("CHEAT - AIRBREAK - %s - %f %f %f", playerName[playerid], vX, vY, vZ);
  1406.  
  1407. return false;
  1408. }
  1409. } else {
  1410. playerAirbreak[playerid] = 0;
  1411. }
  1412.  
  1413. // Velocity
  1414. if(playerVelocityTicks[playerid] > 15){
  1415. if(playerVelocity[playerid][0] > 19 || playerVelocity[playerid][0] < -19 || playerVelocity[playerid][1] > 19 || playerVelocity[playerid][1] < -19 || playerVelocity[playerid][2] > 19 || playerVelocity[playerid][2] < -19){
  1416. AdminMessage("The player who is being kicked was speedhacking (speed)..");
  1417. BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 106)");
  1418.  
  1419. printf("CHEAT - VELOCITY1 - %s - %f %f %f", playerName[playerid], playerVelocity[playerid][0], playerVelocity[playerid][1], playerVelocity[playerid][2]);
  1420.  
  1421. return false;
  1422. }
  1423.  
  1424. new Float:increment[3];
  1425. increment[0] = playerVelocity[playerid][0] - playerOldVelocity[playerid][0];
  1426. increment[1] = playerVelocity[playerid][1] - playerOldVelocity[playerid][1];
  1427. increment[2] = playerVelocity[playerid][2] - playerOldVelocity[playerid][2];
  1428.  
  1429. if(playerOldVelocity[playerid][0] != 0 && (increment[0] > 10 || increment[0] < -10 || increment[1] > 10 || increment[1] < -10 || increment[2] > 10 || increment[2] < -10)){
  1430. /*
  1431. AdminMessage("The player who is being kicked was speedhacking (acceleration)..");
  1432. BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 107)");
  1433.  
  1434. printf("CHEAT - VELOCITY2 - %s - %f %f %f", playerName[playerid], increment[0], increment[1], increment[2]);
  1435.  
  1436. return false;
  1437. */
  1438. }
  1439.  
  1440. playerVelocityTicks[playerid] = 0;
  1441. playerOldVelocity[playerid][0] = playerVelocity[playerid][0];
  1442. playerOldVelocity[playerid][1] = playerVelocity[playerid][1];
  1443. playerOldVelocity[playerid][2] = playerVelocity[playerid][2];
  1444. playerVelocity[playerid][0] = 0;
  1445. playerVelocity[playerid][1] = 0;
  1446. playerVelocity[playerid][2] = 0;
  1447. } else {
  1448. playerVelocityTicks[playerid]++;
  1449. playerVelocity[playerid][0] += vX;
  1450. playerVelocity[playerid][1] += vY;
  1451. playerVelocity[playerid][2] += vZ;
  1452. }
  1453.  
  1454. // Player armor
  1455. if(pArmour > 0){
  1456. AdminMessage("The player who is being kicked had armour..");
  1457. BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 104)");
  1458.  
  1459. printf("CHEAT - ARMOUR - %s - %f", playerName[playerid], pArmour);
  1460.  
  1461. return false;
  1462. }
  1463.  
  1464. // Vehicle health
  1465. if(vHealth > 0){
  1466. if(vHealth > 990){
  1467. if(playerCheatTreshold[playerid] > 30){
  1468. AdminMessage("The player who is being kicked had their vehicle health go beyond our limit..");
  1469. BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 101)");
  1470.  
  1471. printf("CHEAT - VHEALTH1 - %s - %f", playerName[playerid], vHealth);
  1472.  
  1473. return false;
  1474. } else {
  1475. playerCheatTreshold[playerid]++;
  1476. }
  1477. }
  1478.  
  1479. if(vHealth > playerVehicleHealth[playerid] && playerVehicleHealth[playerid] > 0){
  1480. AdminMessage("The player who is being kicked had their vehicle health go up..");
  1481. BanReason(playerid, "Server", "Anti-Cheat triggered (Code: 102)");
  1482.  
  1483. printf("CHEAT - VHEALTH2 - %s - %f %f", playerName[playerid], vHealth, playerVehicleHealth[playerid]);
  1484.  
  1485. return false;
  1486. }
  1487. }
  1488.  
  1489. GetVehicleHealth(GetPlayerVehicleID(playerid), playerVehicleHealth[playerid]);
  1490. }
  1491.  
  1492. if(floatround(z) < mapTreshold){
  1493. format(string, sizeof(string), "%s fell off after %d seconds.", playerName[playerid], playerTime[playerid]);
  1494. SendClientMessageToAll(COLOR_YELLOW, string);
  1495.  
  1496. DestroyVehicle(GetPlayerVehicleID(playerid));
  1497. playerVehicle[playerid] = -1;
  1498.  
  1499. PlayerDied(playerid, true);
  1500. }
  1501. }
  1502.  
  1503. if(GetPlayerWeapon(playerid) != 0){
  1504. AdminMessage("The player who is being kicked had a weapon..");
  1505. BanReason(playerid, "Server", "Anti-Cheat triggered (Reason: 103)");
  1506.  
  1507. printf("CHEAT - WEAPON - %s - %d", playerName[playerid], GetPlayerWeapon(playerid));
  1508.  
  1509. return false;
  1510. }
  1511.  
  1512. return 1;
  1513. }
  1514.  
  1515. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1516. {
  1517. return 1;
  1518. }
  1519.  
  1520. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  1521. {
  1522. return 1;
  1523. }
  1524.  
  1525. //
  1526. // Invalid actions (most likely cheats)
  1527. //
  1528. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  1529. {
  1530. if(vehicleid != playerOldVehicle[playerid]){
  1531. AdminMessage("The player who is being kicked entered a vehicle..");
  1532. return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 001)");
  1533. } else {
  1534. return 1;
  1535. }
  1536. }
  1537.  
  1538. public OnPlayerPickUpPickup(playerid, pickupid)
  1539. {
  1540. AdminMessage("The player who is being kicked picked up a pickup..");
  1541. return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 002)");
  1542. }
  1543.  
  1544. public OnVehicleMod(playerid, vehicleid, componentid)
  1545. {
  1546. AdminMessage("The player who is being kicked modded their vehicle..");
  1547. return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 003)");
  1548. }
  1549.  
  1550. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  1551. {
  1552. AdminMessage("The player who is being kicked painted their vehicle..");
  1553. return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 004)");
  1554. }
  1555.  
  1556. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  1557. {
  1558. AdminMessage("The player who is being kicked resprayed their vehicle..");
  1559. return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 005))");
  1560. }
  1561.  
  1562. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  1563. {
  1564. AdminMessage("The player who is being kicked changed interior..");
  1565. return KickReason(playerid, "Server", "Anti-Cheat triggered (Code: 006)");
  1566. }
  1567.  
  1568. //
  1569. // Stocks
  1570. //
  1571. #define _strlib_included
  1572. #define _strlib_sma_string 128
  1573. #define _strlib_med_string 256
  1574. #define _strlib_big_string 512
  1575.  
  1576. stock GetPlayerPlace(playerid)
  1577. {
  1578. new Rank = 1;
  1579. new score = playerTime[playerid];
  1580. for(new i; i < MAX_PLAYERS; i++)
  1581. {
  1582. if(playerActive[i] == 1 && playerTime[i] > score) Rank++;
  1583. }
  1584. return Rank;
  1585. }
  1586.  
  1587. stock CheckAdminLevel(playerid, level){
  1588. if(playerLevel[playerid] >= level){
  1589. return true;
  1590. } else {
  1591. return false;
  1592. }
  1593. }
  1594.  
  1595. stock GetSuffix(number){
  1596. new suffix[4];
  1597.  
  1598. if(number == 1 || number == 21 || number == 31 || number == 41){
  1599. format(suffix, sizeof(suffix), "st");
  1600. } else if(number == 2 || number == 22 || number == 32 || number == 42){
  1601. format(suffix, sizeof(suffix), "nd");
  1602. } else if(number == 3|| number == 23 || number == 33 || number == 43){
  1603. format(suffix, sizeof(suffix), "rd");
  1604. } else {
  1605. format(suffix, sizeof(suffix), "th");
  1606. }
  1607.  
  1608. return suffix;
  1609. }
  1610.  
  1611. stock trim(const sSource[])
  1612. {
  1613. new
  1614. iBegin,
  1615. iEnd,
  1616. iInputLength = strlen(sSource),
  1617. sReturn[_strlib_med_string];
  1618.  
  1619. strcat(sReturn, sSource, _strlib_med_string);
  1620.  
  1621. for(iBegin = 0; iBegin < iInputLength; ++iBegin)
  1622. {
  1623. switch(sReturn[iBegin])
  1624. {
  1625. case ' ', '\t', '\r', '\n':
  1626. {
  1627. continue;
  1628. }
  1629. default:
  1630. {
  1631. break;
  1632. }
  1633. }
  1634. }
  1635.  
  1636. for(iEnd = (iInputLength - 1); iEnd > iBegin; --iEnd)
  1637. {
  1638. switch(sReturn[iEnd])
  1639. {
  1640. case ' ', '\t', '\r', '\n':
  1641. {
  1642. continue;
  1643. }
  1644. default:
  1645. {
  1646. break;
  1647. }
  1648. }
  1649. }
  1650.  
  1651. strdel(sReturn, (iEnd + 1), iInputLength);
  1652. strdel(sReturn, 0, iBegin);
  1653.  
  1654. return sReturn;
  1655. }
Advertisement
Add Comment
Please, Sign In to add comment