Advertisement
Bulletje

Untitled

Jan 21st, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.79 KB | None | 0 0
  1. /*
  2. Script by: Bullet
  3. Map by: Bullet
  4. Mission Base: Team Deathmatch
  5. Mission Type: Team Deathmatch
  6. Mission Type ID: 6
  7. */
  8. //==============================================================================
  9. // Includes
  10. //==============================================================================
  11. #include <a_samp>
  12. #include <crashdetect>
  13. #include <float>
  14. #include <fixes2>
  15.  
  16. #include "..\filterscripts\MM\stuff\defines"
  17. #include "..\filterscripts\MM\stuff\serverkeymsg"
  18.  
  19. //==============================================================================
  20. // Defines
  21. //==============================================================================
  22.  
  23. #define MISSION_NAME "Los Santos Bash"
  24. #define Health 99.0
  25. #define TEAM_DEFEND_NAME "Groves"
  26. #define TEAM_ATTACK_NAME "Ballas"
  27. #define MAX_MAP_OBJECTS 0
  28. #define VEHICLE_HEALTH 0
  29. #define CLASS_POSTION 1960.3746,-1206.2233,27.0981
  30. #define CLASS_CAMERA 1966.6736,-1205.9620,27.6609
  31. #define CLASS_FACING_AGNLE 269.6407
  32. #define SINKING false
  33. #define SPAWN_PROTECTION true
  34.  
  35. //==============================================================================
  36. // Per mission functions
  37. //==============================================================================
  38.  
  39. enum ped_enum
  40. {
  41. TeamID,
  42. Skin,
  43. Float:SpawnX,
  44. Float:SpawnY,
  45. Float:SpawnZ,
  46. Float:SpawnAngle,
  47. SpawnInterior,
  48. VirtualWorld,
  49. Weapon1,
  50. Ammo1,
  51. Weapon2,
  52. Ammo2,
  53. Weapon3,
  54. Ammo3,
  55. };
  56.  
  57.  
  58. new PedInfo[][ped_enum] = {
  59.  
  60. {TEAM_ATTACK, 102, 2053.9026,-1151.6842,23.7296,99.0651,0,0,WEAPON_BAT,1,WEAPON_DEAGLE,250,WEAPON_AK47,500},
  61. {TEAM_DEFEND, 105, 1863.5563,-1239.7374,15.1647,271.2530,0,0,WEAPON_BAT,1,WEAPON_DEAGLE,250,WEAPON_AK47,500},
  62. {TEAM_ATTACK, 103, 2053.9026,-1151.6842,23.7296,99.0651,0,0,0,0,0,0,WEAPON_SHOTGSPA,300},
  63. {TEAM_DEFEND, 106, 1863.5563,-1239.7374,15.1647,271.2530,0,0,0,0,0,0,WEAPON_SHOTGSPA,300},
  64. {TEAM_ATTACK, 104, 2053.9026,-1151.6842,23.7296,99.0651,0,0,WEAPON_COLT45,450,WEAPON_MP5,450,WEAPON_M4,500},
  65. {TEAM_DEFEND, 107, 1863.5563,-1239.7374,15.1647,271.2530,0,0,WEAPON_COLT45,450,WEAPON_MP5,450,WEAPON_M4,500}
  66. };
  67.  
  68. #if SINKING == true
  69. new MapSkining[2];
  70. #endif
  71.  
  72. #if MAX_MAP_OBJECTS != 0
  73. new Object[MAX_MAP_OBJECTS];
  74.  
  75. CreateMap()
  76. {
  77. }
  78. #endif
  79.  
  80. //==============================================================================
  81. // Basic vars
  82. //==============================================================================
  83.  
  84. new bool:MissionStarted;
  85. new bool:ObjectiveStarted;
  86. new bool:MissionCancelled;
  87.  
  88. native IsValidVehicle(vehicleid);
  89.  
  90. enum teamdata
  91. {
  92. Kills,
  93. Name[32],
  94. Members
  95. };
  96.  
  97. enum playerdata
  98. {
  99. UserName[MAX_PLAYER_NAME],
  100. bool:Counted,
  101. TeamSelection,
  102. PlayerClassID
  103. };
  104.  
  105. new Team[2][teamdata];
  106. new PlayerMissionInfo[MAX_PLAYERS][playerdata];
  107.  
  108. //==============================================================================
  109. // Basic script
  110. //==============================================================================
  111.  
  112. main()
  113. {
  114. print("----------------------------------");
  115. print(" Mission: "MISSION_NAME" started.");
  116. print("----------------------------------\n");
  117. }
  118.  
  119. public OnGameModeInit()
  120. {
  121. MissionStarted= true;
  122.  
  123. format(Team[TEAM_DEFEND][Name],32,"%s",TEAM_DEFEND_NAME);
  124. format(Team[TEAM_ATTACK][Name],32,"%s",TEAM_ATTACK_NAME);
  125.  
  126. if(CallRemoteFunction("GetCurrentMissionCJWalk","")) UsePlayerPedAnims();
  127.  
  128. #if MAX_MAP_OBJECTS != 0
  129. CreateMap();
  130. #endif
  131.  
  132. for(new i=0; i<sizeof(PedInfo); i++)AddPlayerClassEx(PedInfo[i][TeamID],PedInfo[i][Skin],PedInfo[i][SpawnX],PedInfo[i][SpawnY],PedInfo[i][SpawnZ],PedInfo[i][SpawnAngle],0,0,0,0,0,0);
  133.  
  134. #if SINKING == true
  135. MapSkining[0] = SetTimer("SinkMap", 80*1000, false);
  136. #endif
  137.  
  138. for(new i=0; i<MAX_VEHICLES; i++) if(IsValidVehicle(i)) SetVehicleHealth(i,VEHICLE_HEALTH);
  139. for(new i=0; i<MAX_PLAYERS; i++) PlayerMissionInfo[i][TeamSelection]= NO_TEAM;
  140.  
  141. SetTimer("StartMissionFunc",3000,false);
  142. return 1;
  143. }
  144.  
  145. FUNCTION StartMissionFunc()
  146. {
  147. CallRemoteFunction("StartMission","");
  148. ObjectiveStarted= true;
  149. return 1;
  150. }
  151.  
  152. public OnGameModeExit()
  153. {
  154. #if MAX_MAP_OBJECTS != 0
  155. for(new i=0;i<MAX_MAP_OBJECTS;i++) DestroyObject(Object[i]);
  156. #endif
  157. return 1;
  158. }
  159.  
  160. public OnPlayerDisconnect(playerid)
  161. {
  162. if(PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM && PlayerMissionInfo[playerid][Counted])
  163. {
  164. Team[PlayerMissionInfo[playerid][TeamSelection]][Members] --;
  165. PlayerMissionInfo[playerid][Counted] = false;
  166. }
  167. return 1;
  168. }
  169.  
  170. public OnPlayerRequestClass(playerid,classid)
  171. {
  172. SetPlayerPos(playerid,CLASS_POSTION);
  173. SetPlayerCameraPos(playerid,CLASS_CAMERA);
  174. SetPlayerCameraLookAt(playerid,CLASS_POSTION);
  175. SetPlayerFacingAngle(playerid,CLASS_FACING_AGNLE);
  176.  
  177. CallRemoteFunction("TdmHide","i",playerid);
  178. CallRemoteFunction("ShowClassSelection","ddsddd",playerid, PedInfo[classid][TeamID],Team[PedInfo[classid][TeamID]][Name], PedInfo[classid][Weapon1], PedInfo[classid][Weapon2], PedInfo[classid][Weapon3]);
  179. if(PlayerMissionInfo[playerid][Counted] && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM)
  180. {
  181. Team[PlayerMissionInfo[playerid][TeamSelection]][Members]--;
  182. PlayerMissionInfo[playerid][Counted] = false;
  183. }
  184. PlayerMissionInfo[playerid][TeamSelection] = PedInfo[classid][TeamID];
  185. PlayerMissionInfo[playerid][PlayerClassID]=classid;
  186. return 1;
  187. }
  188.  
  189. public OnPlayerRequestSpawn(playerid)
  190. {
  191. new opp_team = (PlayerMissionInfo[playerid][TeamSelection] == 1)? 0:1;
  192. if(Team[PlayerMissionInfo[playerid][TeamSelection]][Members] > Team[opp_team][Members])
  193. {
  194. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,"This Team is full, choose another!",0);
  195. return 0;
  196. }
  197. return 1;
  198. }
  199. public OnPlayerSpawn(playerid)
  200. {
  201. new string[124];
  202. CallRemoteFunction("UpdateAliveState","ii",playerid,1);
  203. CallRemoteFunction("TdmShow","i",playerid);
  204. CallRemoteFunction("TdmUpdate","sssdd","Kills",Team[TEAM_DEFEND][Name],Team[TEAM_ATTACK][Name],Team[TEAM_DEFEND][Kills],Team[TEAM_ATTACK][Kills]);
  205. SetPlayerHealth(playerid,Health);
  206. if(CallRemoteFunction("GetSpectateStatus","d",playerid)) return CallRemoteFunction("SpecOffAdmin","d",playerid);
  207. if(CallRemoteFunction("GetJailedStatus","d",playerid)) CallRemoteFunction("SetJailed","d",playerid);
  208. else
  209. {
  210. SetPlayerPos(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnX],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnY],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnZ]);
  211. SetPlayerFacingAngle(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnAngle]);
  212. SetPlayerInterior(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][SpawnInterior]);
  213. SetPlayerVirtualWorld(playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][VirtualWorld]);
  214. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon1],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo1]);
  215. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon2],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo2]);
  216. CallRemoteFunction("GivePlayerWeaponEx","ddd",playerid,PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Weapon3],PedInfo[PlayerMissionInfo[playerid][PlayerClassID]][Ammo3]);
  217. if(!PlayerMissionInfo[playerid][Counted])
  218. {
  219. Team[PlayerMissionInfo[playerid][TeamSelection]][Members]++;
  220. PlayerMissionInfo[playerid][Counted] = true;
  221. new opp_team = (PlayerMissionInfo[playerid][TeamSelection] == 1)? 0:1;
  222. format(string,sizeof(string),"You have chosen team %s, your mission is to kill %s.",Team[PlayerMissionInfo[playerid][TeamSelection]][Name],Team[opp_team][Name]);
  223. CallRemoteFunction("ShowInfoBox", "iisi", playerid, -1,string,0);
  224. format(string,sizeof(string),"~r~~h~Eliminate ~w~%s.",Team[opp_team][Name]);
  225. CallRemoteFunction("ShowInfoText", "iisi", playerid, -1,string,0);
  226. }
  227. }
  228. SetPlayerTeam(playerid,PlayerMissionInfo[playerid][TeamSelection]);
  229. if(PlayerMissionInfo[playerid][TeamSelection] == TEAM_ATTACK) SetPlayerColor(playerid,COLOR_TEAM_ATTACK);
  230. else SetPlayerColor(playerid,COLOR_TEAM_DEFEND);
  231. #if SPAWN_PROTECTION == true
  232. CallRemoteFunction("SetSpawnProtection","df",playerid,Health);
  233. #endif
  234. return 1;
  235. }
  236.  
  237. public OnPlayerDeath(playerid, killerid, reason)
  238. {
  239. if(killerid != INVALID_PLAYER_ID && PlayerMissionInfo[playerid][TeamSelection] != NO_TEAM && MissionStarted)
  240. {
  241. Team[PlayerMissionInfo[killerid][TeamSelection]][Kills]++;
  242. SetPlayerScore(killerid,GetPlayerScore(killerid)+1);
  243. CallRemoteFunction("TdmUpdate","sssdd","Kills",Team[TEAM_DEFEND][Name],Team[TEAM_ATTACK][Name],Team[TEAM_DEFEND][Kills],Team[TEAM_ATTACK][Kills]);
  244. }
  245. CallRemoteFunction("UpdateAliveState","ii",playerid,0);
  246. return 1;
  247. }
  248.  
  249. public OnVehicleSpawn(vehicleid)
  250. {
  251. SetVehicleHealth(vehicleid,VEHICLE_HEALTH);
  252. return 1;
  253. }
  254.  
  255. FUNCTION EndTheMission()
  256. {
  257. if(!MissionStarted) return 1;
  258. MissionStarted= false;
  259. if(!MissionCancelled)
  260. {
  261. new string[256];
  262. new amount= 10000;
  263. new winning_team;
  264. if(Team[TEAM_DEFEND][Kills] == Team[TEAM_ATTACK][Kills]) { winning_team = 2; }
  265. else if(Team[TEAM_DEFEND][Kills] > Team[TEAM_ATTACK][Kills]) { winning_team = 0; }
  266. else { winning_team = 1; }
  267.  
  268. if(winning_team != 2)
  269. {
  270. amount =amount+(Team[winning_team][Kills]*100);
  271. format(string,sizeof(string),""SERVER_KEY_MSG" %s has won the team deathmatch! Reward: $%d",Team[winning_team][Name],amount);
  272. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  273. SendClientMessageToAll(COLOR_SERVER,string);
  274. format(string,sizeof(string),""SERVER_KEY_MSG" You have received $%i because your team has won the team deathmatch!",amount);
  275. for(new i=0,j=GetPlayerPoolSize(); i <= j; i++)
  276. {
  277. if(PlayerMissionInfo[i][TeamSelection] == winning_team && PlayerMissionInfo[i][Counted])
  278. {
  279. PlayerPlaySound(i,3200,0,0,0);
  280. SendClientMessage(i,COLOR_SERVER,string);
  281. CallRemoteFunction("GivePlayerCash","ii",i,amount);
  282. CallRemoteFunction("PlayerMissionStats","dd",i,0);
  283. CallRemoteFunction("PlayerMissionStats","dd",i,6);
  284. }
  285. if(PlayerMissionInfo[i][TeamSelection] != winning_team && PlayerMissionInfo[i][Counted])
  286. {
  287. PlayerPlaySound(i,17004,0,0,0);
  288. GameTextForPlayer(i,"~R~MISSION FAILED~w~!",3000,3);
  289. CallRemoteFunction("PlayerMissionStats","dd",i,1);
  290. }
  291. }
  292. }
  293. else
  294. {
  295. PlaySoundForAll(1058);
  296. format(string,sizeof(string),""SERVER_KEY_MSG" IT'S A DRAW! No team has won the team-deathmatch.");
  297. SendClientMessageToAll(COLOR_SERVER,string);
  298. CallRemoteFunction("IRC_SendMessage","ss",string,IRC_SERVER_COLOR);
  299. for(new i=0,j=GetPlayerPoolSize(); i <= j; i++) if(IsPlayerConnected(i) && PlayerMissionInfo[i][Counted]) CallRemoteFunction("PlayerMissionStats","dd",i,2);
  300. }
  301. }
  302. else
  303. {
  304. PlaySoundForAll(1058);
  305. SendClientMessageToAll(COLOR_SERVER,""SERVER_KEY_MSG" The mission has been cancelled.");
  306. CallRemoteFunction("IRC_SendMessage","ss",""SERVER_KEY_MSG" The mission has been cancelled.",IRC_SERVER_COLOR);
  307. CallRemoteFunction("ShowInfoBox", "iisi", -1, -1,"The mission has been cancelled.",0);
  308. GameTextForAll("~R~MISSION CANCELLED~w~!",3000,3);
  309. }
  310. return 1;
  311. }
  312.  
  313. //==============================================================================
  314. // Mission functions
  315. //==============================================================================
  316.  
  317. #if SINKING == true
  318. FUNCTION SinkMap()
  319. {
  320. GameTextForAll("~r~the island is sinking!",4000,3);
  321. new Float:X, Float:Y, Float:Z;
  322. new Float:oldRotX, Float:oldRotY, Float:oldRotZ;
  323.  
  324. for(new i = 0; i < MAX_MAP_OBJECTS; i++) { GetObjectPos(Object[i], X, Y, Z), GetObjectRot(Object[i], oldRotX, oldRotY, oldRotZ); MoveObject(Object[i], X, Y, Z-40, 0.6, oldRotX, oldRotY, oldRotZ+0.05); }
  325. MapSkining[0] = SetTimer("ResurfaceMap", 150*1000,false);
  326. return true;
  327. }
  328.  
  329.  
  330. FUNCTION ResurfaceMap()
  331. {
  332. GameTextForAll("~g~the island is resurfacing!",4000,3);
  333. new Float:X, Float:Y, Float:Z;
  334. new Float:oldRotX, Float:oldRotY, Float:oldRotZ;
  335.  
  336. for(new i = 0; i < MAX_MAP_OBJECTS; i++) { GetObjectPos(Object[i], X, Y, Z), GetObjectRot(Object[i], oldRotX, oldRotY, oldRotZ); MoveObject(Object[i], X, Y, Z+40, 0.6, oldRotX, oldRotY, oldRotZ-0.05); }
  337. //MapSkining[1] = SetTimer("SinkMap", 80000,false);
  338. return true;
  339. }
  340. #endif
  341.  
  342. PlaySoundForAll(sound)
  343. {
  344. for (new i=0,j=GetPlayerPoolSize(); i <=j ; i++)
  345. {
  346. if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  347. }
  348. }
  349.  
  350. //==============================================================================
  351. // Important functions required
  352. //==============================================================================
  353.  
  354. FUNCTION OnPlayerNameRecieve(playerid,name[])
  355. {
  356. format(PlayerMissionInfo[playerid][UserName],MAX_PLAYER_NAME,"%s",name);
  357. return 1;
  358. }
  359.  
  360.  
  361. FUNCTION CancelTheMission()
  362. {
  363. MissionCancelled= true;
  364. return 1;
  365. }
  366.  
  367. FUNCTION MissionObjectiveStarted() return ObjectiveStarted;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement