Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 35.06 KB | None | 0 0
  1. // Based in the plugin "Anti Spawn Camp" of Imdawe
  2. #pragma semicolon 1
  3. #include <sourcemod>
  4. #include <sdktools>
  5.  
  6. #define VERSION "2.2.1"
  7.  
  8. new beamColorT[4] = {255, 0, 0, 255};
  9. new beamColorCT[4] = {0, 0, 255, 255};
  10. new beamColorN[4 ]= {255, 255, 0, 255};
  11. new beamColorM[4]={0, 255, 0, 255};
  12. new g_CurrentZoneTeam[MAXPLAYERS+1];
  13. new g_CurrentZoneVis[MAXPLAYERS+1];
  14. new String:g_CurrentZoneName[MAXPLAYERS+1][64];
  15.  
  16. // VARIABLES
  17. new Handle:g_Zones=INVALID_HANDLE;
  18. new g_Editing[MAXPLAYERS+1]={0,...};
  19. new Float:g_Positions[MAXPLAYERS+1][2][3];
  20. new g_ClientSelectedZone[MAXPLAYERS+1]={-1,...};
  21. new bool:FixName[MAXPLAYERS+1];
  22. new g_BeamSprite;
  23. new g_HaloSprite;
  24. new Handle:hOnClientEntry = INVALID_HANDLE;
  25. new Handle:hOnClientLeave = INVALID_HANDLE;
  26.  
  27. enum zonelist
  28. {
  29. String:NamezList[64],
  30. bool:b_this
  31. }
  32.  
  33. new g_zonas[MAXPLAYERS+1][192][zonelist]; // max zones = 192
  34.  
  35. // cvars
  36. new Handle:cvar_mode;
  37. new Handle:cvar_checker;
  38. new Handle:cvar_model;
  39. new Float:checker;
  40. new bool:mode_plugin;
  41. new String:model[192];
  42. new Handle:cvar_timer = INVALID_HANDLE;
  43.  
  44. //scale menu
  45. new Float:g_AvaliableScales[5]={1.0, 5.0, 10.0, 50.0, 100.0};
  46. new g_ClientSelectedScale[MAXPLAYERS+1];
  47. new g_ClientSelectedPoint[MAXPLAYERS+1];
  48.  
  49. // PLUGIN INFO
  50. public Plugin:myinfo =
  51. {
  52. name = "SM DEV Zones",
  53. author = "Franc1sco franug & Root, Special Edit Xines BombZones",
  54. description = "zones plugin",
  55. version = VERSION,
  56. url = ""
  57. };
  58.  
  59. public OnPluginStart()
  60. {
  61. CreateConVar("sm_DevZones", VERSION, "plugin", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD);
  62. cvar_mode = CreateConVar("sm_devzones_mode", "1", "0 = Use checks every X seconds for check if a player join or leave a zone, 1 = hook zone entities with OnStartTouch and OnEndTouch (less CPU consume)");
  63. cvar_checker = CreateConVar("sm_devzones_checker", "5.0", "checks and beambox refreshs per second, low value = more precise but more CPU consume, More hight = less precise but less CPU consume");
  64. cvar_model = CreateConVar("sm_devzones_model", "models/error.mdl", "Use a model for zone entity (IMPORTANT: change this value only on map start)");
  65. g_Zones = CreateArray(256);
  66. RegAdminCmd("sm_zones", Command_CampZones, ADMFLAG_ROOT);
  67. RegConsoleCmd("say",fnHookSay);
  68. HookEventEx("round_start", Event_OnRoundStart);
  69. HookEventEx("teamplay_round_start", Event_OnRoundStart);
  70.  
  71. ReadZones();
  72.  
  73. HookConVarChange(cvar_checker, CVarChange);
  74. HookConVarChange(cvar_mode, CVarChange);
  75. HookConVarChange(cvar_model, CVarChange);
  76. }
  77.  
  78. public CVarChange(Handle:convar_hndl, const String:oldValue[], const String:newValue[])
  79. {
  80. GetCVars();
  81. }
  82.  
  83. // Get new values of cvars if they has being changed
  84. public GetCVars()
  85. {
  86. mode_plugin = GetConVarBool(cvar_mode);
  87. checker = GetConVarFloat(cvar_checker);
  88. GetConVarString(cvar_model, model, 192);
  89.  
  90. if(cvar_timer != INVALID_HANDLE)
  91. {
  92. KillTimer(cvar_timer);
  93. cvar_timer = INVALID_HANDLE;
  94. }
  95. cvar_timer = CreateTimer(checker, BeamBoxAll, _, TIMER_REPEAT);
  96. }
  97.  
  98. public OnClientPostAdminCheck(client)
  99. {
  100. g_ClientSelectedZone[client]=-1;
  101. g_Editing[client]=0;
  102. FixName[client] = false;
  103. }
  104.  
  105. public Action:Event_OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast)
  106. {
  107. if(mode_plugin) RefreshZones();
  108. }
  109.  
  110. CreateBombZoneEntity(Float:fMins[3], Float:fMaxs[3], String:sZoneName[64]) //BombZone Special
  111. {
  112. // Create bomb Zone
  113. new Float:fMiddle[3];
  114. new iBombEnt = -1;
  115. iBombEnt = CreateEntityByName("func_bomb_target");
  116. if(iBombEnt != -1 && IsModelPrecached("models/props/cs_office/vending_machine.mdl"))
  117. {
  118. DispatchKeyValue(iBombEnt, "spawnflags", "64");
  119. Format(sZoneName, sizeof(sZoneName), "sm_devzone %s", sZoneName);
  120. DispatchKeyValue(iBombEnt, "targetname", sZoneName);
  121.  
  122. DispatchSpawn(iBombEnt);
  123. ActivateEntity(iBombEnt);
  124.  
  125. SetEntProp(iBombEnt, Prop_Data, "m_spawnflags", 64);
  126.  
  127. GetMiddleOfABox(fMins, fMaxs, fMiddle);
  128.  
  129. new index = -1;
  130. index = FindEntityByClassname(index, "cs_player_manager");
  131. if(index != -1)
  132. {
  133. if(StrContains(sZoneName, "custom_bomb_target_a") != -1) SetEntPropVector(index, Prop_Send, "m_bombsiteCenterA", fMiddle);
  134. else if(StrContains(sZoneName, "custom_bomb_target_b") != -1) SetEntPropVector(index, Prop_Send, "m_bombsiteCenterB", fMiddle);
  135. }
  136.  
  137. TeleportEntity(iBombEnt, fMiddle, NULL_VECTOR, NULL_VECTOR);
  138. SetEntityModel(iBombEnt, "models/props/cs_office/vending_machine.mdl");
  139.  
  140. // Have the mins always be negative
  141. fMins[0] = fMins[0] - fMiddle[0];
  142. if(fMins[0] > 0.0) fMins[0] *= -1.0;
  143.  
  144. fMins[1] = fMins[1] - fMiddle[1];
  145. if(fMins[1] > 0.0) fMins[1] *= -1.0;
  146.  
  147. fMins[2] = fMins[2] - fMiddle[2];
  148. if(fMins[2] > 0.0) fMins[2] *= -1.0;
  149.  
  150. // And the maxs always be positive
  151. fMaxs[0] = fMaxs[0] - fMiddle[0];
  152. if(fMaxs[0] < 0.0) fMaxs[0] *= -1.0;
  153.  
  154. fMaxs[1] = fMaxs[1] - fMiddle[1];
  155. if(fMaxs[1] < 0.0) fMaxs[1] *= -1.0;
  156.  
  157. fMaxs[2] = fMaxs[2] - fMiddle[2];
  158. if(fMaxs[2] < 0.0) fMaxs[2] *= -1.0;
  159.  
  160.  
  161. SetEntPropVector(iBombEnt, Prop_Send, "m_vecMins", fMins);
  162. SetEntPropVector(iBombEnt, Prop_Send, "m_vecMaxs", fMaxs);
  163. SetEntProp(iBombEnt, Prop_Send, "m_nSolidType", 2);
  164.  
  165. SetEntProp(iBombEnt, Prop_Send, "m_fEffects", GetEntProp(iBombEnt, Prop_Send, "m_fEffects") | 1 << 5);
  166.  
  167. /*
  168. new iEffects = GetEntProp(iBombEnt, Prop_Send, "m_fEffects");
  169. iEffects |= 32;
  170. SetEntProp(iBombEnt, Prop_Send, "m_fEffects", iEffects);
  171. */
  172.  
  173. HookSingleEntityOutput(iBombEnt, "OnStartTouch", EntOut_OnStartTouch);
  174. HookSingleEntityOutput(iBombEnt, "OnEndTouch", EntOut_OnEndTouch);
  175. }
  176. }
  177.  
  178. CreateZoneEntity(Float:fMins[3], Float:fMaxs[3], String:sZoneName[64]) //For Anyother Trigger zone
  179. {
  180. new Float:fMiddle[3];
  181. new iEnt = CreateEntityByName("trigger_multiple");
  182.  
  183. DispatchKeyValue(iEnt, "spawnflags", "64");
  184. Format(sZoneName, sizeof(sZoneName), "sm_devzone %s", sZoneName);
  185. DispatchKeyValue(iEnt, "targetname", sZoneName);
  186. DispatchKeyValue(iEnt, "wait", "0");
  187.  
  188. DispatchSpawn(iEnt);
  189. ActivateEntity(iEnt);
  190. SetEntProp(iEnt, Prop_Data, "m_spawnflags", 64 );
  191.  
  192. GetMiddleOfABox(fMins, fMaxs, fMiddle);
  193.  
  194. TeleportEntity(iEnt, fMiddle, NULL_VECTOR, NULL_VECTOR);
  195. SetEntityModel(iEnt, model);
  196.  
  197. // Have the mins always be negative
  198. fMins[0] = fMins[0] - fMiddle[0];
  199. if(fMins[0] > 0.0)
  200. fMins[0] *= -1.0;
  201. fMins[1] = fMins[1] - fMiddle[1];
  202. if(fMins[1] > 0.0)
  203. fMins[1] *= -1.0;
  204. fMins[2] = fMins[2] - fMiddle[2];
  205. if(fMins[2] > 0.0)
  206. fMins[2] *= -1.0;
  207.  
  208. // And the maxs always be positive
  209. fMaxs[0] = fMaxs[0] - fMiddle[0];
  210. if(fMaxs[0] < 0.0)
  211. fMaxs[0] *= -1.0;
  212. fMaxs[1] = fMaxs[1] - fMiddle[1];
  213. if(fMaxs[1] < 0.0)
  214. fMaxs[1] *= -1.0;
  215. fMaxs[2] = fMaxs[2] - fMiddle[2];
  216. if(fMaxs[2] < 0.0)
  217. fMaxs[2] *= -1.0;
  218.  
  219. SetEntPropVector(iEnt, Prop_Send, "m_vecMins", fMins);
  220. SetEntPropVector(iEnt, Prop_Send, "m_vecMaxs", fMaxs);
  221. SetEntProp(iEnt, Prop_Send, "m_nSolidType", 2);
  222.  
  223. new iEffects = GetEntProp(iEnt, Prop_Send, "m_fEffects");
  224. iEffects |= 32;
  225. SetEntProp(iEnt, Prop_Send, "m_fEffects", iEffects);
  226.  
  227. HookSingleEntityOutput(iEnt, "OnStartTouch", EntOut_OnStartTouch);
  228. HookSingleEntityOutput(iEnt, "OnEndTouch", EntOut_OnEndTouch);
  229. }
  230.  
  231. public EntOut_OnStartTouch(const String:output[], caller, activator, Float:delay)
  232. {
  233. // Ignore dead players
  234. if(activator < 1 || activator > MaxClients || !IsClientInGame(activator) ||!IsPlayerAlive(activator))
  235. return;
  236.  
  237. decl String:sTargetName[256];
  238. GetEntPropString(caller, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
  239. ReplaceString(sTargetName, sizeof(sTargetName), "sm_devzone ", "");
  240.  
  241. // Start Touch
  242. Call_StartForward(hOnClientEntry);
  243. Call_PushCell(activator);
  244. Call_PushString(sTargetName);
  245. Call_Finish();
  246. }
  247.  
  248. public EntOut_OnEndTouch(const String:output[], caller, activator, Float:delay)
  249. {
  250. // Ignore dead players
  251. if(activator < 1 || activator > MaxClients || !IsClientInGame(activator) || !IsPlayerAlive(activator))
  252. return;
  253.  
  254. decl String:sTargetName[256];
  255. GetEntPropString(caller, Prop_Data, "m_iName", sTargetName, sizeof(sTargetName));
  256. ReplaceString(sTargetName, sizeof(sTargetName), "sm_devzone ", "");
  257.  
  258. // End Touch
  259. Call_StartForward(hOnClientLeave);
  260. Call_PushCell(activator);
  261. Call_PushString(sTargetName);
  262. Call_Finish();
  263. }
  264.  
  265. public OnMapStart()
  266. {
  267. OnConfigsExecuted();
  268. }
  269.  
  270. public OnConfigsExecuted()
  271. {
  272. GetCVars();
  273. g_BeamSprite = PrecacheModel("sprites/laserbeam.vmt");
  274. g_HaloSprite = PrecacheModel("materials/sprites/halo.vmt");
  275. PrecacheModel("models/props/cs_office/vending_machine.mdl", true); //For BombZone Model
  276. PrecacheModel(model);
  277. ReadZones();
  278. }
  279.  
  280. public OnMapEnd()
  281. {
  282. SaveZones(0);
  283. }
  284.  
  285. public Action:OnPlayerRunCmd(client, &buttons, &impulse, Float:vel[3], Float:angles[3], &weapon)
  286. {
  287. BeamBox_OnPlayerRunCmd(client);
  288. }
  289.  
  290. public Action:Command_CampZones(client, args)
  291. {
  292. ZoneMenu(client);
  293. }
  294.  
  295. public getZoneTeamColor(team, color[4])
  296. {
  297. switch(team)
  298. {
  299. case 1:
  300. {
  301. color=beamColorM;
  302. }
  303. case 2:
  304. {
  305. color=beamColorT;
  306. }
  307. case 3:
  308. {
  309. color=beamColorCT;
  310. }
  311. default:
  312. {
  313. color=beamColorN;
  314. }
  315. }
  316. // Get zone team -> get zone color
  317. }
  318.  
  319. public ReadZones()
  320. {
  321. ClearArray(g_Zones);
  322. new String:Path[512];
  323. BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones");
  324. if(!DirExists(Path))
  325. CreateDirectory(Path, 0777);
  326.  
  327. new String:map[64];
  328. GetCurrentMap(map, sizeof(map));
  329. BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones/%s.zones.txt", map);
  330. if(!FileExists(Path))
  331. {
  332. new Handle:kv = CreateKeyValues("Zones");
  333. KeyValuesToFile(kv, Path);
  334. }
  335.  
  336. new Handle:kv = CreateKeyValues("Zones");
  337. FileToKeyValues(kv, Path);
  338. if (!KvGotoFirstSubKey(kv))
  339. {
  340. PrintToServer("[ERROR] Config file is corrupted: %s", Path);
  341. return;
  342. }
  343. decl Float:pos1[3], Float:pos2[3], String:namey[64];
  344. do
  345. {
  346. KvGetVector(kv, "cordinate_a", pos1);
  347. KvGetVector(kv, "cordinate_b", pos2);
  348. KvGetString(kv, "name", namey, 64);
  349. new Handle:trie = CreateTrie();
  350. SetTrieArray(trie, "corda", pos1, 3);
  351. SetTrieArray(trie, "cordb", pos2, 3);
  352. SetTrieValue(trie, "team", KvGetNum(kv, "team", 0));
  353. SetTrieValue(trie, "vis", KvGetNum(kv, "vis", 0));
  354. SetTrieString(trie, "name", namey);
  355. PushArrayCell(g_Zones, trie);
  356. }while(KvGotoNextKey(kv));
  357. CloseHandle(kv);
  358. }
  359.  
  360. public SaveZones(client)
  361. {
  362. new String:Path[512];
  363. new String:map[64];
  364. GetCurrentMap(map, sizeof(map));
  365. BuildPath(Path_SM, Path, sizeof(Path), "configs/dev_zones/%s.zones.txt", map);
  366. new Handle:file = OpenFile(Path, "w+");
  367. CloseHandle(file);
  368. new Float:pos1[3], Float:pos2[3], String:SectName[64], Team, Vis,String:namey[64];
  369. new size=GetArraySize(g_Zones);
  370. new Handle:kv = CreateKeyValues("Zones");
  371. for(new i=0;i<size;++i)
  372. {
  373. IntToString(i, SectName, sizeof(SectName));
  374. new Handle:trie = GetArrayCell(g_Zones, i);
  375. GetTrieArray(trie, "corda", pos1, sizeof(pos1));
  376. GetTrieArray(trie, "cordb", pos2, sizeof(pos2));
  377. GetTrieValue(trie, "team", Team);
  378. GetTrieValue(trie, "vis", Vis);
  379. GetTrieString(trie, "name", namey, 64);
  380.  
  381. KvJumpToKey(kv, SectName, true);
  382. KvSetString(kv, "name", namey);
  383. KvSetVector(kv, "cordinate_a", pos1);
  384. KvSetVector(kv, "cordinate_b", pos2);
  385. KvSetNum(kv, "vis", Vis);
  386. KvSetNum(kv, "team", Team);
  387. KvGoBack(kv);
  388. }
  389. KeyValuesToFile(kv, Path);
  390. CloseHandle(kv);
  391. if(client!=0)
  392. PrintToChat(client, "All zones are saved in file.");
  393. }
  394.  
  395. public bool:TraceRayDontHitSelf(entity, mask, any:data)
  396. {
  397. if(entity == data)
  398. return false;
  399. return true;
  400. }
  401.  
  402. public Action:fnHookSay(client,args)
  403. {
  404. if(!FixName[client]) return;
  405.  
  406. decl String:sArgs[192];
  407. GetCmdArgString(sArgs,sizeof(sArgs));
  408.  
  409. StripQuotes(sArgs);
  410.  
  411. ReplaceString(sArgs, 192, "'", ".");
  412. ReplaceString(sArgs, 192, "<", ".");
  413. if(strlen(sArgs) > 45)
  414. {
  415. PrintToChat(client, "the name is too long, try other name");
  416. return;
  417. }
  418. if(StrEqual(sArgs, "!cancel"))
  419. {
  420. PrintToChat(client, "Set name action canceled");
  421. EditorMenu(client);
  422. return;
  423. }
  424. decl String:ZoneId[64];
  425. new size = GetArraySize(g_Zones);
  426. for(new i=0;i<size;++i)
  427. {
  428. new Handle:trie = GetArrayCell(g_Zones, i);
  429. GetTrieString(trie, "name", ZoneId, 64);
  430. if(StrEqual(ZoneId, sArgs))
  431. {
  432. PrintToChat(client, "The name already exist, write other name");
  433. return;
  434. }
  435. }
  436.  
  437. Format(g_CurrentZoneName[client], 64, sArgs);
  438. PrintToChat(client, "Zone name set to %s",sArgs);
  439. FixName[client] = false;
  440. EditorMenu(client);
  441. }
  442.  
  443. public APLRes:AskPluginLoad2(Handle:myself, bool:late, String:error[], err_max)
  444. {
  445. hOnClientEntry = CreateGlobalForward("Zone_OnClientEntry", ET_Ignore, Param_Cell, Param_String);
  446. hOnClientLeave = CreateGlobalForward("Zone_OnClientLeave", ET_Ignore, Param_Cell, Param_String);
  447. CreateNative("Zone_IsClientInZone", Native_InZone);
  448. CreateNative("Zone_GetZonePosition", Native_Teleport);
  449. CreateNative("Zone_CheckIfZoneExists", Native_ZoneExist);
  450.  
  451. return APLRes_Success;
  452. }
  453.  
  454. public Native_InZone(Handle:plugin, argc)
  455. {
  456. decl String:name[64];
  457. GetNativeString(2, name, 64);
  458. new client = GetNativeCell(1);
  459. new bool:igual = GetNativeCell(3);
  460. new bool:sensitive = GetNativeCell(4);
  461.  
  462. new size = GetArraySize(g_Zones);
  463. for(new i=0;i<size;++i)
  464. {
  465. if(igual)
  466. {
  467. if(StrEqual(g_zonas[client][i][NamezList], name, sensitive) && g_zonas[client][i][b_this])
  468. return true;
  469. }
  470. else
  471. {
  472. if(StrContains(g_zonas[client][i][NamezList], name, sensitive) == 0 && g_zonas[client][i][b_this])
  473. return true;
  474. }
  475. }
  476. return false;
  477. }
  478.  
  479. public Native_Teleport(Handle:plugin, argc)
  480. {
  481. decl String:name[64], String:namezone[64], Float:posA[3], Float:posB[3];
  482. GetNativeString(1, name, 64);
  483. new bool:sensitive = GetNativeCell(2);
  484.  
  485. new size = GetArraySize(g_Zones);
  486. if(size>0)
  487. {
  488. for(new i=0;i<size;++i)
  489. {
  490. GetTrieString(GetArrayCell(g_Zones, i), "name", namezone, 64);
  491. if(StrEqual(name, namezone, sensitive))
  492. {
  493. GetTrieArray(GetArrayCell(g_Zones, i), "corda", posA, sizeof(posA));
  494. GetTrieArray(GetArrayCell(g_Zones, i), "cordb", posB, sizeof(posB));
  495. new Float:ZonePos[3];
  496. AddVectors(posA, posB, ZonePos);
  497. ZonePos[0]=FloatDiv(ZonePos[0], 2.0);
  498. ZonePos[1]=FloatDiv(ZonePos[1], 2.0);
  499. ZonePos[2]=FloatDiv(ZonePos[2], 2.0);
  500. SetNativeArray(3, ZonePos, 3);
  501. return true;
  502. }
  503. }
  504. }
  505. return false;
  506. }
  507.  
  508. public Native_ZoneExist(Handle:plugin, argc)
  509. {
  510. decl String:name[64], String:namezone[64];
  511. GetNativeString(1, name, 64);
  512. new bool:igual = GetNativeCell(2);
  513. new bool:sensitive = GetNativeCell(3);
  514.  
  515. new size = GetArraySize(g_Zones);
  516. if(size>0)
  517. {
  518. for(new i=0;i<size;++i)
  519. {
  520. GetTrieString(GetArrayCell(g_Zones, i), "name", namezone, 64);
  521. if(igual) if(StrEqual(name, namezone, sensitive)) return true;
  522. else if(StrContains(name, namezone, sensitive) == 0) return true;
  523. }
  524. }
  525. return false;
  526. }
  527.  
  528. // beambox.sp
  529.  
  530. public DrawBeamBox(client)
  531. {
  532. new zColor[4];
  533. getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
  534. TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 1.0, 5.0, 5.0, 2, 1.0, zColor, 0);
  535. CreateTimer(1.0, BeamBox, client, TIMER_REPEAT);
  536. }
  537.  
  538. public Action:BeamBox(Handle:timer, any:client)
  539. {
  540. if(IsClientInGame(client))
  541. {
  542. if(g_Editing[client]==2)
  543. {
  544. new zColor[4];
  545. getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
  546. TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 1.0, 5.0, 5.0, 2, 1.0, zColor, 0);
  547. return Plugin_Continue;
  548. }
  549. }
  550. return Plugin_Stop;
  551. }
  552.  
  553. public Action:BeamBoxAll(Handle:timer, any:data)
  554. {
  555. new size = GetArraySize(g_Zones);
  556. new Float:posA[3], Float:posB[3], zColor[4], Team, Vis, String:namey[64];
  557. for(new i=0;i<size;++i)
  558. {
  559. new Handle:trie = GetArrayCell(g_Zones, i);
  560. GetTrieArray(trie, "corda", posA, sizeof(posA));
  561. GetTrieArray(trie, "cordb", posB, sizeof(posB));
  562. GetTrieValue(trie, "team", Team);
  563. GetTrieValue(trie, "vis", Vis);
  564. GetTrieString(trie, "name", namey, 64);
  565. for (new p = 1; p <= MaxClients; p++)
  566. {
  567. if(IsClientInGame(p))
  568. {
  569. if(g_ClientSelectedZone[p]!=i && (Vis==1 || GetClientTeam(p)==Vis))
  570. {
  571. getZoneTeamColor(Team, zColor);
  572. if(checker > 15.0) checker = 15.0; //prevent time overload
  573. TE_SendBeamBoxToClient(p, posA, posB, g_BeamSprite, g_HaloSprite, 0, 30, checker, 5.0, 5.0, 2, 1.0, zColor, 0);
  574. }
  575.  
  576. if(mode_plugin) continue;
  577.  
  578. if(IsPlayerAlive(p))
  579. {
  580. if(IsbetweenRect(NULL_VECTOR, posA, posB, p))
  581. {
  582. if(!g_zonas[p][i][b_this])
  583. {
  584. // Enter Touch
  585. g_zonas[p][i][b_this] = true;
  586. Format(g_zonas[p][i][NamezList], 64, namey);
  587. Call_StartForward(hOnClientEntry);
  588. Call_PushCell(p);
  589. Call_PushString(g_zonas[p][i][NamezList]);
  590. Call_Finish();
  591. }
  592. }
  593. else
  594. {
  595. if(g_zonas[p][i][b_this])
  596. {
  597. // End Touch
  598. g_zonas[p][i][b_this] = false;
  599. Format(g_zonas[p][i][NamezList], 64, namey);
  600. Call_StartForward(hOnClientLeave);
  601. Call_PushCell(p);
  602. Call_PushString(g_zonas[p][i][NamezList]);
  603. Call_Finish();
  604. }
  605. }
  606. }
  607. }
  608. }
  609. }
  610. return Plugin_Continue;
  611. }
  612.  
  613. public BeamBox_OnPlayerRunCmd(client)
  614. {
  615. if(g_Editing[client]==1 || g_Editing[client]==3)
  616. {
  617. new Float:pos[3], Float:ang[3], zColor[4];
  618. getZoneTeamColor(g_CurrentZoneTeam[client], zColor);
  619. if(g_Editing[client]==1)
  620. {
  621. GetClientEyePosition(client, pos);
  622. GetClientEyeAngles(client, ang);
  623. TR_TraceRayFilter(pos, ang, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitSelf, client);
  624. TR_GetEndPosition(g_Positions[client][1]);
  625. }
  626. TE_SendBeamBoxToClient(client, g_Positions[client][1], g_Positions[client][0], g_BeamSprite, g_HaloSprite, 0, 30, 0.1, 5.0, 5.0, 2, 1.0, zColor, 0);
  627. }
  628. }
  629.  
  630. stock TE_SendBeamBoxToClient(client, Float:uppercorner[3], const Float:bottomcorner[3], ModelIndex, HaloIndex, StartFrame, FrameRate, Float:Life, Float:Width, Float:EndWidth, FadeLength, Float:Amplitude, const Color[4], Speed)
  631. {
  632. // Create the additional corners of the box
  633. new Float:tc1[3];
  634. AddVectors(tc1, uppercorner, tc1);
  635. tc1[0] = bottomcorner[0];
  636.  
  637. new Float:tc2[3];
  638. AddVectors(tc2, uppercorner, tc2);
  639. tc2[1] = bottomcorner[1];
  640.  
  641. new Float:tc3[3];
  642. AddVectors(tc3, uppercorner, tc3);
  643. tc3[2] = bottomcorner[2];
  644.  
  645. new Float:tc4[3];
  646. AddVectors(tc4, bottomcorner, tc4);
  647. tc4[0] = uppercorner[0];
  648.  
  649. new Float:tc5[3];
  650. AddVectors(tc5, bottomcorner, tc5);
  651. tc5[1] = uppercorner[1];
  652.  
  653. new Float:tc6[3];
  654. AddVectors(tc6, bottomcorner, tc6);
  655. tc6[2] = uppercorner[2];
  656.  
  657. // Draw all the edges
  658. TE_SetupBeamPoints(uppercorner, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  659. TE_SendToClient(client);
  660. TE_SetupBeamPoints(uppercorner, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  661. TE_SendToClient(client);
  662. TE_SetupBeamPoints(uppercorner, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  663. TE_SendToClient(client);
  664. TE_SetupBeamPoints(tc6, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  665. TE_SendToClient(client);
  666. TE_SetupBeamPoints(tc6, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  667. TE_SendToClient(client);
  668. TE_SetupBeamPoints(tc6, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  669. TE_SendToClient(client);
  670. TE_SetupBeamPoints(tc4, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  671. TE_SendToClient(client);
  672. TE_SetupBeamPoints(tc5, bottomcorner, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  673. TE_SendToClient(client);
  674. TE_SetupBeamPoints(tc5, tc1, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  675. TE_SendToClient(client);
  676. TE_SetupBeamPoints(tc5, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  677. TE_SendToClient(client);
  678. TE_SetupBeamPoints(tc4, tc3, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  679. TE_SendToClient(client);
  680. TE_SetupBeamPoints(tc4, tc2, ModelIndex, HaloIndex, StartFrame, FrameRate, Life, Width, EndWidth, FadeLength, Amplitude, Color, Speed);
  681. TE_SendToClient(client);
  682. }
  683.  
  684. bool:IsbetweenRect(Float:Pos[3], Float:Corner1[3], Float:Corner2[3], client=0)
  685. {
  686. decl Float:Entity[3];
  687. decl Float:field1[2];
  688. decl Float:field2[2];
  689. decl Float:field3[2];
  690.  
  691. if (!client)
  692. {
  693. Entity = Pos;
  694. }
  695. else
  696. GetClientAbsOrigin(client, Entity);
  697.  
  698. Entity[2] = FloatAdd(Entity[2], 25.0);
  699.  
  700. // Sort Floats...
  701. if (FloatCompare(Corner1[0], Corner2[0]) == -1)
  702. {
  703. field1[0] = Corner1[0];
  704. field1[1] = Corner2[0];
  705. }
  706. else
  707. {
  708. field1[0] = Corner2[0];
  709. field1[1] = Corner1[0];
  710. }
  711. if (FloatCompare(Corner1[1], Corner2[1]) == -1)
  712. {
  713. field2[0] = Corner1[1];
  714. field2[1] = Corner2[1];
  715. }
  716. else
  717. {
  718. field2[0] = Corner2[1];
  719. field2[1] = Corner1[1];
  720. }
  721. if (FloatCompare(Corner1[2], Corner2[2]) == -1)
  722. {
  723. field3[0] = Corner1[2];
  724. field3[1] = Corner2[2];
  725. }
  726. else
  727. {
  728. field3[0] = Corner2[2];
  729. field3[1] = Corner1[2];
  730. }
  731.  
  732. // Check the Vectors ...
  733.  
  734. if (Entity[0] < field1[0] || Entity[0] > field1[1])
  735. {
  736. //PrintToChat(client, "first");
  737. return false;
  738. }
  739. if (Entity[1] < field2[0] || Entity[1] > field2[1])
  740. {
  741. //PrintToChat(client, "second");
  742. return false;
  743. }
  744. if (Entity[2] < field3[0] || Entity[2] > field3[1])
  745. {
  746. //PrintToChat(client, "third");
  747. return false;
  748. }
  749.  
  750. return true;
  751. }
  752.  
  753. // menus.sp
  754.  
  755. public ZoneMenu(client)
  756. {
  757. g_ClientSelectedZone[client]=-1;
  758. g_Editing[client]=0;
  759. new Handle:Menu2 = CreateMenu(Handle_ZoneMenu);
  760. SetMenuTitle(Menu2, "Zones");
  761. AddMenuItem(Menu2, "", "Create Zone");
  762. AddMenuItem(Menu2, "", "Edit Zones");
  763. AddMenuItem(Menu2, "", "Save Zones");
  764. AddMenuItem(Menu2, "", "Reload Zones");
  765. AddMenuItem(Menu2, "", "Clear Zones");
  766. SetMenuExitBackButton(Menu2, true);
  767. DisplayMenu(Menu2, client, MENU_TIME_FOREVER);
  768. }
  769.  
  770. public Handle_ZoneMenu(Handle:tMenu, MenuAction:action, client, item)
  771. {
  772. switch(action)
  773. {
  774. case MenuAction_Select:
  775. {
  776. switch(item)
  777. {
  778. case 0:
  779. {
  780. EditorMenu(client);
  781. }
  782. case 1:
  783. {
  784. ListZones(client, MenuHandler_ZoneModify);
  785. }
  786. case 2:
  787. {
  788. SaveZones(client);
  789. ZoneMenu(client);
  790. }
  791. case 3:
  792. {
  793. ReadZones();
  794. PrintToChat(client, "Zones are reloaded");
  795. ZoneMenu(client);
  796. }
  797. case 4:
  798. {
  799. ClearZonesMenu(client);
  800. }
  801. }
  802. }
  803. case MenuAction_End:
  804. {
  805. CloseHandle(tMenu);
  806. }
  807. }
  808. }
  809.  
  810. public ListZones(client, MenuHandler:handler)
  811. {
  812. new Handle:Menu2 = CreateMenu(handler);
  813. SetMenuTitle(Menu2, "Avaliable Zones");
  814.  
  815. decl String:ZoneName[256], String:ZoneId[64], String:Id[64],TeamId;
  816. new size = GetArraySize(g_Zones);
  817. if(size>0)
  818. {
  819. for(new i=0;i<size;++i)
  820. {
  821. GetTrieValue(GetArrayCell(g_Zones, i), "team", TeamId);
  822. GetTrieString(GetArrayCell(g_Zones, i), "name", ZoneId, 64);
  823. IntToString(i, Id, sizeof(Id));
  824. Format(ZoneName, sizeof(ZoneName), ZoneId);
  825. AddMenuItem(Menu2, Id, ZoneId);
  826. }
  827. }else{
  828. AddMenuItem(Menu2, "", "No zones are avaliable", ITEMDRAW_DISABLED);
  829. }
  830. SetMenuExitBackButton(Menu2, true);
  831. DisplayMenu(Menu2, client, MENU_TIME_FOREVER);
  832. }
  833.  
  834. public EditorMenu(client)
  835. {
  836. if(g_Editing[client]==3)
  837. {
  838. DrawBeamBox(client);
  839. g_Editing[client]=2;
  840. }
  841. new Handle:Menu2 = CreateMenu(MenuHandler_Editor);
  842. if(g_ClientSelectedZone[client] != -1)
  843. SetMenuTitle(Menu2, "Zone Editor (MODIFY)");
  844. else
  845. SetMenuTitle(Menu2, "Zone Editor");
  846.  
  847. if(g_Editing[client]==0)
  848. AddMenuItem(Menu2, "", "Start Zone");
  849. else
  850. AddMenuItem(Menu2, "", "Restart Zone");
  851.  
  852. if(g_Editing[client]>0)
  853. {
  854. AddMenuItem(Menu2, "", "Set Zone name");
  855. if(g_Editing[client]==2)
  856. AddMenuItem(Menu2, "", "Continue Editing");
  857. else
  858. AddMenuItem(Menu2, "", "Pause Editing");
  859. AddMenuItem(Menu2, "", "Cancel Zone");
  860. AddMenuItem(Menu2, "", "Save Zone");
  861. switch(g_CurrentZoneTeam[client])
  862. {
  863. case 0:
  864. {
  865. AddMenuItem(Menu2, "", "Set Zone Yellow");
  866. }
  867. case 1:
  868. {
  869. AddMenuItem(Menu2, "", "Set Zone Green");
  870. }
  871. case 2:
  872. {
  873. AddMenuItem(Menu2, "", "Set Zone Red");
  874. }
  875. case 3:
  876. {
  877. AddMenuItem(Menu2, "", "Set Zone Blue");
  878. }
  879. }
  880. AddMenuItem(Menu2, "", "Go to Zone");
  881. AddMenuItem(Menu2, "", "Strech Zone");
  882. switch(g_CurrentZoneVis[client])
  883. {
  884. case 0:
  885. {
  886. AddMenuItem(Menu2, "", "Visibility: No One");
  887. }
  888. case 1:
  889. {
  890. AddMenuItem(Menu2, "", "Visibility: All");
  891. }
  892. case 2:
  893. {
  894. AddMenuItem(Menu2, "", "Visibility: T");
  895. }
  896. case 3:
  897. {
  898. AddMenuItem(Menu2, "", "Visibility: CT");
  899. }
  900. }
  901. }
  902. SetMenuExitBackButton(Menu2, true);
  903. DisplayMenu(Menu2, client, MENU_TIME_FOREVER);
  904. }
  905.  
  906. public MenuHandler_Editor(Handle:tMenu, MenuAction:action, client, item)
  907. {
  908. switch(action)
  909. {
  910. case MenuAction_Select:
  911. {
  912. switch(item)
  913. {
  914. case 0:
  915. {
  916. // Start
  917. g_Editing[client]=1;
  918. new Float:pos[3], Float:ang[3];
  919. GetClientEyePosition(client, pos);
  920. GetClientEyeAngles(client, ang);
  921. TR_TraceRayFilter(pos, ang, MASK_PLAYERSOLID, RayType_Infinite, TraceRayDontHitSelf, client);
  922. TR_GetEndPosition(g_Positions[client][0]);
  923. EditorMenu(client);
  924. }
  925. case 1:
  926. {
  927. PrintToChat(client, "Write in chat the name for the zone\nType !cancel for cancel the operation");
  928. FixName[client] = true;
  929. }
  930. case 2:
  931. {
  932. // Pause
  933. if(g_Editing[client]==2)
  934. {
  935. g_Editing[client]=1;
  936. }else{
  937. DrawBeamBox(client);
  938. g_Editing[client]=2;
  939. }
  940. EditorMenu(client);
  941. }
  942. case 3:
  943. {
  944. // Delete
  945. if(g_ClientSelectedZone[client] != -1)
  946. RemoveFromArray(g_Zones, g_ClientSelectedZone[client]);
  947. g_Editing[client]=0;
  948. g_ClientSelectedZone[client]=-1;
  949. ZoneMenu(client);
  950. if(mode_plugin) RefreshZones();
  951. }
  952. case 4:
  953. {
  954. // Save
  955. g_Editing[client]=2;
  956. new Handle:trie = CreateTrie();
  957. SetTrieArray(trie, "corda", g_Positions[client][0], 3);
  958. SetTrieArray(trie, "cordb", g_Positions[client][1], 3);
  959. SetTrieValue(trie, "team", g_CurrentZoneTeam[client]);
  960. SetTrieValue(trie, "vis", g_CurrentZoneVis[client]);
  961. if(g_ClientSelectedZone[client] != -1)
  962. {
  963. SetTrieString(trie, "name", g_CurrentZoneName[client]);
  964. SetArrayCell(g_Zones, g_ClientSelectedZone[client], trie);
  965.  
  966. }
  967. else
  968. {
  969. Format(g_CurrentZoneName[client], 64, "Zone %i", GetArraySize(g_Zones)+1);
  970. SetTrieString(trie, "name", g_CurrentZoneName[client]);
  971. PushArrayCell(g_Zones, trie);
  972. }
  973. PrintToChat(client, "Zone saved");
  974. g_CurrentZoneTeam[client]=0;
  975. g_CurrentZoneVis[client]=0;
  976. g_Editing[client]=0;
  977. ZoneMenu(client);
  978. if(mode_plugin) RefreshZones();
  979. // Save zone
  980. }
  981. case 5:
  982. {
  983. // Set team
  984. ++g_CurrentZoneTeam[client];
  985. switch(g_CurrentZoneTeam[client])
  986. {
  987. case 1:
  988. {
  989. PrintToChat(client, "The zone is now Green");
  990. }
  991. case 2:
  992. {
  993. PrintToChat(client, "The zone is now Red");
  994. }
  995. case 3:
  996. {
  997. PrintToChat(client, "The zone is now Blue");
  998. }
  999. case 4:
  1000. {
  1001. g_CurrentZoneTeam[client]=0;
  1002. PrintToChat(client, "The zone is now Yellow");
  1003. }
  1004. }
  1005. EditorMenu(client);
  1006. }
  1007. case 6:
  1008. {
  1009. // Teleport
  1010. new Float:ZonePos[3];
  1011. AddVectors(g_Positions[client][0], g_Positions[client][1], ZonePos);
  1012. ZonePos[0]=FloatDiv(ZonePos[0], 2.0);
  1013. ZonePos[1]=FloatDiv(ZonePos[1], 2.0);
  1014. ZonePos[2]=FloatDiv(ZonePos[2], 2.0);
  1015. TeleportEntity(client, ZonePos, NULL_VECTOR, NULL_VECTOR);
  1016. EditorMenu(client);
  1017. PrintToChat(client, "You are teleported to the zone");
  1018. }
  1019. case 7:
  1020. {
  1021. // Scaling
  1022. ScaleMenu(client);
  1023. }
  1024. case 8:
  1025. {
  1026. ++g_CurrentZoneVis[client];
  1027. switch(g_CurrentZoneVis[client])
  1028. {
  1029. case 1:
  1030. {
  1031. PrintToChat(client, "The zone is visible for ALL");
  1032. }
  1033. case 2:
  1034. {
  1035. PrintToChat(client, "The zone is visible for Terror");
  1036. }
  1037. case 3:
  1038. {
  1039. PrintToChat(client, "The zone is visible for Counter-Terrors");
  1040. }
  1041. case 4:
  1042. {
  1043. g_CurrentZoneVis[client]=0;
  1044. PrintToChat(client, "The zone is invisible");
  1045. }
  1046. }
  1047. EditorMenu(client);
  1048. }
  1049. }
  1050. }
  1051. case MenuAction_Cancel:
  1052. {
  1053. ZoneMenu(client);
  1054. }
  1055. case MenuAction_End:
  1056. {
  1057. CloseHandle(tMenu);
  1058. }
  1059. }
  1060. }
  1061.  
  1062. public ScaleMenu(client)
  1063. {
  1064. g_Editing[client]=3;
  1065. new Handle:Menu2 = CreateMenu(MenuHandler_Scale);
  1066. SetMenuTitle(Menu2, "Strech Zone");
  1067. if(g_ClientSelectedPoint[client]==1)
  1068. AddMenuItem(Menu2, "", "Point B");
  1069. else
  1070. AddMenuItem(Menu2, "", "Point A");
  1071. AddMenuItem(Menu2, "", "+ Width");
  1072. AddMenuItem(Menu2, "", "- Width");
  1073. AddMenuItem(Menu2, "", "+ Height");
  1074. AddMenuItem(Menu2, "", "- Height");
  1075. AddMenuItem(Menu2, "", "+ Length");
  1076. AddMenuItem(Menu2, "", "- Length");
  1077. decl String:ScaleSize[128];
  1078. Format(ScaleSize, sizeof(ScaleSize), "Scale Size %f", g_AvaliableScales[g_ClientSelectedScale[client]]);
  1079. AddMenuItem(Menu2, "", ScaleSize);
  1080. SetMenuExitBackButton(Menu2, true);
  1081. DisplayMenu(Menu2, client, MENU_TIME_FOREVER);
  1082. }
  1083.  
  1084. public MenuHandler_Scale(Handle:tMenu, MenuAction:action, client, item)
  1085. {
  1086. switch(action)
  1087. {
  1088. case MenuAction_Select:
  1089. {
  1090. switch(item)
  1091. {
  1092. case 0:
  1093. {
  1094. if(g_ClientSelectedPoint[client]==1)
  1095. g_ClientSelectedPoint[client]=0;
  1096. else
  1097. g_ClientSelectedPoint[client]=1;
  1098. }
  1099. case 1:
  1100. {
  1101. g_Positions[client][g_ClientSelectedPoint[client]][0]=FloatAdd(g_Positions[client][g_ClientSelectedPoint[client]][0], g_AvaliableScales[g_ClientSelectedScale[client]]);
  1102. }
  1103. case 2:
  1104. {
  1105. g_Positions[client][g_ClientSelectedPoint[client]][0]=FloatSub(g_Positions[client][g_ClientSelectedPoint[client]][0], g_AvaliableScales[g_ClientSelectedScale[client]]);
  1106. }
  1107. case 3:
  1108. {
  1109. g_Positions[client][g_ClientSelectedPoint[client]][1]=FloatAdd(g_Positions[client][g_ClientSelectedPoint[client]][1], g_AvaliableScales[g_ClientSelectedScale[client]]);
  1110. }
  1111. case 4:
  1112. {
  1113. g_Positions[client][g_ClientSelectedPoint[client]][1]=FloatSub(g_Positions[client][g_ClientSelectedPoint[client]][1], g_AvaliableScales[g_ClientSelectedScale[client]]);
  1114. }
  1115. case 5:
  1116. {
  1117. g_Positions[client][g_ClientSelectedPoint[client]][2]=FloatAdd(g_Positions[client][g_ClientSelectedPoint[client]][2], g_AvaliableScales[g_ClientSelectedScale[client]]);
  1118. }
  1119. case 6:
  1120. {
  1121. g_Positions[client][g_ClientSelectedPoint[client]][2]=FloatSub(g_Positions[client][g_ClientSelectedPoint[client]][2], g_AvaliableScales[g_ClientSelectedScale[client]]);
  1122. }
  1123. case 7:
  1124. {
  1125. ++g_ClientSelectedScale[client];
  1126. if(g_ClientSelectedScale[client]==5)
  1127. g_ClientSelectedScale[client]=0;
  1128. }
  1129. }
  1130. ScaleMenu(client);
  1131. }
  1132. case MenuAction_Cancel:
  1133. {
  1134. EditorMenu(client);
  1135. }
  1136. case MenuAction_End:
  1137. {
  1138. CloseHandle(tMenu);
  1139. }
  1140. }
  1141. }
  1142.  
  1143. public MenuHandler_ZoneModify(Handle:tMenu, MenuAction:action, client, item)
  1144. {
  1145. switch(action)
  1146. {
  1147. case MenuAction_Select:
  1148. {
  1149. new String:aID[64];
  1150. GetMenuItem(tMenu, item, aID, sizeof(aID));
  1151. g_ClientSelectedZone[client] = StringToInt(aID);
  1152. DrawBeamBox(client);
  1153. g_Editing[client]=2;
  1154. if(g_ClientSelectedZone[client]!= -1)
  1155. GetClientSelectedZone(client, g_Positions[client], g_CurrentZoneTeam[client], g_CurrentZoneVis[client]);
  1156. EditorMenu(client);
  1157. }
  1158. case MenuAction_Cancel:
  1159. {
  1160. ZoneMenu(client);
  1161. }
  1162. case MenuAction_End:
  1163. {
  1164. CloseHandle(tMenu);
  1165. }
  1166. }
  1167. }
  1168.  
  1169. public GetClientSelectedZone(client, Float:poses[2][3], &team, &vis)
  1170. {
  1171. new Float:posA[3], Float:posB[3];
  1172. if(g_ClientSelectedZone[client]!=-1)
  1173. {
  1174. new Handle:trie = GetArrayCell(g_Zones, g_ClientSelectedZone[client]);
  1175. GetTrieArray(trie, "corda", posA, sizeof(posA));
  1176. GetTrieArray(trie, "cordb", posB, sizeof(posB));
  1177. GetTrieValue(trie, "team", team);
  1178. GetTrieValue(trie, "vis", vis);
  1179. GetTrieString(trie, "name", g_CurrentZoneName[client], 64);
  1180. poses[0]=posA;
  1181. poses[1]=posB;
  1182. }
  1183. }
  1184.  
  1185. public ClearZonesMenu(client)
  1186. {
  1187. new Handle:Menu2 = CreateMenu(MenuHandler_ClearZones);
  1188. SetMenuTitle(Menu2, "Are you sure, you want to clear all zones on this map?");
  1189. AddMenuItem(Menu2, "","NO GO BACK!");
  1190. AddMenuItem(Menu2, "","NO GO BACK!");
  1191. AddMenuItem(Menu2, "","YES! DO IT!");
  1192. DisplayMenu(Menu2, client, 20);
  1193. }
  1194.  
  1195. public MenuHandler_ClearZones(Handle:tMenu, MenuAction:action, client, item)
  1196. {
  1197. switch(action)
  1198. {
  1199. case MenuAction_Select:
  1200. {
  1201. if(item==2)
  1202. {
  1203. ClearArray(g_Zones);
  1204. PrintToChat(client, "Zones cleared");
  1205. RemoveZones();
  1206. }
  1207. ZoneMenu(client);
  1208. }
  1209. case MenuAction_End:
  1210. {
  1211. CloseHandle(tMenu);
  1212. }
  1213. }
  1214. }
  1215.  
  1216. stock GetMiddleOfABox(const Float:vec1[3], const Float:vec2[3], Float:buffer[3])
  1217. {
  1218. new Float:mid[3];
  1219. MakeVectorFromPoints(vec1, vec2, mid);
  1220. mid[0] = mid[0] / 2.0;
  1221. mid[1] = mid[1] / 2.0;
  1222. mid[2] = mid[2] / 2.0;
  1223. AddVectors(vec1, mid, buffer);
  1224. }
  1225.  
  1226. stock RefreshZones()
  1227. {
  1228. RemoveZones();
  1229. new size = GetArraySize(g_Zones);
  1230. new Float:posA[3], Float:posB[3],String:namey[64];
  1231. for(new i=0;i<size;++i)
  1232. {
  1233. new Handle:trie = GetArrayCell(g_Zones, i);
  1234. GetTrieArray(trie, "corda", posA, sizeof(posA));
  1235. GetTrieArray(trie, "cordb", posB, sizeof(posB));
  1236. GetTrieString(trie, "name", namey, 64);
  1237.  
  1238. if(StrContains(namey, "custom_bomb_target", false) != -1) CreateBombZoneEntity(posA, posB, namey);
  1239. else CreateZoneEntity(posA, posB, namey);
  1240. }
  1241. }
  1242.  
  1243. stock RemoveZones()
  1244. {
  1245. // Remove all custom bomb targets zones function
  1246. new iEntity = -1;
  1247. decl String:sClassNameBomb[64];
  1248. while((iEntity = FindEntityByClassname(iEntity, "func_bomb_target")) != -1)
  1249. {
  1250. if(IsValidEntity(iEntity)
  1251. && IsValidEdict(iEntity)
  1252. && GetEdictClassname(iEntity, sClassNameBomb, sizeof(sClassNameBomb))
  1253. && StrContains(sClassNameBomb, "func_bomb_target") != -1
  1254. && GetEntPropString(iEntity, Prop_Data, "m_iName", sClassNameBomb, sizeof(sClassNameBomb))
  1255. && StrContains(sClassNameBomb, "custom_bomb_target") != -1)
  1256. {
  1257. AcceptEntityInput(iEntity, "kill");
  1258. }
  1259. }
  1260.  
  1261. // Remove any old zone triggers
  1262. new iEnts = GetMaxEntities();
  1263. decl String:sClassName[64];
  1264. for(new i=MaxClients;i<iEnts;i++)
  1265. {
  1266. if(IsValidEntity(i)
  1267. && IsValidEdict(i)
  1268. && GetEdictClassname(i, sClassName, sizeof(sClassName))
  1269. && StrContains(sClassName, "trigger_multiple") != -1
  1270. && GetEntPropString(i, Prop_Data, "m_iName", sClassName, sizeof(sClassName))
  1271. && StrContains(sClassName, "sm_devzone") != -1)
  1272. {
  1273. UnhookSingleEntityOutput(i, "OnStartTouch", EntOut_OnStartTouch);
  1274. UnhookSingleEntityOutput(i, "OnEndTouch", EntOut_OnEndTouch);
  1275. AcceptEntityInput(i, "Kill");
  1276. }
  1277. }
  1278. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement