Advertisement
Guest User

Dynamic Org Edit (WARRENRP)

a guest
Nov 23rd, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 37.58 KB | None | 0 0
  1. #include <a_samp>
  2. #include <Dini>
  3. #include <zcmd>
  4. #include <sscanf2>
  5.  
  6.  
  7.  
  8. //Color defines
  9. #define COLOR_GREY 0xAFAFAFAA
  10. #define COLOR_WHITE 0xFFFFFFAA
  11. #define COLOR_ORANGE 0xFF9900AA
  12. #define COLOR_YELLOW 0xFFFF00AA
  13. #define COLOR_RED 0xFF0000FF
  14. //
  15.  
  16.  
  17. #define WAGE 2350 //Define the wage here
  18. #define MAX_ORGS 10 //Change only if you need more than 10 orgs
  19. #define MAX_ORG_WEAPONS 3 //Max amount of weapons for orgs
  20. #define ORG_NAME_LENGTH 32 //Max name length for organization and it's leader
  21. #define MAX_ORG_VEHICLES 10
  22. #define MAX_ZONES_PER_ORG 10
  23.  
  24. #define SAVE_LEADERS_TO "org_leaders.txt"
  25.  
  26.  
  27.  
  28.  
  29. // Script configuration
  30.  
  31. #define SPAWN_WITH_ORG_SKIN //Comment this line IF YOU DON'T WANT THE PLAYERS SPAWN WITH ORGANIZATION SKIN!
  32. #define ENABLE_HQ_TELE //Comment this line IF YOU WANT TO DISABLE /teletohq
  33.  
  34. //
  35.  
  36.  
  37. forward PayDay();
  38. forward CheckArea();
  39. forward AutoSave();
  40.  
  41. new bool:fire;
  42. new AlerTimer[MAX_PLAYERS];
  43. new ExplTimer[MAX_PLAYERS];
  44. new OnDuty[MAX_PLAYERS];
  45. new OrgsCount;
  46. new ZoneCount;
  47.  
  48. new Float:RandomFire[][3] =
  49. {
  50. // X Y Z
  51. {-1952.6168,262.2432,41.0471},
  52. {-2307.5876,1230.7885,38.1414},
  53. {-2838.2437,457.2243,4.5833},
  54. {-2692.2534,385.3595,4.3750},
  55. {-2571.9353,311.5503,15.4476},
  56. {-2629.9619,183.9223,4.3414},
  57. {-1987.4305,33.7425,32.9659} // no comma here
  58. }; // Fire array, remove the comma in the last array.
  59.  
  60. enum Orgs
  61. {
  62. Name[32],
  63. Leader[24],
  64. Skin,
  65. Float:X,
  66. Float:Y,
  67. Float:Z,
  68. Weapons[3],
  69. Ammo[3],
  70. Vehicles[MAX_ORG_VEHICLES],
  71. VehiclesCreated,
  72. Text3D:OrgLabel,
  73. Zones[MAX_ZONES_PER_ORG],
  74. Float:ZoneMinX[MAX_ZONES_PER_ORG],
  75. Float:ZoneMinY[MAX_ZONES_PER_ORG],
  76. Float:ZoneMaxX[MAX_ZONES_PER_ORG],
  77. Float:ZoneMaxY[MAX_ZONES_PER_ORG],
  78. ZoneColor[MAX_ZONES_PER_ORG],
  79. ZonesCreated,
  80. };
  81.  
  82. new Organization[MAX_ORGS][Orgs];
  83. new sname[MAX_PLAYERS][MAX_PLAYER_NAME];
  84. new PlayerOrg[MAX_PLAYERS];
  85. new PlayerLeader[MAX_PLAYERS];
  86. new PlayerRank[MAX_PLAYERS][28];
  87. new Requesting[MAX_PLAYERS];
  88. new CollectedWage[MAX_PLAYERS];
  89.  
  90.  
  91. public OnFilterScriptInit()
  92. {
  93. print("\n--------------------------------------");
  94. print("==Dynamic organization filterscript by Jakku -modified by Mike Peterson- initialized!==");
  95. print("==(C)2013==");
  96. print("--------------------------------------\n");
  97.  
  98. for(new i=0; i < MAX_PLAYERS; i++)
  99. {
  100. if(IsPlayerConnected(i)) {
  101. GetPlayerName(i,sname[i],MAX_PLAYER_NAME);
  102. }
  103. }
  104. SetTimer("PayDay",1800000,1); //Payday every 30 minutes
  105. SetTimer("CheckArea",1000,1);
  106. SetTimer("AutoSave",45000,1);
  107. SetTimer("Incident",900000,1);
  108. /*
  109.  
  110. ALWAYS add your organization BELOW the old one, otherwise the IDs will change = leaders mix up ! ! ! ! !
  111.  
  112. Syntax for CreateOrganization: CreateOrganization(name[32], skin, Float:x,Float:y,Float:z, wp1,a1,wp2,a2,wp3,a3)
  113.  
  114. Syntax for CreateOrgVehicle: CreateOrgVehicle(orgname[32], modelid, Float:x,Float:y,Float:z,Float:rotation, color1,color2)
  115.  
  116. Syntax for CreateOrganizationZone: CreateOrganizationZone(orgname[32], Float:minx,Float:miny,Float:maxx,Float:maxy, color)
  117.  
  118. */
  119.  
  120. //Create ORGS here:
  121. CreateOrganization("Fire Department", 277, -2022.3185,67.1812,28.4755, 9,9999,42,9999,0,1);
  122. CreateOrganization("Police Department", 266, -1605.4655,714.2980,12.9726, 3,1,24,500,31,5000);
  123.  
  124. //
  125.  
  126. //Create ORG VEHICLES here:
  127.  
  128. CreateOrgVehicle("Fire Department", 433, -2392.6755, -42.6893, 35.9392, 269.9164, 3, 1); // Rescue Station 1
  129. CreateOrgVehicle("Fire Department", 544, -2393.2896, -48.8804, 35.6728, 268.5853, 3, 1); // Truck Station 1
  130. CreateOrgVehicle("Fire Department", 407, -2393.4995, -55.4522, 35.5279, 269.8778, 3, 1); // Engine Station 1
  131.  
  132. CreateOrgVehicle("Police Department", 597,-1616.7081,672.5991,6.9554,180.6896,0,1); //Car 1
  133. CreateOrgVehicle("Police Department", 523,-1616.9094,651.9808,6.7580,356.0465,0,0); //Bike 1
  134. CreateOrgVehicle("Police Department", 597,-1612.0490,672.6185,6.9567,180.2458,0,1); //Car 2
  135. CreateOrgVehicle("Police Department", 402,-1628.4525,652.3068,7.0193,359.5661,22,22); //Undercover 1
  136. CreateOrgVehicle("Police Department", 490,-1588.4080,673.0498,7.3080,176.8286,0,0); //Undercover 2
  137.  
  138. //
  139.  
  140. //Create ORG ZONES here:
  141.  
  142. //
  143.  
  144.  
  145.  
  146. LoadLeaders();
  147.  
  148. new pcount = 0;
  149. for (new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  150. {
  151. if (IsPlayerConnected(playerid))
  152. {
  153. LoadPlayerOrgInfo(playerid);
  154. pcount++;
  155. }
  156. }
  157. if (pcount > 0)
  158. {
  159. printf("==Dynamic organization filterscript by Jakku -modified by Mike Peterson- reloaded!==");
  160. printf("==Data loaded for %d connected players==", pcount);
  161. }
  162.  
  163. return 1;
  164. }
  165. /*
  166. for (new i=0;i<MAX_PLAYERS;i++)
  167. {
  168. if (IsPlayerConnected(i))
  169. {
  170. new skin = GetPlayerSkin(i);
  171. if(skin >= 277 && skin <= 279 && onDuty[i])
  172. {*/
  173. forward Incident();
  174. public Incident()
  175. {
  176. if(!fire) SpawnRandomFire();
  177. return 1;
  178. }
  179.  
  180. SpawnRandomFire()
  181. {
  182. fire=true;
  183. new rand = random(sizeof(RandomFire));
  184. CreateExplosion(RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2],1,100);
  185. for (new i=0;i<MAX_PLAYERS;i++)
  186. {
  187. ExplTimer[i] = SetTimerEx("Explosion",2500,1,"i",rand);
  188. AlerTimer[i] = SetTimerEx("ReAlert",30000,1,"i",rand);
  189. }
  190. for (new i=0;i<MAX_PLAYERS;i++)
  191. {
  192. new skin = GetPlayerSkin(i);
  193. if(skin >= 277 && skin <= 279 && OnDuty[i]) { SetPlayerCheckpoint(i,RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2],5); SendClientMessage(i,COLOR_RED,FireName(rand)); }
  194. }
  195. }
  196.  
  197. forward ReAlert(rand);
  198. /*public ReAlert(rand)
  199. {
  200. for (new i=0;i<MAX_PLAYERS;i++)
  201. {
  202. new skin = GetPlayerSkin(i);
  203. if(skin >= 277 && skin <= 279 && OnDuty[i]) { SetPlayerCheckpoint(i,RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2],5); SendClientMessage(i,COLOR_RED,FireName(rand)); }
  204. }
  205. }*/
  206. forward Explosion(rand);
  207. public Explosion(rand)
  208. {
  209. for (new i=0;i<MAX_PLAYERS;i++)
  210. {
  211. new skin = GetPlayerSkin(i);
  212. if(skin >= 277 && skin <= 279 && OnDuty[i])
  213. {
  214. if(IsPlayerInRangeOfPoint(i,5.0,RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2]))
  215. {
  216. SendClientMessage(i,COLOR_RED,"Extinguish the fire!");
  217. for (new iz=0;iz<MAX_PLAYERS;iz++)
  218. {
  219. DisablePlayerCheckpoint(iz);
  220. KillTimer(AlerTimer[iz]);
  221. KillTimer(ExplTimer[iz]);
  222. fire=false;
  223. }
  224. } else {
  225. CreateExplosion(RandomFire[rand][0], RandomFire[rand][1],RandomFire[rand][2],1,100);
  226. }
  227. }
  228. }
  229. return 1;
  230. }
  231.  
  232.  
  233. public PayDay()
  234. {
  235. for (new i=0;i<MAX_PLAYERS;i++)
  236. {
  237. if (IsPlayerConnected(i))
  238. {
  239. if (PlayerOrg[i] != 0 && OnDuty[i])
  240. {
  241. new string[80];
  242. format(string, sizeof(string),"Payday ($%d)", WAGE);
  243. SendClientMessage(i, COLOR_GREY, string);
  244. CollectedWage[i]+=WAGE;
  245. SavePlayerOrgInfo(i);
  246. }
  247. }
  248. }
  249. }
  250.  
  251. public AutoSave()
  252. {
  253. for (new i=0;i<MAX_PLAYERS;i++)
  254. {
  255. if (IsPlayerConnected(i))
  256. {
  257. SavePlayerOrgInfo(i);
  258. }
  259. }
  260.  
  261. SaveLeaders();
  262. }
  263.  
  264. public CheckArea()
  265. {
  266. for (new i=0;i<MAX_PLAYERS;i++)
  267. {
  268. if (IsPlayerConnected(i))
  269. {
  270. new count,name[32];
  271. for (new c=1;c<OrgsCount+1;c++)
  272. {
  273. if (DoesOrgExist(GetOrgName(c)))
  274. {
  275. for (new a=1;a<Organization[c][ZonesCreated]+1;a++)
  276. {
  277. if (IsPlayerInArea(i, Organization[c][ZoneMinX][a],Organization[c][ZoneMinY][a],Organization[c][ZoneMaxX][a],Organization[c][ZoneMaxY][a]))
  278. {
  279. count++;
  280. name = GetOrgName(c);
  281. }
  282.  
  283. }
  284. }
  285. }
  286.  
  287. if (count != 0)
  288. {
  289. if (GetPVarInt(i, "IsInOrgZone") == 0)
  290. {
  291. new string[120];
  292. if (PlayerOrg[i] == GetOrgID(name))
  293. {
  294. format(string,sizeof(string),"Welcome to your organization's zone!");
  295. }
  296. else
  297. {
  298. format(string,sizeof(string),"You are now in {5CB3FF}%s's{FFFFFF} zone!", name);
  299. }
  300. SendClientMessage(i, COLOR_WHITE, string);
  301. SetPVarInt(i, "IsInOrgZone", 1);
  302. return 1;
  303. }
  304. }
  305. else
  306. {
  307. SetPVarInt(i, "IsInOrgZone", 0);
  308. }
  309. }
  310. }
  311. return 1;
  312. }
  313.  
  314.  
  315.  
  316. public OnFilterScriptExit()
  317. {
  318. print("Thank you for using Jakku's Dynamic organizations -modified by Mike Peterson- filterscript");
  319. print("(C) 2011 - 2012");
  320.  
  321. for (new i=1;i<OrgsCount+1;i++)
  322. {
  323. for (new a=0;a<MAX_ORG_VEHICLES;a++)
  324. {
  325. if (IsVehicleConnected(Organization[i][Vehicles][a]))
  326. {
  327. DestroyVehicle(Organization[i][Vehicles][a]);
  328. }
  329. }
  330. Delete3DTextLabel(Organization[i][OrgLabel]);
  331. }
  332.  
  333. for (new playerid = 0;playerid<MAX_PLAYERS;playerid++)
  334. {
  335. if (IsPlayerConnected(playerid))
  336. {
  337. SavePlayerOrgInfo(playerid);
  338. }
  339. }
  340.  
  341. SaveLeaders();
  342. return 1;
  343. }
  344.  
  345.  
  346. public OnPlayerConnect(playerid)
  347. {
  348. PlayerOrg[playerid] = 0; //Resetting player org
  349. PlayerLeader[playerid] = 0; //Resetting player org leader status
  350. Requesting[playerid] = 0;
  351. CollectedWage[playerid] = 0;
  352. PlayerRank[playerid] = "None";
  353. GetPlayerName(playerid,sname[playerid],MAX_PLAYER_NAME);
  354. if(!dini_Exists(PlayerPath(playerid))) //Creating file (check stock PlayerPath(playerid) )
  355. {
  356. SendClientMessage(playerid, COLOR_ORANGE,"Welcome to SFR-GTA. The San Fierro Fire Dept and the San Fierro Police Dept are currently hiring, apply on the forums.");
  357. dini_Create(PlayerPath(playerid));
  358. }
  359. else
  360. {
  361. LoadPlayerOrgInfo(playerid);
  362. }
  363. return 1;
  364. }
  365.  
  366. public OnPlayerDisconnect(playerid, reason)
  367. {
  368. SavePlayerOrgInfo(playerid);
  369. return 1;
  370. }
  371.  
  372. public OnPlayerSpawn(playerid)
  373. {
  374. AntiDeAMX();
  375. if (PlayerOrg[playerid] != 0)
  376. {
  377. if (GetPVarInt(playerid, "Dead") == 0)
  378. {
  379. new string[160];
  380. new leader[4];
  381. if (IsLeader(playerid)) leader = "Yes";
  382. else leader = "No";
  383. format(string,sizeof(string),"Organization: {5CB3FF}%s {FFFFFF}|| Leader: {5CB3FF}%s {FFFFFF}|| Rank: {5CB3FF}%s", GetOrgName(PlayerOrg[playerid]), leader, PlayerRank[playerid]);
  384. SendClientMessage(playerid, COLOR_WHITE, string);
  385. GiveOrgFeatures(playerid);
  386. format(string,sizeof(string),"[%s]%s",PlayerRank[playerid],sname[playerid]);
  387. SetPlayerName(playerid,string);
  388. }
  389. }
  390. SetPVarInt(playerid, "Dead", 0);
  391.  
  392. for (new i=1;i<OrgsCount+1;i++)
  393. {
  394. for (new a=1;a<Organization[i][ZonesCreated]+1;a++)
  395. {
  396. GangZoneShowForPlayer(playerid, Organization[i][Zones][a], Organization[i][ZoneColor][a]);
  397. }
  398. }
  399.  
  400. return 1;
  401. }
  402.  
  403. public OnPlayerDeath(playerid, killerid, reason)
  404. {
  405. SetPVarInt(playerid, "Dead", 1);
  406. }
  407.  
  408.  
  409. public OnPlayerCommandText(playerid, cmdtext[])
  410. {
  411. return 0;
  412. }
  413.  
  414.  
  415.  
  416. public OnPlayerEnterCheckpoint(playerid)
  417. {
  418. return 1;
  419. }
  420.  
  421.  
  422.  
  423. public OnPlayerPickUpPickup(playerid, pickupid)
  424. {
  425. return 1;
  426. }
  427.  
  428.  
  429. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  430. {
  431. if (dialogid == 755)
  432. {
  433. if (response)
  434. {
  435. new string[120];
  436. format(string,sizeof(string),"You have resigned from %s", Organization[PlayerOrg[playerid]][Name]);
  437. SendClientMessage(playerid, COLOR_YELLOW, string);
  438. format(string,sizeof(string),"**%s has resigned from %s", PlayerName(playerid), Organization[PlayerOrg[playerid]][Name]);
  439. SendClientMessageToAllEx(playerid, COLOR_GREY, string);
  440.  
  441. if (IsLeader(playerid))
  442. {
  443. new none[24];
  444. format(none,sizeof(none),"None");
  445. Organization[PlayerOrg[playerid]][Leader] = none;
  446. }
  447. ResetPlayerOrg(playerid);
  448. SavePlayerOrgInfo(playerid);
  449. }
  450. else
  451. {
  452. SendClientMessage(playerid, COLOR_YELLOW, "Resignation cancelled");
  453. }
  454. }
  455.  
  456. if (dialogid == 756 && response)
  457. {
  458. switch (listitem)
  459. {
  460. case 0:
  461. {
  462. for (new i=1;i<OrgsCount+1;i++)
  463. {
  464. if (IsPlayerInRangeOfPoint(playerid, 3.0, Organization[i][X], Organization[i][Y],Organization[i][Z]))
  465. {
  466. new string[140];
  467. format(string,sizeof(string),"{5CB3FF}Organization: {FFFFFF}%s\n{5CB3FF}Leader: {FFFFFF}%s", GetOrgName(i), Organization[i][Leader]);
  468. ShowPlayerDialog(playerid, 757, DIALOG_STYLE_MSGBOX, "Organization",string,"Close","");
  469. return 1;
  470. }
  471. }
  472.  
  473. }
  474.  
  475. case 1:
  476. {
  477. if (CollectedWage[playerid] <= 0) return SendClientMessage(playerid, COLOR_RED, "You don't have any wage earned yet!");
  478. new string[80];
  479. format(string,sizeof(string),"You have collected $%d", CollectedWage[playerid]);
  480. SendClientMessage(playerid, COLOR_YELLOW, string);
  481. GivePlayerMoney(playerid, CollectedWage[playerid]);
  482. CollectedWage[playerid] = 0;
  483. SavePlayerOrgInfo(playerid);
  484. }
  485.  
  486. }
  487.  
  488. }
  489. return 1;
  490. }
  491.  
  492. public OnPlayerStateChange(playerid,newstate,oldstate)
  493. {
  494. if (newstate == PLAYER_STATE_DRIVER)
  495. {
  496. for (new i=1;i<OrgsCount+1;i++)
  497. {
  498. for (new a=0;a<MAX_ORG_VEHICLES;a++)
  499. {
  500. new vehicleid = GetPlayerVehicleID(playerid);
  501. if (IsVehicleConnected(vehicleid))
  502. {
  503. if (vehicleid == Organization[i][Vehicles][a] && PlayerOrg[playerid] != i)
  504. {
  505. if (DoesOrgExist(GetOrgName(i)))
  506. {
  507. new string[100];
  508. format(string,sizeof(string),"This vehicle belongs to %s. You are not authorized to use it", GetOrgName(i));
  509. SendClientMessage(playerid, COLOR_RED, string);
  510. RemovePlayerFromVehicle(playerid);
  511. }
  512. }
  513. }
  514. }
  515. }
  516. }
  517.  
  518. return 1;
  519. }
  520.  
  521. stock PlayerName(playerid)
  522. {
  523. new playername[24];
  524. GetPlayerName(playerid, playername, 24);
  525. return playername;
  526. }
  527.  
  528. stock FireName(id)
  529. {
  530. new IncidentName[256];
  531. switch(id)
  532. {
  533. case 0: { IncidentName = "Box 98-02 Level 3 Alert, Gas explosion at Wang Cars Dealership, Multiple callers reporting working fire."; }
  534. case 1: { IncidentName = "Box 98-04 Level 2 Alert, Brush fire on Juniper Hill."; }
  535. case 2: { IncidentName = "Box 98-03 Level 1 Alert, Trash can fire in Palisades."; }
  536. case 3: { IncidentName = "Box 98-03 Level 2 Alert, Propane tank explosion at City Hall"; }
  537. case 4: { IncidentName = "Box 98-03 Level 3 Alert, Commercial structure fire, 687 New Brunswick Ave, Garden Center. Callers reporting working fire."; }
  538. case 5: { IncidentName = "Box 98-04 Level 2 Alert, Unknown type fire, 239 Route 57. Caller reports hearing a loud explosion, doesn't see any fire."; }
  539. case 6: { IncidentName = "Box 98-01 Level 2 Alert, 424 Hamilton Drive, Drier Fire. No further information at this time."; }
  540. }
  541. return IncidentName;
  542. }
  543.  
  544. stock CreateOrganization(name[32], skin, Float:x,Float:y,Float:z, wp1 = 0,a1 = 0,wp2 = 0,a2 = 0,wp3 = 0,a3 = 0)
  545. {
  546. OrgsCount++;
  547. if (OrgsCount >= MAX_ORGS) return printf("You have exceeded the MAX_ORGS- define! Aborted");
  548. new id = OrgsCount;
  549. Organization[id][Name] = name;
  550. Organization[id][Skin] = skin;
  551. Organization[id][X] = x;
  552. Organization[id][Y] = y;
  553. Organization[id][Z] = z;
  554. Organization[id][Weapons][0] = wp1;
  555. Organization[id][Ammo][0] = a1;
  556. Organization[id][Weapons][1] = wp2;
  557. Organization[id][Ammo][1] = a2;
  558. Organization[id][Weapons][2] = wp3;
  559. Organization[id][Ammo][2] = a3;
  560. printf("Organization created: ID: %d || Name: %s",id, name);
  561. new string[100];
  562. format(string,sizeof(string),"{5CB3FF}HQ:{FFFFFF} %s\nType {5CB3FF}/org{FFFFFF} for more information!",name);
  563. Organization[id][OrgLabel] = Create3DTextLabel(string, 0x008080FF, x, y, z, 25.0, 0);
  564. return 1;
  565. }
  566.  
  567. stock PlayerPath(playerid)
  568. {
  569. new path[45];
  570. format(path, sizeof(path),"Orginfo_%s.ini", PlayerName(playerid));
  571. return path;
  572. }
  573.  
  574. stock SaveLeaders()
  575. {
  576. new part[40];
  577. if (!dini_Exists(SAVE_LEADERS_TO))
  578. {
  579. dini_Create(SAVE_LEADERS_TO);
  580. }
  581.  
  582. for (new i=1;i<OrgsCount+1;i++)
  583. {
  584. format(part,sizeof(part),"%d", i);
  585. dini_Set(SAVE_LEADERS_TO,part,Organization[i][Leader]);
  586. }
  587. }
  588.  
  589. stock LoadLeaders()
  590. {
  591. new part[24];
  592. new part2[40];
  593.  
  594. if (!dini_Exists(SAVE_LEADERS_TO))
  595. {
  596. for (new i=1;i<OrgsCount+1;i++)
  597. {
  598. dini_Create(SAVE_LEADERS_TO);
  599. format(part,sizeof(part),"None");
  600. Organization[i][Leader] = part;
  601. SaveLeaders();
  602. }
  603. return 1;
  604. }
  605.  
  606. for (new i=1;i<OrgsCount+1;i++)
  607. {
  608. format(part2,sizeof(part2),"%d", i);
  609. format(part,sizeof(part),dini_Get(SAVE_LEADERS_TO,part2));
  610.  
  611. if (strcmp(part," ", false) == 0)
  612. {
  613. part = "None";
  614. }
  615.  
  616. Organization[i][Leader] = part;
  617. }
  618.  
  619. return 1;
  620. }
  621.  
  622. stock SavePlayerOrgInfo(playerid)
  623. {
  624.  
  625. if (!dini_Exists(PlayerPath(playerid)))
  626. {
  627. dini_Create(PlayerPath(playerid));
  628. }
  629. //dini_Set(savef,"ContactName1",ContactNames[0][playerid]);
  630. dini_Set(PlayerPath(playerid),"Org",Organization[PlayerOrg[playerid]][Name]);
  631. dini_Set(PlayerPath(playerid),"Rank",PlayerRank[playerid]);
  632. dini_IntSet(PlayerPath(playerid),"CollectedWage",CollectedWage[playerid]);
  633. }
  634.  
  635. stock LoadPlayerOrgInfo(playerid)
  636. {
  637. new string[45];
  638. format(string,sizeof(string),"%s",dini_Get(PlayerPath(playerid),"Org"));
  639. PlayerOrg[playerid] = GetOrgID(string);
  640. new string2[28];
  641. format(string2,sizeof(string2),"%s",dini_Get(PlayerPath(playerid),"Rank"));
  642. PlayerRank[playerid] = string2;
  643. CollectedWage[playerid] = dini_Int(PlayerPath(playerid), "CollectedWage");
  644.  
  645. if (strcmp(Organization[PlayerOrg[playerid]][Leader], PlayerName(playerid),true) == 0 && PlayerOrg[playerid] != 0)
  646. {
  647. PlayerLeader[playerid] = 1;
  648. }
  649.  
  650. }
  651.  
  652. stock GiveOrgFeatures(playerid)
  653. {
  654. new org = PlayerOrg[playerid];
  655. if (!org) return 1;
  656. GivePlayerWeapon(playerid, Organization[org][Weapons][0],Organization[org][Ammo][0]);
  657. GivePlayerWeapon(playerid, Organization[org][Weapons][1],Organization[org][Ammo][1]);
  658. GivePlayerWeapon(playerid, Organization[org][Weapons][2],Organization[org][Ammo][2]);
  659. #if defined SPAWN_WITH_ORG_SKIN
  660. SetPlayerSkin(playerid, Organization[org][Skin]);
  661. #endif
  662. return 1;
  663. }
  664.  
  665. stock GetOrgName(orgid)
  666. {
  667. new name[32];
  668. format(name,sizeof(name),"%s",Organization[orgid][Name]);
  669. if (orgid == 0) format(name,sizeof(name),"None");
  670. return name;
  671. }
  672.  
  673.  
  674.  
  675.  
  676. stock SendClientMessageToAllEx(exception, clr, const message[])
  677. {
  678. for(new i; i<MAX_PLAYERS; i++)
  679. {
  680. if(IsPlayerConnected(i))
  681. {
  682. if(i != exception)
  683. {
  684. SendClientMessage(i, clr, message);
  685. }
  686. }
  687. }
  688. }
  689.  
  690. stock ResetPlayerOrg(playerid)
  691. {
  692. if (PlayerOrg[playerid] == 0) return 1;
  693. printf("%s has been removed from %s", PlayerName(playerid), GetOrgName(PlayerOrg[playerid]));
  694. SetPlayerSkin(playerid, 0);
  695. ResetPlayerWeapons(playerid);
  696. PlayerOrg[playerid] = 0;
  697. Requesting[playerid] = 0;
  698. PlayerLeader[playerid] = 0;
  699. return 1;
  700. }
  701.  
  702.  
  703. CMD:resign(playerid, params[])
  704. {
  705. #pragma unused params
  706. if (PlayerOrg[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not a member of an organization");
  707. ShowPlayerDialog(playerid, 755, DIALOG_STYLE_MSGBOX, "{FFFFFF}Are you sure you want to resign?","{FFFFFF}Please {00FF00}confirm {FFFFFF}your resignation request","Resign","Cancel");
  708. return 1;
  709. }
  710.  
  711. CMD:duty(playerid, params[])
  712. {
  713. #pragma unused params
  714. if (PlayerOrg[playerid] == 0) return SendClientMessage(playerid, COLOR_RED, "You are not a member of an organization");
  715. if(!OnDuty[playerid]) {
  716. OnDuty[playerid] = true;
  717. SendClientMessage(playerid, COLOR_RED, "You are now on duty");
  718. SetPlayerArmour(playerid,100.0);
  719. }
  720.  
  721. else if(OnDuty[playerid]) {
  722. OnDuty[playerid] = false;
  723. SendClientMessage(playerid, COLOR_RED, "You are now off duty");
  724. SetPlayerArmour(playerid,100.0);
  725. }
  726. return 1;
  727. }
  728.  
  729. CMD:makefire(playerid, params[])
  730. {
  731. #pragma unused params
  732. if (!IsPlayerAdmin(playerid)) return 0;
  733. for(new i=0; i < MAX_PLAYERS; i++)
  734. {
  735. if(IsPlayerConnected(i))
  736. {
  737. DisablePlayerCheckpoint(i);
  738. KillTimer(AlerTimer[i]);
  739. KillTimer(ExplTimer[i]);
  740. fire=false;
  741. }
  742. }
  743. SpawnRandomFire();
  744. return 1;
  745. }
  746.  
  747. CMD:r(playerid, params[])
  748. {
  749. if (PlayerOrg[playerid] == 0) return SendClientMessage(playerid, COLOR_RED,"You are not a member of an organization");
  750. new text[100];
  751. if (sscanf(params, "s[100]", text)) return SendClientMessage(playerid,COLOR_WHITE,"Call in on Fire Response by using /r [message]");
  752. new org = PlayerOrg[playerid];
  753. new string[128];
  754. format(string,sizeof(string),"{5CB3FF}(Fire Response Frequency) {FFFFFF}(%s): %s", PlayerName(playerid), text);
  755. SendClientMessageToOrg(GetOrgName(org), COLOR_WHITE, string);
  756. return 1;
  757. }
  758.  
  759. CMD:teletohq(playerid, params[])
  760. {
  761. #pragma unused params
  762.  
  763. #if defined ENABLE_HQ_TELE
  764. if (PlayerOrg[playerid] == 0) return SendClientMessage(playerid, COLOR_RED,"You are not a member of an organization");
  765.  
  766. if (IsPlayerInRangeOfPoint(playerid, 10.0,Organization[PlayerOrg[playerid]][X],Organization[PlayerOrg[playerid]][Y],Organization[PlayerOrg[playerid]][Z]))
  767. {
  768. SendClientMessage(playerid, COLOR_RED,"You are already close to your HQ!");
  769. return 1;
  770. }
  771.  
  772. SetPlayerPos(playerid, Organization[PlayerOrg[playerid]][X],Organization[PlayerOrg[playerid]][Y],Organization[PlayerOrg[playerid]][Z]);
  773. SendClientMessage(playerid, COLOR_YELLOW,"You have teleported to your HQ");
  774.  
  775. #else
  776. SendClientMessage(playerid, COLOR_RED,"This feature has been disabled");
  777. #endif
  778.  
  779. return 1;
  780. }
  781.  
  782.  
  783. CMD:ovrespawn(playerid, params[])
  784. {
  785. #pragma unused params
  786. if (!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_RED,"You are not the leader of an organization!");
  787. new org = PlayerOrg[playerid];
  788. if (Organization[org][VehiclesCreated] <= 0) return SendClientMessage(playerid, COLOR_RED,"There are no vehicles created for your org!");
  789. SendClientMessage(playerid, COLOR_YELLOW,"You have respawned your org. vehicles!");
  790.  
  791. for (new i=0;i<MAX_ORG_VEHICLES;i++)
  792. {
  793. if (IsVehicleConnected(Organization[org][Vehicles][i]))
  794. {
  795. SetVehicleToRespawn(Organization[org][Vehicles][i]);
  796. }
  797. }
  798.  
  799. return 1;
  800. }
  801.  
  802. CMD:org(playerid, params[])
  803. {
  804. #pragma unused params
  805.  
  806. for (new i=1;i<OrgsCount+1;i++)
  807. {
  808. if (IsPlayerInRangeOfPoint(playerid, 3.0, Organization[i][X],Organization[i][Y],Organization[i][Z]))
  809. {
  810. new string[35];
  811. new string2[80];
  812. format(string, sizeof(string),"%s", GetOrgName(i));
  813. format(string2, sizeof(string2),"Information");
  814. if (PlayerOrg[playerid] == i) format(string2, sizeof(string2),"Information\nCollect Wage");
  815. ShowPlayerDialog(playerid, 756, DIALOG_STYLE_LIST, string,string2,"Ok","Cancel");
  816. return 1;
  817. }
  818. }
  819. SendClientMessage(playerid, COLOR_RED,"You are not close enough to an organization!");
  820. return 1;
  821. }
  822.  
  823. CMD:setmember(playerid, params[])
  824. {
  825. if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");
  826. new ID;
  827. if (sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setmember [playerid]");
  828. if (!IsPlayerConnected(ID) || ID == playerid) return 1;
  829. new org = PlayerOrg[playerid];
  830. if (PlayerOrg[ID]) return SendClientMessage(playerid, COLOR_RED,"That player already belongs to an organization");
  831. if (Requesting[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player is not requesting to join your organization!");
  832. new string[120];
  833. format(string,sizeof(string),"%s has set you as a member of %s", PlayerName(playerid), GetOrgName(org));
  834. SendClientMessage(ID, COLOR_YELLOW, string);
  835. format(string,sizeof(string),"You have set %s a member of %s", PlayerName(ID), GetOrgName(org));
  836. SendClientMessage(playerid, COLOR_YELLOW, string);
  837. PlayerOrg[ID] = org;
  838. GiveOrgFeatures(ID);
  839. Requesting[ID] = 0;
  840. return 1;
  841. }
  842.  
  843. CMD:setleader(playerid, params[])
  844. {
  845. if (!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_RED,"You must be logged into RCON to use this command!");
  846. new ID,orgid;
  847. if (sscanf(params, "ud", ID,orgid)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setleader [playerid] [orgid]");
  848. if (!IsPlayerConnected(ID)) return 1;
  849. if (PlayerOrg[ID]) return SendClientMessage(playerid, COLOR_RED,"That player already belongs to an organization");
  850. if (orgid < 1 || orgid > OrgsCount) return SendClientMessage(playerid, COLOR_RED,"Invalid org. ID!");
  851. new string[140];
  852. format(string,sizeof(string),"An admin %s has set you as the leader of %s", PlayerName(playerid), GetOrgName(orgid));
  853. SendClientMessage(ID, COLOR_YELLOW, string);
  854. format(string,sizeof(string),"You have set %s the leader of %s", PlayerName(ID), GetOrgName(orgid));
  855. SendClientMessage(playerid, COLOR_YELLOW, string);
  856. PlayerOrg[ID] = orgid;
  857. PlayerLeader[ID] = 1;
  858. Organization[orgid][Leader] = PlayerName(ID);
  859. SaveLeaders();
  860. SavePlayerOrgInfo(ID);
  861. GiveOrgFeatures(ID);
  862. return 1;
  863. }
  864.  
  865.  
  866. CMD:setrank(playerid, params[])
  867. {
  868. if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");
  869. new ID, rank[28];
  870. if (sscanf(params, "us[28]", ID, rank)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setrank [playerid] [rank]");
  871. if (strlen(rank) > 28) return SendClientMessage(playerid, COLOR_RED,"The maximum rank length is 28 characters!");
  872. if (!IsPlayerConnected(ID)) return 1;
  873. new org = PlayerOrg[playerid];
  874. if (PlayerOrg[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player does not belong to your organization");
  875. new string[120];
  876. format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), rank);
  877. SendClientMessage(ID, COLOR_YELLOW, string);
  878. format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), rank);
  879. SendClientMessage(playerid, COLOR_YELLOW, string);
  880. PlayerRank[ID] = rank;
  881. format(string,sizeof(string),"[%s]%s",rank,sname[ID]);
  882. SetPlayerName(ID,string);
  883. SavePlayerOrgInfo(ID);
  884. return 1;
  885. }
  886.  
  887. CMD:kickmember(playerid, params[])
  888. {
  889. if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");
  890. new ID;
  891. if (sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /kickmember [playerid]");
  892. if (!IsPlayerConnected(ID) || ID == playerid) return 1;
  893. new org = PlayerOrg[playerid];
  894. if (PlayerOrg[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player does not belong to your organization");
  895. new string[130];
  896. format(string,sizeof(string),"%s has kicked you from %s", PlayerName(playerid), GetOrgName(org));
  897. SendClientMessage(ID, COLOR_YELLOW, string);
  898. format(string,sizeof(string),"You have kicked %s from %s", PlayerName(ID), GetOrgName(org));
  899. SendClientMessage(playerid, COLOR_YELLOW, string);
  900. ResetPlayerOrg(ID);
  901. return 1;
  902. }
  903.  
  904. CMD:request(playerid, params[])
  905. {
  906. if (PlayerOrg[playerid] > 0) return SendClientMessage(playerid, COLOR_RED,"You already belong to an organization!");
  907. if (Requesting[playerid] > 0) return SendClientMessage(playerid, COLOR_RED,"You are already requesting to join an organization!");
  908. new ID;
  909. if (sscanf(params, "d", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /request [org id]");
  910. if (ID < 1 || ID > OrgsCount) return SendClientMessage(playerid,COLOR_RED,"Invalid organization ID! Type /orglist for a complete list");
  911. if (!IsLeaderOnline(ID)) return SendClientMessage(playerid,COLOR_RED,"The leader of this organization is currently offline!");
  912. new string[120];
  913. format(string,sizeof(string),"%s is requesting to join the %s", PlayerName(playerid), GetOrgName(ID));
  914. SendClientMessageToAllEx(playerid, COLOR_GREY, string);
  915. format(string,sizeof(string),"Your request to %s has been sent", GetOrgName(ID));
  916. SendClientMessage(playerid, COLOR_YELLOW, string);
  917. Requesting[playerid] = ID;
  918. return 1;
  919. }
  920.  
  921. CMD:decline(playerid, params[])
  922. {
  923. #pragma unused params
  924. if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization");
  925. new ID;
  926. if (sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /decline [playerid]");
  927. if (!IsPlayerConnected(ID) || ID == playerid) return 1;
  928. new org = PlayerOrg[playerid];
  929. if (Requesting[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player is not requesting to join your organization!");
  930. new string[120];
  931. format(string,sizeof(string),"Your request to %s has been declined by %s", GetOrgName(org), PlayerName(playerid));
  932. SendClientMessage(ID, COLOR_GREY, string);
  933. format(string,sizeof(string),"You have successfully declined %s's request", PlayerName(ID));
  934. SendClientMessage(playerid, COLOR_YELLOW, string);
  935. Requesting[ID] = 0;
  936. return 1;
  937. }
  938.  
  939. CMD:orglist(playerid, params[])
  940. {
  941. #pragma unused params
  942. new string[90];
  943. if (OrgsCount == 0) return SendClientMessage(playerid, COLOR_RED,"Sorry, there are no organizations created at the moment!");
  944. SendClientMessage(playerid, COLOR_WHITE, "Current organizations:");
  945.  
  946. for (new i=1;i<OrgsCount+1;i++)
  947. {
  948. format(string,sizeof(string),"ID: %d || Name: %s || Leader: %s", i, GetOrgName(i), Organization[i][Leader]);
  949. SendClientMessage(playerid, COLOR_YELLOW, string);
  950. }
  951.  
  952. return 1;
  953. }
  954.  
  955. CMD:members(playerid, params[])
  956. {
  957. #pragma unused params
  958. if (!IsLeader(playerid)) return SendClientMessage(playerid, COLOR_RED,"You're not the leader of an organization");
  959. new string[60];
  960. new count = 0;
  961. SendClientMessage(playerid, COLOR_YELLOW,"Employees online");
  962. for (new i=0;i<MAX_PLAYERS;i++)
  963. {
  964. if (IsPlayerConnected(i))
  965. {
  966. if (PlayerOrg[i] == PlayerOrg[playerid] && i != playerid)
  967. {
  968. format(string,sizeof(string),"%s - %s", PlayerName(i), PlayerRank[i]);
  969. SendClientMessage(playerid, COLOR_WHITE, string);
  970. count++;
  971. }
  972. }
  973. }
  974.  
  975. if (count == 0)
  976. {
  977. SendClientMessage(playerid, COLOR_YELLOW,"None of your employees are online");
  978. }
  979.  
  980. else
  981. {
  982. format(string,sizeof(string),"%d member(s) online", count);
  983. SendClientMessage(playerid, COLOR_WHITE, string);
  984. }
  985.  
  986. return 1;
  987. }
  988.  
  989. CMD:myorg(playerid, params[])
  990. {
  991. #pragma unused params
  992. if (PlayerOrg[playerid] == 0) return SendClientMessage(playerid, COLOR_RED,"You are not a member of an organization");
  993. new string[140];
  994. format(string,sizeof(string),"{5CB3FF}Organization: {FFFFFF}%s\n{5CB3FF}Leader: {FFFFFF}%s", GetOrgName(PlayerOrg[playerid]), Organization[PlayerOrg[playerid]][Leader]);
  995. ShowPlayerDialog(playerid, 757, DIALOG_STYLE_MSGBOX, "My organization", string, "Ok", "");
  996. return 1;
  997. }
  998.  
  999. CMD:orghelp(playerid, params[])
  1000. {
  1001. #pragma unused params
  1002. SendClientMessage(playerid, COLOR_YELLOW, "Dynamic Organizations by Jakku");
  1003. SendClientMessage(playerid, COLOR_WHITE, "/orglist || /myorg || /request || /resign || /org || /ochat");
  1004. if (IsPlayerAdmin(playerid)) SendClientMessage(playerid, COLOR_WHITE,"RCON- Admin commands: /setleader");
  1005. if (IsLeader(playerid)) SendClientMessage(playerid, COLOR_WHITE,"Leader commands: /setmember || /kickmember || /setrank || /members || /ovrespawn || /decline");
  1006. return 1;
  1007. }
  1008.  
  1009. stock GetOrgID(name[])
  1010. {
  1011. if (strlen(name) <= 0) return 0;
  1012. for (new i=1;i<OrgsCount+1;i++)
  1013. {
  1014. if (strcmp(name,Organization[i][Name],true) == 0) return i;
  1015. }
  1016. return 0;
  1017. }
  1018.  
  1019.  
  1020. stock CreateOrgVehicle(org[32], model, Float:x,Float:y,Float:z,Float:rot, clr1,clr2)
  1021. {
  1022. if (!DoesOrgExist(org)) return printf("You are attempting to create org. vehicles for an org. which does not exist!");
  1023. new orgid = GetOrgID(org);
  1024. new freeslot = Organization[orgid][VehiclesCreated];
  1025. if (freeslot >= MAX_ORG_VEHICLES) return printf("Error: %s cannot handle more vehicles! Aborted", org);
  1026.  
  1027. Organization[orgid][Vehicles][freeslot] = CreateVehicle(model, x,y,z,rot,clr1,clr2,900);
  1028. printf("Added org. vehicle: %d to slot %d for %s",model,freeslot+1, org);
  1029. Organization[orgid][VehiclesCreated]++;
  1030. return 1;
  1031. }
  1032.  
  1033.  
  1034. stock IsLeaderOnline(org)
  1035. {
  1036. for (new i = 0; i < MAX_PLAYERS; i++)
  1037. {
  1038. if (IsPlayerConnected(i))
  1039. {
  1040. if (PlayerOrg[i] == org && PlayerLeader[i] == 1) return true;
  1041. }
  1042.  
  1043. }
  1044. return false;
  1045. }
  1046.  
  1047. stock IsLeader(playerid)
  1048. {
  1049. if (PlayerOrg[playerid] != 0 && PlayerLeader[playerid] == 1) return 1;
  1050. return 0;
  1051. }
  1052.  
  1053. stock IsVehicleConnected(vehicleid)
  1054. {
  1055. new Float:x1,Float:y1,Float:z1;
  1056. GetVehiclePos(vehicleid,x1,y1,z1);
  1057. if(x1==0.0 && y1==0.0 && z1==0.0)
  1058. {
  1059. return 0;
  1060. }
  1061. return 1;
  1062. }
  1063.  
  1064. stock DoesOrgExist(orgname[32])
  1065. {
  1066. for (new i=1;i<OrgsCount+1;i++)
  1067. {
  1068. if (strcmp(Organization[i][Name], orgname, true) == 0) return 1;
  1069. }
  1070. return 0;
  1071. }
  1072.  
  1073. stock CreateOrganizationZone(orgname[32], Float:minx,Float:miny,Float:maxx,Float:maxy, color)
  1074. {
  1075. if (!DoesOrgExist(orgname)) return printf("Error: You are attempting to create a gangzone for '%s' which does not exist", orgname);
  1076.  
  1077. new orgid = GetOrgID(orgname);
  1078. Organization[orgid][ZonesCreated]++;
  1079. if (Organization[orgid][ZonesCreated] >= MAX_ZONES_PER_ORG) return printf("Error: You are attempting to create more than %d zones for %s", MAX_ZONES_PER_ORG, orgname);
  1080. new id = Organization[orgid][ZonesCreated];
  1081. Organization[orgid][ZoneMinX][id] = minx;
  1082. Organization[orgid][ZoneMinY][id] = miny;
  1083. Organization[orgid][ZoneMaxX][id] = maxx;
  1084. Organization[orgid][ZoneMaxY][id] = maxy;
  1085. Organization[orgid][ZoneColor][id] = hexToDec(color);
  1086. Organization[orgid][Zones][id] = GangZoneCreate(minx, miny, maxx, maxy);
  1087. ZoneCount++;
  1088. return ZoneCount;
  1089. }
  1090.  
  1091.  
  1092. stock hexToDec(hex) { new out[11]; format(out, 11, "%i", hex); return strval(out); }
  1093.  
  1094.  
  1095. stock IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY)
  1096. {
  1097. new Float:AX, Float:AY, Float:AZ;
  1098. GetPlayerPos(playerid, AX, AY, AZ);
  1099. if (AX > MinX && AX < MaxX && AY > MinY && AY < MaxY) return true;
  1100. else return false;
  1101. }
  1102. AntiDeAMX()
  1103. {
  1104. new a[][] =
  1105. {
  1106. "Unarmed (Fist)",
  1107. "Brass K"
  1108. };
  1109. #pragma unused a
  1110. }
  1111.  
  1112. stock IsPlayerInOrgZone(playerid, orgname[32])
  1113. {
  1114. new orgid = GetOrgID(orgname);
  1115. if (DoesOrgExist(orgname))
  1116. {
  1117. for (new i=1;i<ZoneCount+1;i++)
  1118. {
  1119. if (Organization[orgid][ZoneMinX][i] != 0.0)
  1120. {
  1121. if (IsPlayerInArea(playerid, Organization[orgid][ZoneMinX][i],Organization[orgid][ZoneMinY][i],Organization[orgid][ZoneMaxX][i],Organization[orgid][ZoneMaxY][i]))
  1122. {
  1123. return 1;
  1124. }
  1125. }
  1126. }
  1127. }
  1128. return 0;
  1129. }
  1130.  
  1131. stock SendClientMessageToOrg(orgname[32], clr, msg[])
  1132. {
  1133. if (!DoesOrgExist(orgname)) return 0;
  1134.  
  1135. for (new a=0;a<MAX_PLAYERS;a++)
  1136. {
  1137. if (IsPlayerConnected(a))
  1138. {
  1139. if (PlayerOrg[a] == GetOrgID(orgname))
  1140. {
  1141. SendClientMessage(a, clr, msg);
  1142. }
  1143. }
  1144. }
  1145. return 1;
  1146. }
  1147. /*
  1148. stock sscanf(string[], format[], {Float,_}:...)
  1149. {
  1150. #if defined isnull
  1151. if (isnull(string))
  1152. #else
  1153. if (string[0] == 0 || (string[0] == 1 && string[1] == 0))
  1154. #endif
  1155. {
  1156. return format[0];
  1157. }
  1158. #pragma tabsize 4
  1159. new
  1160. formatPos = 0,
  1161. stringPos = 0,
  1162. paramPos = 2,
  1163. paramCount = numargs(),
  1164. delim = ' ';
  1165. while (string[stringPos] && string[stringPos] <= ' ')
  1166. {
  1167. stringPos++;
  1168. }
  1169. while (paramPos < paramCount && string[stringPos])
  1170. {
  1171. switch (format[formatPos++])
  1172. {
  1173. case '\0':
  1174. {
  1175. return 0;
  1176. }
  1177. case 'i', 'd':
  1178. {
  1179. new
  1180. neg = 1,
  1181. num = 0,
  1182. ch = string[stringPos];
  1183. if (ch == '-')
  1184. {
  1185. neg = -1;
  1186. ch = string[++stringPos];
  1187. }
  1188. do
  1189. {
  1190. stringPos++;
  1191. if ('0' <= ch <= '9')
  1192. {
  1193. num = (num * 10) + (ch - '0');
  1194. }
  1195. else
  1196. {
  1197. return -1;
  1198. }
  1199. }
  1200. while ((ch = string[stringPos]) > ' ' && ch != delim);
  1201. setarg(paramPos, 0, num * neg);
  1202. }
  1203. case 'h', 'x':
  1204. {
  1205. new
  1206. num = 0,
  1207. ch = string[stringPos];
  1208. do
  1209. {
  1210. stringPos++;
  1211. switch (ch)
  1212. {
  1213. case 'x', 'X':
  1214. {
  1215. num = 0;
  1216. continue;
  1217. }
  1218. case '0' .. '9':
  1219. {
  1220. num = (num << 4) | (ch - '0');
  1221. }
  1222. case 'a' .. 'f':
  1223. {
  1224. num = (num << 4) | (ch - ('a' - 10));
  1225. }
  1226. case 'A' .. 'F':
  1227. {
  1228. num = (num << 4) | (ch - ('A' - 10));
  1229. }
  1230. default:
  1231. {
  1232. return -1;
  1233. }
  1234. }
  1235. }
  1236. while ((ch = string[stringPos]) > ' ' && ch != delim);
  1237. setarg(paramPos, 0, num);
  1238. }
  1239. case 'c':
  1240. {
  1241. setarg(paramPos, 0, string[stringPos++]);
  1242. }
  1243. case 'f':
  1244. {
  1245. setarg(paramPos, 0, _:floatstr(string[stringPos]));
  1246. }
  1247. case 'p':
  1248. {
  1249. delim = format[formatPos++];
  1250. continue;
  1251. }
  1252. case '\'':
  1253. {
  1254. new
  1255. end = formatPos - 1,
  1256. ch;
  1257. while ((ch = format[++end]) && ch != '\'') {}
  1258. if (!ch)
  1259. {
  1260. return -1;
  1261. }
  1262. format[end] = '\0';
  1263. if ((ch = strfind(string, format[formatPos], false, stringPos)) == -1)
  1264. {
  1265. if (format[end + 1])
  1266. {
  1267. return -1;
  1268. }
  1269. return 0;
  1270. }
  1271. format[end] = '\'';
  1272. stringPos = ch + (end - formatPos);
  1273. formatPos = end + 1;
  1274. }
  1275. case 'u':
  1276. {
  1277. new
  1278. end = stringPos - 1,
  1279. id = 0,
  1280. bool:num = true,
  1281. ch;
  1282. while ((ch = string[++end]) && ch != delim)
  1283. {
  1284. if (num)
  1285. {
  1286. if ('0' <= ch <= '9')
  1287. {
  1288. id = (id * 10) + (ch - '0');
  1289. }
  1290. else
  1291. {
  1292. num = false;
  1293. }
  1294. }
  1295. }
  1296. if (num && IsPlayerConnected(id))
  1297. {
  1298. setarg(paramPos, 0, id);
  1299. }
  1300. else
  1301. {
  1302. #if !defined foreach
  1303. #define foreach(%1,%2) for (new %2 = 0; %2 < MAX_PLAYERS; %2++) if (IsPlayerConnected(%2))
  1304. #define __SSCANF_FOREACH__
  1305. #endif
  1306. string[end] = '\0';
  1307. num = false;
  1308. new
  1309. name[MAX_PLAYER_NAME];
  1310. id = end - stringPos;
  1311. foreach (Player, playerid)
  1312. {
  1313. GetPlayerName(playerid, name, sizeof (name));
  1314. if (!strcmp(name, string[stringPos], true, id))
  1315. {
  1316. setarg(paramPos, 0, playerid);
  1317. num = true;
  1318. break;
  1319. }
  1320. }
  1321. if (!num)
  1322. {
  1323. setarg(paramPos, 0, INVALID_PLAYER_ID);
  1324. }
  1325. string[end] = ch;
  1326. #if defined __SSCANF_FOREACH__
  1327. #undef foreach
  1328. #undef __SSCANF_FOREACH__
  1329. #endif
  1330. }
  1331. stringPos = end;
  1332. }
  1333. case 's', 'z':
  1334. {
  1335. new
  1336. i = 0,
  1337. ch;
  1338. if (format[formatPos])
  1339. {
  1340. while ((ch = string[stringPos++]) && ch != delim)
  1341. {
  1342. setarg(paramPos, i++, ch);
  1343. }
  1344. if (!i)
  1345. {
  1346. return -1;
  1347. }
  1348. }
  1349. else
  1350. {
  1351. while ((ch = string[stringPos++]))
  1352. {
  1353. setarg(paramPos, i++, ch);
  1354. }
  1355. }
  1356. stringPos--;
  1357. setarg(paramPos, i, '\0');
  1358. }
  1359. default:
  1360. {
  1361. continue;
  1362. }
  1363. }
  1364. while (string[stringPos] && string[stringPos] != delim && string[stringPos] > ' ')
  1365. {
  1366. stringPos++;
  1367. }
  1368. while (string[stringPos] && (string[stringPos] == delim || string[stringPos] <= ' '))
  1369. {
  1370. stringPos++;
  1371. }
  1372. paramPos++;
  1373. }
  1374. do
  1375. {
  1376. if ((delim = format[formatPos++]) > ' ')
  1377. {
  1378. if (delim == '\'')
  1379. {
  1380. while ((delim = format[formatPos++]) && delim != '\'') {}
  1381. }
  1382. else if (delim != 'z')
  1383. {
  1384. return delim;
  1385. }
  1386. }
  1387. }
  1388. while (delim > ' ');
  1389. return 0;
  1390. }*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement