Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.29 KB | None | 0 0
  1. #include <a_samp>
  2. #include <zcmd>
  3. #include <sscanf2>
  4. #include <foreach>
  5.  
  6. //Redefine SAMP variables //
  7. #undef MAX_PLAYERS
  8. #define MAX_PLAYERS 50
  9. #undef MAX_VEHICLES
  10. #define MAX_VEHICLES 2000 // SA-MP limit as of 0.3x is 2000.
  11.  
  12. //Teams//
  13. #define TEAM_CIV 0
  14. #define TEAM_COP 1
  15. #define TEAM_SOLD 2
  16.  
  17. /*--[Colors]--*/
  18. #define COLOR_YELLOW 0xE4FF33AA
  19. #define COLOR_WHITE 0xFFFFFFFF
  20. #define COLOR_COP 0x0059FFFF
  21. #define COLOR_SOLDIER 0x2D9402FF
  22. #define COLOR_GREY 0xAFAFAFAA
  23. #define COLOR_RED 0xFF0000AA
  24.  
  25. #include <zcmd>
  26. #include <foreach>
  27.  
  28. /*#include <a_mysql>
  29. #include <sscanf2>
  30. #include <DiniSarp>
  31. #include <a_http>
  32. #include <streamer>
  33. #include <yom_buttons>
  34. #include <zones>*/ //includes i havent used yet
  35.  
  36.  
  37. new str[3000];
  38. new Text3D:civpickup, Text3D:coppickup, Text3D:solderpickup;
  39.  
  40. main()
  41. {
  42. }
  43.  
  44. /*new GPSOn[MAX_PLAYERS];
  45. forward DefineGPS(playerid);
  46. DefineGPS(playerid)
  47. {
  48. GPSOn[playerid] = 0;
  49. }*/
  50.  
  51. enum pInfo
  52. {
  53. pFaction,
  54. pGPS
  55. }
  56. new PlayerInfo[MAX_PLAYERS][pInfo];
  57.  
  58. public OnGameModeInit()
  59. {
  60. #pragma unused civpickup, coppickup, solderpickup
  61. SetGameModeText("Day"); //gamemode
  62.  
  63. // Add Player Classes
  64. AddPlayerClass(299, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  65. AddPlayerClass(265, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  66. AddPlayerClass(287, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  67.  
  68. //Add Vehicles
  69. AddStaticVehicle(425, -1454.3373,501.5115,18.2650,269.0268,43,0); //hunter for soldier spawn
  70. AddStaticVehicle(426, 1986.5759,150.8554,27.3533,179.8385,171,152); //car for civ spawn
  71. AddStaticVehicle(597, -1572.8947,730.6797,-5.2422,88.6973,0,1); //car for cop spawn
  72.  
  73. /*--[Spawn Icons]--*/
  74. format(str, sizeof(str), "--------\nCivilian Spawn\nThere are {FF6060}NULL{FFFFFF} Civilians\n--------");
  75. civpickup = Create3DTextLabel(str, COLOR_WHITE, -1969.2399, 120.1662, 27.6875, 30, 0);
  76. format(str, sizeof(str), "--------\nCop Spawn\nThere are {FF6060}NULL{0059FF} Cops\n--------");
  77. coppickup = Create3DTextLabel(str, COLOR_COP, -1588.1664, 719.0873, -5.2422, 30, 0);
  78. format(str, sizeof(str), "--------\nSoldier Spawn\nThere are {2D9402}NULL{2D9402} Soldier\n--------");
  79. solderpickup = Create3DTextLabel(str, COLOR_SOLDIER, -1395.9022, 499.5081, 18.2344, 30, 0);
  80. /*----------------*/
  81. return 1;
  82. }
  83.  
  84. public OnPlayerRequestClass(playerid, classid)
  85. {
  86. SetPlayerPos(playerid, -1753.6973,884.7565,295.8750);
  87. SetPlayerFacingAngle(playerid, 177.3350);
  88. SetPlayerCameraPos(playerid, -1753.5608,874.4424,300.7809);
  89. SetPlayerCameraLookAt(playerid, -1753.6973,884.7565,295.8750);
  90. switch(classid)
  91. {
  92. case TEAM_CIV:
  93. GameTextForPlayer(playerid,"~w~Civilian", 20000, 3);
  94. case TEAM_COP:
  95. GameTextForPlayer(playerid,"~b~Cop", 20000, 3);
  96. case TEAM_SOLD:
  97. GameTextForPlayer(playerid,"~g~Soldier", 20000, 3);
  98. }
  99. PlayerInfo[playerid][pFaction] = classid;
  100. return 1;
  101. }
  102.  
  103. public OnPlayerConnect(playerid)
  104. {
  105. format(str, sizeof(str), "[Connection]: %s has joined the server, there are now %d players.", PlayerName(playerid), GetPlayerCount());
  106. SendClientMessageToAll(COLOR_YELLOW, str);
  107. return 1;
  108. }
  109.  
  110. public OnPlayerDisconnect(playerid, reason)
  111. {
  112. new str2[16];
  113. switch(reason)
  114. {
  115. case 0:
  116. str2 = "Timeout";
  117. case 1:
  118. str2 = "Quit";
  119. case 2:
  120. str2 = "Kick";
  121. }
  122. format(str, sizeof(str), "[%s]: %s has disconnected from the server, there are now %d players.", str2, PlayerName(playerid), GetPlayerCount());
  123. SendClientMessageToAll(COLOR_YELLOW, str);
  124. }
  125. public OnPlayerSpawn(playerid)
  126. {
  127. if(IsPlayerConnected(playerid))
  128. {
  129. format(str, sizeof(str), "[Team]: %s has spawned as a %s", PlayerName(playerid), GetPlayerFaction(playerid));
  130. SendClientMessageToAll(COLOR_YELLOW, str);
  131. switch(PlayerInfo[playerid][pFaction])
  132. {
  133. case 0://Civilian
  134. {
  135. SetPlayerPos(playerid, -1968.5970,110.6172,27.6875);
  136. SetPlayerFacingAngle(playerid, 355.38);
  137. }
  138. case 1://Cop
  139. {
  140. SetPlayerPos(playerid, -1593.7192,716.2565,-5.2422);
  141. SetPlayerFacingAngle(playerid, 263.62);
  142. }
  143. case 2://Army
  144. {
  145. SetPlayerPos(playerid, -1390.5062,497.4170,18.2344);
  146. SetPlayerFacingAngle(playerid, 25.53);
  147. }
  148. default://In case of errors
  149. {
  150. SetPlayerPos(playerid, -1968.5970,110.6172,27.6875);
  151. SetPlayerFacingAngle(playerid, 355.38);
  152. }
  153. }
  154. SetCameraBehindPlayer(playerid);
  155. UpdateTeamText();
  156. }
  157. return 1;
  158. }
  159.  
  160. forward GetPlayerCount();
  161. public GetPlayerCount()
  162. {
  163. new PlayerCount;
  164. foreach(Player, i)
  165. {
  166. if(IsPlayerConnected(i))
  167. {
  168. PlayerCount ++;
  169. }
  170. }
  171. return PlayerCount;
  172. }
  173.  
  174. forward GetPlayerFaction(playerid);
  175. GetPlayerFaction(playerid)
  176. {
  177. new PlayerFaction[32];
  178. switch(PlayerInfo[playerid][pFaction])
  179. {
  180. case TEAM_CIV:
  181. PlayerFaction = "Civilian";
  182. case TEAM_COP:
  183. PlayerFaction = "Cop";
  184. case TEAM_SOLD:
  185. PlayerFaction = "Soldier";
  186. default:
  187. PlayerFaction = "Error";
  188. }
  189. return PlayerFaction;
  190. }
  191.  
  192. forward PlayerName(playerid);
  193. PlayerName(playerid)
  194. {
  195. new PlayerNamee[MAX_PLAYER_NAME];
  196. if(IsPlayerConnected(playerid))
  197. {
  198. GetPlayerName(playerid, PlayerNamee, sizeof(PlayerNamee));
  199. }
  200. return PlayerNamee;
  201. }
  202.  
  203. forward UpdateTeamText();
  204. UpdateTeamText()
  205. {
  206. new team;
  207. /*--[Spawn Icons]--*/
  208. team = 0;
  209. format(str, sizeof(str), "--------\nCivilian Spawn\nThere are {FF6060}%d{FFFFFF} Civilians\n--------", GetTeamCount(team));
  210. Update3DTextLabelText(civpickup, COLOR_WHITE, str);
  211. team = 1;
  212. format(str, sizeof(str), "--------\nCop Spawn\nThere are {FF6060}%d{0059FF} Cops\n--------", GetTeamCount(team));
  213. Update3DTextLabelText(coppickup, COLOR_COP, str);
  214. team = 2;
  215. format(str, sizeof(str), "--------\nSoldier Spawn\nThere are {FF6060}%d{2D9402} Soldier\n--------", GetTeamCount(team));
  216. Update3DTextLabelText(solderpickup, COLOR_SOLDIER, str);
  217. /*----------------*/
  218. }
  219.  
  220. forward GetTeamCount(team);
  221. GetTeamCount(team)
  222. {
  223. new count;
  224. switch(team)
  225. {
  226. case 0://Civilians
  227. {
  228. foreach(Player, i)
  229. {
  230. if(IsPlayerConnected(i))
  231. {
  232. if(PlayerInfo[i][pFaction] == 0) count ++;
  233. }
  234. }
  235. }
  236. case 1://Cop
  237. {
  238. foreach(Player, i)
  239. {
  240. if(IsPlayerConnected(i))
  241. {
  242. if(PlayerInfo[i][pFaction] == 1) count ++;
  243. }
  244. }
  245. }
  246. case 2://Soldier
  247. {
  248. foreach(Player, i)
  249. {
  250. if(IsPlayerConnected(i))
  251. {
  252. if(PlayerInfo[i][pFaction] == 2) count ++;
  253. }
  254. }
  255. }
  256. }
  257. return count;
  258. }
  259.  
  260. CMD:goto(playerid, params[])
  261. {
  262. new tmp[10];
  263. if(!IsPlayerConnected(playerid)) return 1;
  264. if(sscanf(params, "s[10]", tmp)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /goto (civ, cop, soldier)");
  265. if(!strcmp(tmp, "civ"))//goto civ
  266. {
  267. SendClientMessage(playerid, COLOR_WHITE, "[Teleport]: You have been teleported to the civilian spawn.");
  268. SetPlayerPos(playerid, -1968.5970,110.6172,27.6875);
  269. SetPlayerFacingAngle(playerid, 355.38);
  270. SetCameraBehindPlayer(playerid);
  271. }
  272. else if(!strcmp(tmp, "cop"))//goto cop
  273. {
  274. SendClientMessage(playerid, COLOR_COP, "[Teleport]: You have been teleported to the cop spawn.");
  275. SetPlayerPos(playerid, -1593.7192,716.2565,-5.2422);
  276. SetPlayerFacingAngle(playerid, 263.62);
  277. SetCameraBehindPlayer(playerid);
  278. }
  279. else if(!strcmp(tmp, "soldier"))//goto cop
  280. {
  281. SendClientMessage(playerid, COLOR_SOLDIER, "[Teleport]: You have been teleported to the soldier spawn.");
  282. SetPlayerPos(playerid, -1390.5062,497.4170,18.2344);
  283. SetPlayerFacingAngle(playerid, 25.53);
  284. SetCameraBehindPlayer(playerid);
  285. }
  286. return 1;
  287. }
  288.  
  289. CMD:myclassid(playerid)
  290. {
  291. new strid[100];
  292. format(strid, 100, "Team ID: %s", GetPlayerFaction(playerid));
  293. SendClientMessage(playerid, COLOR_GREY, strid);
  294. return 1;
  295. }
  296.  
  297. CMD:gps(playerid)
  298. {
  299. SendClientMessage(playerid, COLOR_GREY, GetPlayerFaction(playerid)); //temp to check where class is being changed
  300.  
  301. if(!IsPlayerConnected(playerid)) return 1;
  302. if(PlayerInfo[playerid][pGPS])
  303. {
  304. PlayerInfo[playerid][pGPS] = 0;
  305. PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
  306. SendClientMessage(playerid, COLOR_RED, "GPS disabled.");
  307. foreach(Player, i)
  308. {
  309. new player1[128], player2[64];
  310. player1 = GetPlayerFaction(playerid);
  311. player2 = GetPlayerFaction(i);
  312. if(!strcmp(player1, "Civilian") && !strcmp(player2, "Civilian"))
  313. {
  314. SetPlayerMarkerForPlayer(playerid, i, COLOR_WHITE);
  315. return 1;
  316. }
  317. if(!strcmp(player1, "Cop") && !strcmp(player2, "Cop"))
  318. {
  319. SetPlayerMarkerForPlayer(playerid, i, COLOR_COP);
  320. return 1;
  321. }
  322. if(!strcmp(player1, "Soldier") && !strcmp(player2, "Soldier"))
  323. {
  324. SetPlayerMarkerForPlayer(playerid, i, COLOR_SOLDIER);
  325. return 1;
  326. }
  327. }
  328. return 1;
  329. }
  330. else
  331. {
  332. PlayerInfo[playerid][pGPS] = 1;
  333. SendClientMessage(playerid, COLOR_GREY, GetPlayerFaction(playerid)); //temp to check where class is being changed
  334. PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
  335. foreach(Player, i)
  336. {
  337. new player1[128], player2[64];
  338. player1 = GetPlayerFaction(playerid);
  339. player2 = GetPlayerFaction(i);
  340. if(!strcmp(player1, "Civilian") && !strcmp(player2, "Civilian"))
  341. {
  342. SendClientMessage(playerid, COLOR_WHITE, "GPS enabled, your team can now see your location.");
  343. SetPlayerMarkerForPlayer(playerid, i, COLOR_WHITE);
  344. return 1;
  345. }
  346. if(!strcmp(player1, "Cop") && !strcmp(player2, "Cop"))
  347. {
  348. SendClientMessage(playerid, COLOR_GREY, GetPlayerFaction(playerid)); //temp to check where class is being changed
  349. SendClientMessage(playerid, COLOR_COP, "GPS enabled, your team can now see your location.");
  350. SetPlayerMarkerForPlayer(playerid, i, COLOR_COP);
  351. return 1;
  352. }
  353. if(!strcmp(player1, "Soldier") && !strcmp(player2, "Soldier"))
  354. {
  355. SendClientMessage(playerid, COLOR_SOLDIER, "GPS enabled, your team can now see your location.");
  356. SetPlayerMarkerForPlayer(playerid, i, COLOR_SOLDIER);
  357. return 1;
  358. }
  359. }
  360. }
  361. return 1;
  362. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement