Advertisement
Guest User

Turf Help

a guest
Apr 19th, 2014
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 14.35 KB | None | 0 0
  1. #define MAX_TURFS 40
  2. #define TWADMINMENU 4050
  3. #define TWEDITTURFSSELECTION 4051
  4. #define TWEDITTURFSMENU 4052
  5. #define TWEDITFCOLORSSELECTION 4053
  6. #define TWEDITFCOLORSMENU 4054
  7. #define TWEDITTURFSOWNER 4055
  8. #define TWEDITTURFSLOCKED 4056
  9. #define TWEDITTURFSVUL 4057
  10. #define TWEDITTURFSPERKS 4058
  11.  
  12. TurfWarsAdminMenu(playerid)
  13. {
  14. new string[128];
  15. format(string,sizeof(string),"Edit Turfs...\nEdit Family Colors...");
  16. ShowPlayerDialog(playerid,TWADMINMENU,DIALOG_STYLE_LIST,"Turf Wars - Admin Menu:",string,"Select","Exit");
  17. }
  18.  
  19. TurfWarsEditTurfsSelection(playerid)
  20. {
  21. new string[2048];
  22. for(new i = 0; i < MAX_TURFS; i++)
  23. {
  24. if(TurfWars[i][twOwnerId] != -1)
  25. {
  26. if(TurfWars[i][twOwnerId] < 0 || TurfWars[i][twOwnerId] > MAX_FAMILY-1)
  27. {
  28. format(string,sizeof(string),"%s%s - \t(Invalid Family)\n",string,TurfWars[i][twName]);
  29. }
  30. else
  31. {
  32. format(string,sizeof(string),"%s%s - \t(%s)\n",string,TurfWars[i][twName],FamilyInfo[TurfWars[i][twOwnerId]][FamilyName]);
  33. }
  34. }
  35. else
  36. {
  37. format(string,sizeof(string),"%s%s - \t(%s)\n",string,TurfWars[i][twName],"Vacant");
  38. }
  39. }
  40. ShowPlayerDialog(playerid,TWEDITTURFSSELECTION,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Selection Menu:",string,"Select","Back");
  41. }
  42.  
  43. TurfWarsEditTurfsMenu(playerid)
  44. {
  45. new string[128];
  46. format(string,sizeof(string),"Edit Dimensions...\nEdit Owners...\nEdit Vulnerable Time...\nEdit Locked...\nEdit Perks...\nReset War...\nDestroy Turf");
  47. ShowPlayerDialog(playerid,TWEDITTURFSMENU,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Menu:",string,"Select","Back");
  48. }
  49.  
  50. TurfWarsEditTurfsOwner(playerid)
  51. {
  52. new string[128];
  53. format(string,sizeof(string),"Please enter a family id that you wish to assign to this turf:\n\nHint: Enter -1 if you wish to vacant the turf.");
  54. ShowPlayerDialog(playerid,TWEDITTURFSOWNER,DIALOG_STYLE_INPUT,"Turf Wars - Edit Turfs Owner Menu:",string,"Change","Back");
  55. }
  56.  
  57. TurfWarsEditTurfsVul(playerid)
  58. {
  59. new string[128];
  60. format(string,sizeof(string),"Please enter a Vulnerable countdown time for the turf:");
  61. ShowPlayerDialog(playerid,TWEDITTURFSVUL,DIALOG_STYLE_INPUT,"Turf Wars - Edit Turfs Vulnerable Menu:",string,"Change","Back");
  62. }
  63.  
  64. TurfWarsEditTurfsLocked(playerid)
  65. {
  66. new string[128];
  67. format(string,sizeof(string),"Lock\nUnlock");
  68. ShowPlayerDialog(playerid,TWEDITTURFSLOCKED,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Locked Menu:",string,"Change","Back");
  69. }
  70.  
  71. TurfWarsEditTurfsPerks(playerid)
  72. {
  73. new string[128];
  74. format(string,sizeof(string),"None\nExtortion");
  75. ShowPlayerDialog(playerid,TWEDITTURFSPERKS,DIALOG_STYLE_LIST,"Turf Wars - Edit Turfs Perks Menu:",string,"Change","Back");
  76. }
  77.  
  78. CMD:twmenu(playerid, params[])
  79. {
  80. if(PlayerInfo[playerid][pAdmin] > 3 || PlayerInfo[playerid][pGangModerator] == 1)
  81. {
  82. TurfWarsAdminMenu(playerid);
  83. }
  84. else
  85. {
  86. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not authorized to use this command!");
  87. }
  88. return 1;
  89. }
  90.  
  91. CMD:turfinfo(playerid, params[])
  92. {
  93. if(GetPlayerTurfWarsZone(playerid) != -1) {
  94. new string[128];
  95. new tw = GetPlayerTurfWarsZone(playerid);
  96. format(string,sizeof(string),"|___________ (ID: %d) %s ___________|",tw,TurfWars[tw][twName]);
  97. SendClientMessageEx(playerid, COLOR_GREEN, string);
  98. if(TurfWars[tw][twOwnerId] != -1) {
  99. format(string,sizeof(string),"Owner: %s.",FamilyInfo[TurfWars[tw][twOwnerId]][FamilyName]);
  100. }
  101. else {
  102. format(string,sizeof(string),"Owner: Vacant.");
  103. }
  104. SendClientMessageEx(playerid, COLOR_WHITE, string);
  105. format(string,sizeof(string),"Vulnerable: %d Hours.",TurfWars[tw][twVulnerable]);
  106. SendClientMessageEx(playerid, COLOR_WHITE, string);
  107. format(string,sizeof(string),"Locked: %d.",TurfWars[tw][twLocked]);
  108. SendClientMessageEx(playerid, COLOR_WHITE, string);
  109. format(string,sizeof(string),"Active: %d.",TurfWars[tw][twActive]);
  110. SendClientMessageEx(playerid, COLOR_WHITE, string);
  111. if(TurfWars[tw][twActive] != 0) {
  112. format(string,sizeof(string),"Time Left: %d Secs.",TurfWars[tw][twTimeLeft]);
  113. SendClientMessageEx(playerid, COLOR_WHITE, string);
  114. if(TurfWars[tw][twAttemptId] == -1) {
  115. format(string,sizeof(string),"Takeover Faction: Law Enforcement.");
  116. SendClientMessageEx(playerid, COLOR_WHITE, string);
  117. }
  118. else {
  119. format(string,sizeof(string),"Takeover Family: %s.",FamilyInfo[TurfWars[tw][twAttemptId]][FamilyName]);
  120. SendClientMessageEx(playerid, COLOR_WHITE, string);
  121. }
  122. }
  123. switch(TurfWars[tw][twSpecial]) {
  124. case 1:
  125. {
  126. format(string,sizeof(string),"Special Perks: Extortion.");
  127. }
  128. default:
  129. {
  130. format(string,sizeof(string),"Special Perks: None.");
  131. }
  132. }
  133. SendClientMessageEx(playerid, COLOR_WHITE, string);
  134. }
  135. else {
  136. SendClientMessageEx(playerid, COLOR_WHITE, "You are not in a turf!");
  137. }
  138. return 1;
  139. }
  140.  
  141. CMD:claim(playerid, params[])
  142. {
  143. new string[128];
  144. new tw = GetPlayerTurfWarsZone(playerid);
  145. new family = PlayerInfo[playerid][pFMember];
  146. new rank = PlayerInfo[playerid][pRank];
  147. if(family == 255) {
  148. SendClientMessageEx(playerid, COLOR_GRAD2, "You are not in a family/gang, you can not claim turfs!");
  149. return 1;
  150. }
  151. if(rank < 5) {
  152. SendClientMessageEx(playerid, COLOR_GRAD2, "You have to be at least Rank 5 to claim turfs!");
  153. return 1;
  154. }
  155. if(FamilyInfo[family][FamilyTurfTokens] < 12) {
  156. SendClientMessageEx(playerid, COLOR_GRAD2, "Your family/gang does not have any turf claim tokens, please wait at least 12 hours.");
  157. return 1;
  158. }
  159. if(tw != -1) {
  160. if(TurfWars[tw][twLocked] == 1) {
  161. SendClientMessageEx(playerid, COLOR_GRAD2, "The turf is currently locked by a admin, you can not claim it!");
  162. return 1;
  163. }
  164. if(TurfWars[tw][twVulnerable] == 0) {
  165. if(TurfWars[tw][twActive] == 0) {
  166. if(TurfWars[tw][twOwnerId] == family) {
  167. SendClientMessageEx(playerid, COLOR_GRAD2, "Your family/gang already owns this turf, you are unable to claim it!");
  168. return 1;
  169. }
  170. new count = 0;
  171. foreach(Player, i) {
  172. if(family == PlayerInfo[i][pFMember]) {
  173. if(GetPlayerTurfWarsZone(i) == tw) {
  174. count++;
  175. }
  176. }
  177. }
  178.  
  179. if(count > 2) {
  180. FamilyInfo[family][FamilyTurfTokens] -= 12;
  181. TakeoverTurfWarsZone(family, tw);
  182. }
  183. else {
  184. SendClientMessageEx(playerid, COLOR_GRAD2, "You need at least 3 of your family/gang members on the turf, to be able to claim it!");
  185. }
  186. }
  187. else {
  188. new count = 0;
  189. new leocount = 0;
  190. if(TurfWars[tw][twAttemptId] == family) {
  191. SendClientMessageEx(playerid, COLOR_GRAD2, "You are already attempting to capture this turf!");
  192. return 1;
  193. }
  194.  
  195. foreach(Player, i) {
  196. if(TurfWars[tw][twAttemptId] == PlayerInfo[i][pFMember]) {
  197. if(GetPlayerTurfWarsZone(i) == tw) {
  198. count++;
  199. }
  200. }
  201. if(TurfWars[tw][twAttemptId] == -1) {
  202. if(IsACop(i)) {
  203. if(GetPlayerTurfWarsZone(i) == tw) {
  204. leocount++;
  205. }
  206. }
  207. }
  208. }
  209.  
  210. if(count == 0 && leocount == 0) {
  211. if(family != TurfWars[tw][twOwnerId]) {
  212. FamilyInfo[family][FamilyTurfTokens] -= 12;
  213. }
  214. foreach(Player, i) {
  215. if(PlayerInfo[i][pGangModerator] == 1) {
  216. format(string,sizeof(string),"%s has attempted to takeover turf %d for family %s",GetPlayerNameEx(playerid),tw,FamilyInfo[family][FamilyName]);
  217. SendClientMessageEx(i,COLOR_YELLOW,string);
  218. }
  219. }
  220. TakeoverTurfWarsZone(family, tw);
  221. }
  222. else {
  223. if(leocount == 0) {
  224. format(string,sizeof(string),"There is still %d Attacking Members on the Turf, you must get rid of them before reclaiming!",count);
  225. SendClientMessageEx(playerid, COLOR_GRAD2, string);
  226. }
  227. else {
  228. format(string,sizeof(string),"There is still %d Officers on the Turf, you must get rid of them before reclaiming!",leocount);
  229. SendClientMessageEx(playerid, COLOR_GRAD2, string);
  230. }
  231. }
  232. }
  233. }
  234. else {
  235. SendClientMessageEx(playerid, COLOR_GRAD2, "This turf is currently not vulnerable, you are unable to claim it!");
  236. }
  237. }
  238. else {
  239. SendClientMessageEx(playerid, COLOR_GRAD2, "You have to be in a turf to be able to claim turfs!");
  240. }
  241.  
  242. if(turfWarsRadar[playerid] == 0) {
  243. ShowTurfWarsRadar(playerid);
  244. }
  245. return 1;
  246. }
  247.  
  248. //================================================================
  249. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  250. {
  251. if(dialogid == TWADMINMENU) // Turf Wars System
  252. {
  253. if(response == 1)
  254. {
  255. switch(listitem)
  256. {
  257. case 0:
  258. {
  259. TurfWarsEditTurfsSelection(playerid);
  260. }
  261. case 1:
  262. {
  263. TurfWarsEditFColorsSelection(playerid);
  264. }
  265. }
  266. }
  267. }
  268. if(dialogid == TWEDITTURFSSELECTION)
  269. {
  270. if(response == 1)
  271. {
  272. for(new i = 0; i < MAX_TURFS; i++)
  273. {
  274. if(listitem == i)
  275. {
  276. SetPVarInt(playerid, "EditingTurfs", i);
  277. TurfWarsEditTurfsMenu(playerid);
  278. }
  279. }
  280. }
  281. else
  282. {
  283. TurfWarsAdminMenu(playerid);
  284. }
  285. }
  286. if(dialogid == TWEDITTURFSMENU)
  287. {
  288. if(response == 1)
  289. {
  290. new tw = GetPVarInt(playerid, "EditingTurfs");
  291. switch(listitem)
  292. {
  293. case 0: // Edit Dim
  294. {
  295. SetPVarInt(playerid, "EditingTurfsStage", 1);
  296. SendClientMessageEx(playerid, COLOR_WHITE, "Goto a location and type (/savetwpos) to edit the West Wall.");
  297. }
  298. case 1: // Edit Owner
  299. {
  300. TurfWarsEditTurfsOwner(playerid);
  301. }
  302. case 2: // Edit Vulnerablity
  303. {
  304. TurfWarsEditTurfsVul(playerid);
  305. }
  306. case 3: // Edit Locks
  307. {
  308. TurfWarsEditTurfsLocked(playerid);
  309. }
  310. case 4: // Edit Perks
  311. {
  312. TurfWarsEditTurfsPerks(playerid);
  313. }
  314. case 5: // Reset War
  315. {
  316. ResetTurfWarsZone(1, tw);
  317. TurfWarsEditTurfsSelection(playerid);
  318. }
  319. case 6: // Destroy Turf
  320. {
  321. DestroyTurfWarsZone(tw);
  322. TurfWarsEditTurfsSelection(playerid);
  323. }
  324. }
  325. }
  326. else
  327. {
  328. TurfWarsEditTurfsSelection(playerid);
  329. }
  330. }
  331. if(dialogid == TWEDITTURFSOWNER)
  332. {
  333. if(response == 1)
  334. {
  335. new tw = GetPVarInt(playerid, "EditingTurfs");
  336. if(IsNull(inputtext))
  337. {
  338. TurfWarsEditTurfsOwner(playerid);
  339. return 1;
  340. }
  341. if(strval(inputtext) < -1 || strval(inputtext) > MAX_FAMILY-1)
  342. {
  343. TurfWarsEditTurfsOwner(playerid);
  344. return 1;
  345. }
  346. SetOwnerTurfWarsZone(1, tw, strval(inputtext));
  347. SaveTurfWars();
  348. TurfWarsEditTurfsMenu(playerid);
  349. }
  350. else
  351. {
  352. TurfWarsEditTurfsMenu(playerid);
  353. }
  354. }
  355. if(dialogid == TWEDITTURFSVUL)
  356. {
  357. if(response == 1)
  358. {
  359. new tw = GetPVarInt(playerid, "EditingTurfs");
  360. if(IsNull(inputtext))
  361. {
  362. TurfWarsEditTurfsVul(playerid);
  363. return 1;
  364. }
  365. if(strval(inputtext) < 0)
  366. {
  367. TurfWarsEditTurfsVul(playerid);
  368. return 1;
  369. }
  370. TurfWars[tw][twVulnerable] = strval(inputtext);
  371. SaveTurfWars();
  372. TurfWarsEditTurfsMenu(playerid);
  373. }
  374. else
  375. {
  376. TurfWarsEditTurfsMenu(playerid);
  377. }
  378. }
  379. if(dialogid == TWEDITTURFSLOCKED)
  380. {
  381. if(response == 1)
  382. {
  383. new tw = GetPVarInt(playerid, "EditingTurfs");
  384. switch(listitem)
  385. {
  386. case 0: // Lock
  387. {
  388. TurfWars[tw][twLocked] = 1;
  389. SaveTurfWars();
  390. TurfWarsEditTurfsMenu(playerid);
  391. }
  392. case 1: // Unlock
  393. {
  394. TurfWars[tw][twLocked] = 0;
  395. SaveTurfWars();
  396. TurfWarsEditTurfsMenu(playerid);
  397. }
  398. }
  399. }
  400. else
  401. {
  402. TurfWarsEditTurfsMenu(playerid);
  403. }
  404. }
  405. if(dialogid == TWEDITTURFSPERKS)
  406. {
  407. if(response == 1)
  408. {
  409. new tw = GetPVarInt(playerid, "EditingTurfs");
  410. TurfWars[tw][twSpecial] = listitem;
  411. SaveTurfWars();
  412. TurfWarsEditTurfsMenu(playerid);
  413. }
  414. else
  415. {
  416. TurfWarsEditTurfsMenu(playerid);
  417. }
  418. }
  419. if(dialogid == TWEDITFCOLORSSELECTION)
  420. {
  421. if(response == 1)
  422. {
  423. for(new i = 0; i < MAX_FAMILY; i++)
  424. {
  425. if(listitem == i)
  426. {
  427. SetPVarInt(playerid, "EditingFamC", i);
  428. TurfWarsEditFColorsMenu(playerid);
  429. }
  430. }
  431. }
  432. else
  433. {
  434. TurfWarsAdminMenu(playerid);
  435. }
  436. }
  437. if(dialogid == TWEDITFCOLORSMENU)
  438. {
  439. if(response == 1)
  440. {
  441. new fam = GetPVarInt(playerid, "EditingFamC");
  442. if(IsNull(inputtext))
  443. {
  444. TurfWarsEditFColorsMenu(playerid);
  445. return 1;
  446. }
  447. if(strval(inputtext) < 0 || strval(inputtext) > 15)
  448. {
  449. TurfWarsEditFColorsMenu(playerid);
  450. return 1;
  451. }
  452. FamilyInfo[fam][FamilyColor] = strval(inputtext);
  453. SaveFamilies();
  454. TurfWarsEditFColorsSelection(playerid);
  455.  
  456. SyncTurfWarsRadarToAll();
  457. }
  458. else
  459. {
  460. TurfWarsEditFColorsSelection(playerid);
  461. }
  462. }
  463.  
  464. // Timer Name: TurfWarsUpdate()
  465. // TickRate: 1 secs.
  466. Timer:TurfWarsUpdate[1000]()
  467. {
  468. for(new i = 0; i < MAX_TURFS; i++)
  469. {
  470. if(TurfWars[i][twActive] == 1)
  471. {
  472. if(TurfWars[i][twTimeLeft] > 0)
  473. {
  474. TurfWars[i][twTimeLeft]--;
  475. }
  476. else
  477. {
  478. if(TurfWars[i][twAttemptId] != -1)
  479. {
  480. CaptureTurfWarsZone(TurfWars[i][twAttemptId],i);
  481. }
  482. TurfWars[i][twActive] = 0;
  483. foreach(Player, x)
  484. {
  485. if(turfWarsMiniMap[x] == 1)
  486. {
  487. turfWarsMiniMap[x] = 0;
  488. SetPlayerToTeamColor(x);
  489. }
  490. }
  491. }
  492. }
  493. }
  494. }
  495.  
  496.  
  497. __________________________________________________________________________________________________________________________________
  498. Errors/Warnings: C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(15) : error 017: undefined symbol "format"
  499. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(15) : warning 202: number of arguments does not match definition
  500. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(15) : warning 202: number of arguments does not match definition
  501. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(16) : error 017: undefined symbol "ShowPlayerDialog"
  502. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(12) : warning 203: symbol is never used: "playerid"
  503. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(24) : error 017: undefined symbol "TurfWars"
  504. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(24) : warning 215: expression has no effect
  505. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(24) : error 001: expected token: ";", but found "]"
  506. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(24) : error 029: invalid expression, assumed zero
  507. C:\Users\D. Wild\Desktop\Backup\gamemodes\Possibly Working Gang.pwn(24) : fatal error 107: too many error messages on one line
  508.  
  509. Compilation aborted.Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
  510.  
  511.  
  512. 6 Errors.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement