Advertisement
Hiddos

tank.pwn

Jan 21st, 2012
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 5.01 KB | None | 0 0
  1. // tank.pwn
  2. // Small gamemode made my Hiddos
  3. // © Hiddos 2012
  4. #include <a_samp>
  5. #define COLOR_MSG 0x00FFFFFF
  6.     //  Change this to whatever time you want the firing blip to be shown.
  7. #define BLIP_INTERVAL (4000)
  8.     //  All spawn locations. Located in East-LV
  9. new Float:spawnpoints[24][4] = {
  10.     {1891.6543,1162.9626,10.8277,179.6629},
  11.     {2020.1410,1545.6776,10.8354,270.5736},
  12.     {1923.2551,1987.0009,7.6011,274.0966},
  13.     {2011.1720,2138.1384,10.8277,270.5751},
  14.     {2107.2334,2509.0537,10.8279,270.6009},
  15.     {2037.0105,2728.4507,10.8285,359.8666},
  16.     {2346.9155,2759.0457,10.8275,269.3924},
  17.     {2468.3284,2346.5156,10.8278,270.1937},
  18.     {2455.7800,1912.3488,10.8723,0.1140},
  19.     {2219.2756,1838.4451,10.8275,178.5154},
  20.     {2177.5129,1678.4075,10.9383,181.0688},
  21.     {2222.4519,1427.9548,10.8279,269.8378},
  22.     {2232.9871,1283.1406,10.7522,0.1504},
  23.     {2452.3577,1230.9578,10.8277,359.6593},
  24.     {2548.3464,1145.7690,10.8276,90.5001},
  25.     {2460.2100,921.6903,10.8275,0.3934},
  26.     {2394.4424,1013.1955,10.8276,179.1484},
  27.     {2274.9773,1123.3292,10.8274,246.0380},
  28.     {2311.0989,1794.2229,10.8275,179.6785},
  29.     {2475.0234,1778.8390,10.8276,269.3282},
  30.     {2487.9351,1532.5677,10.7551,229.4505},
  31.     {2917.1399,2093.4749,10.8210,87.6007},
  32.     {2764.9453,1249.7780,10.7649,0.9013},
  33.     {2583.8162,1032.7301,10.8279,89.6140}
  34. };
  35. new vehicle[MAX_PLAYERS];
  36. new lastfire[MAX_PLAYERS];
  37. forward Spawn(playerid);
  38. main()
  39. {
  40.     print("\n----------------------------------");
  41.     print(" Tank by Hiddos\n © Hiddos 2012");
  42.     print("----------------------------------\n");
  43. }
  44.  
  45. public OnGameModeInit()
  46. {
  47.     SetGameModeText("Tank");
  48.     AddPlayerClass(287, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  49.     return 1;
  50. }
  51.  
  52. public Spawn(playerid)
  53. {
  54.     SpawnPlayer(playerid);
  55. }
  56.  
  57. public OnPlayerRequestClass(playerid, classid)
  58. {
  59.         //  No class selection, immediate spawning.
  60.         //  It's not possible to use SpawnPlayer when a player connects to the server. Therefore we use a timer linked to Spawn(), which spawns the player.
  61.     SetTimerEx("Spawn", 1, false, "i", playerid);
  62.     return 1;
  63. }
  64.  
  65. public OnPlayerConnect(playerid)
  66. {
  67.         //  White on the TAB list, invisible on the minimap
  68.     SetPlayerColor(playerid, 0xFFFFFF00);
  69.     SendClientMessage(playerid, COLOR_MSG, "Welcome to the server! Use /about to know more about this script!");
  70.     return 1;
  71. }
  72.  
  73. public OnPlayerDisconnect(playerid, reason)
  74. {
  75.         //  Delete vehicle
  76.     DestroyVehicle(vehicle[playerid]);
  77.     vehicle[playerid] = 0;
  78.     return 1;
  79. }
  80.  
  81. public OnPlayerSpawn(playerid)
  82. {
  83.         //  Setting world boundaries so the player doesn't exist east-LV
  84.     SetPlayerWorldBounds(playerid, 2942.0432, 1841.6453, 2925.3669, 905.5538);
  85.         //  Fetch a random position and spawn the player.
  86.     new rand = random(sizeof spawnpoints);
  87.     vehicle[playerid] = CreateVehicle(432, spawnpoints[rand][0], spawnpoints[rand][1], spawnpoints[rand][2], spawnpoints[rand][3], -1, -1, 0);
  88.     PutPlayerInVehicle(playerid, vehicle[playerid], 0);
  89.     return 1;
  90. }
  91.  
  92. public OnPlayerDeath(playerid, killerid, reason)
  93. {
  94.         //  Delete vehicle
  95.     DestroyVehicle(vehicle[playerid]);
  96.     vehicle[playerid] = 0;
  97.     return 1;
  98. }
  99.  
  100. public OnVehicleDeath(vehicleid, killerid)
  101. {
  102.         //  Secured deletion of vehicle. Vehicle destroyed = Kill player and respawn
  103.     for(new i = 0; i < MAX_PLAYERS; i++)
  104.     {
  105.         if(vehicle[i] == vehicleid)
  106.         {
  107.             DestroyVehicle(vehicle[i]);
  108.             vehicle[i] = 0;
  109.             SetPlayerHealth(i, 0.0);
  110.             break;
  111.         }
  112.     }
  113.     return 1;
  114. }
  115.  
  116. public OnPlayerCommandText(playerid, cmdtext[])
  117. {
  118.         //  Feel free to edit or throw away the credits. Just don't claim it as your own.
  119.     if(!strcmp(cmdtext, "/about", true, 6))
  120.     {
  121.         SendClientMessage(playerid, COLOR_MSG, "You're playing a minimode called 'tank.pwn', created by Hiddos from the SA-MP forums.");
  122.         SendClientMessage(playerid, COLOR_MSG, "This minimode was designed to have as few features as possible so new scripters can learn from it and edit it.");
  123.         SendClientMessage(playerid, COLOR_MSG, "Your objective is to kill other players. When somebody fires a shell, they get highlighted on the minimap");
  124.         SendClientMessage(playerid, COLOR_MSG, "for some time. This can help you to find other players. However, firing a bullet yourself allows other players to track you down too!");
  125.         return 1;
  126.     }
  127.     return 0;
  128. }
  129.  
  130. public OnPlayerStateChange(playerid, newstate, oldstate)
  131. {
  132.         //  No vehicle-exit
  133.     if(oldstate == PLAYER_STATE_DRIVER) PutPlayerInVehicle(playerid, vehicle[playerid], 0);
  134.     return 1;
  135. }
  136.  
  137. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  138. {
  139.         //  Add a temporary blip on the radar map when somebody fires a shell
  140.     if(newkeys & KEY_FIRE)
  141.     {
  142.         lastfire[playerid] = GetTickCount();
  143.         SetPlayerColor(playerid, 0xFFFFFF88);
  144.     }
  145.     return 1;
  146. }
  147.  
  148. public OnPlayerUpdate(playerid)
  149. {
  150.         //  Delete the blip again after some seconds
  151.     if(lastfire[playerid] != 0)
  152.     {
  153.         if(lastfire[playerid] + BLIP_INTERVAL < GetTickCount())
  154.         {
  155.             SetPlayerColor(playerid, 0xFFFFFF00);
  156.             lastfire[playerid] = 0;
  157.         }
  158.     }
  159.     return 1;
  160. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement