Advertisement
Guest User

X337 Gang System

a guest
Jul 24th, 2015
4,720
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.           X337 SIMPLE GANG SYSTEM
  3.     Required Plugins : sscanf, mysql R39-2
  4. */
  5. #include <a_samp> // SA-MP Team
  6. #include <a_mysql> // BlueG
  7. #include <sscanf> // Y-Less
  8. #include <YSI\y_iterate> // Y-Less
  9. #include <YSI\y_areas> // Y-Less
  10. #include <zcmd> // Zeex
  11.  
  12. /*
  13.                             DATABASE CONNECTION
  14.     You must define database connection below and recompile this filterscript
  15. */
  16. #define HOSTNAME        "localhost"
  17. #define USERNAME        "root"
  18. #define PASSWORD        ""
  19. #define DATABASENAME    "lscnr"
  20. /*
  21.     -------------------------------------------------------------------------
  22. */
  23.  
  24.  
  25. #define AUTOSAVE                    30 // Save Player, Gangs, Zones data automatically! (In - Minutes);
  26. #define MAX_ZONES                   100 // Maximum Gang Zone
  27. #define MAX_GANGS                   100 // Maximum Gang
  28. #define CAPTURE_TIME                60 // Capture Time
  29. #define LOCKED_MINUTES              10
  30. #define DIALOG_UNUSED               1337 // Dialog ID
  31. #define DEFAULT_ZONE_COLOR          "000000AA" // Default hex colour for gang zone
  32. #define REQUIRED_SCORE              9999999 // Required score to make a new gang
  33. #define MAX_GANG_MEMBER             8 // Maximum gang member
  34. #undef  MAX_PLAYERS
  35.     #define MAX_PLAYERS             50 // MAX_PLAYERS
  36. #define DIALOG_SAVEZONE             DIALOG_UNUSED+1
  37. #define DIALOG_CREATEGANG           DIALOG_UNUSED+2
  38. #define DIALOG_GANGTAG              DIALOG_UNUSED+3
  39. #define DIALOG_GANGCOLOUR           DIALOG_UNUSED+4
  40. #define DIALOG_HEXCOLOUR            DIALOG_UNUSED+5
  41. #define DIALOG_CREATEGANG_CONFIRM   DIALOG_UNUSED+6
  42. #define DIALOG_GCP                  DIALOG_UNUSED+7
  43. #define strcpy(%0,%1) \
  44.     strcat((%0[0] = '\0', %0), %1)
  45. #define GANG_MEMBER                 1
  46. #define GANG_STAFF                  2
  47. #define GANG_LEADER                 3
  48.  
  49. enum _gangzone
  50. {
  51.     ZoneID,
  52.     Float:ZoneMinPos[2],
  53.     Float:ZoneMaxPos[2],
  54.     ZoneOwner,
  55.     ZoneName[50],
  56.     ZoneHolder,
  57.     ZoneArea,
  58.     ZoneLocked,
  59.     bool:ZoneStatus,
  60.     ZoneTimer
  61. }
  62. enum _player
  63. {
  64.     PlayerID,
  65.     bool:CreatingZone,
  66.     PlayerText:TDZone[2],
  67.     PlayerGang,
  68.     PlayerStatus,
  69.     GangRequest,
  70.     PlayerText:CaptureTD[2]
  71. }
  72. enum _gang
  73. {
  74.     GangID,
  75.     GangColor[7],
  76.     GangName[30],
  77.     GangTag[4],
  78.     GangScore,
  79.     CurrentZone,
  80.     GangTimer  
  81. }
  82.  
  83. new Player[MAX_PLAYERS][_player],
  84. GangZone[MAX_ZONES][_gangzone],
  85. Gang[MAX_GANGS][_gang],
  86. Iterator:GangZones<MAX_ZONES>,
  87. Iterator:Gangs<MAX_GANGS>,
  88. Float:MinPos[MAX_PLAYERS][2],
  89. Float:MaxPos[MAX_PLAYERS][2],
  90. PlayerZone[MAX_PLAYERS],
  91. TempGangName[MAX_PLAYERS][30],
  92. TempGangTag[MAX_PLAYERS][4],
  93. TempGangColour[MAX_PLAYERS][7],
  94. connection,
  95. AutoSaveTimer;
  96.  
  97. stock bool:CheckGang(gangid)
  98. {
  99.     new total = 0, query[128];
  100.     mysql_format(connection, query, sizeof(query), "SELECT count(*) AS `total` FROM `member` WHERE `gang` = %d", Gang[gangid][GangID]);
  101.     mysql_query(connection, query, true);
  102.     total = (cache_num_rows() > 0) ? cache_get_field_content_int(0, "total") : 0;
  103.     return (total >= MAX_GANG_MEMBER) ? false : true;
  104. }
  105.  
  106. stock IsAlpha(const string[])
  107. {
  108.     for(new i = 0; i < strlen(string); i++)
  109.     {
  110.         if(string[i] == 45 || (string[i] >= 48 && string[i] <= 57) || (string[i] >= 65 && string[i] <= 90) || (string[i] >= 97 && string[i] <= 122))
  111.             continue;
  112.        
  113.         return false;
  114.     }
  115.     return true;
  116. }
  117.  
  118. stock HexToInt(string[]) // DracoBlue
  119. {
  120.     if (string[0] == 0) return 0;
  121.     new i, cur=1, res = 0;
  122.     for (i=strlen(string);i>0;i--) {
  123.         if (string[i-1]<58) res=res+cur*(string[i-1]-48); else res=res+cur*(string[i-1]-65+10);
  124.  
  125.         cur=cur*16;
  126.     }
  127.     return res;
  128. }
  129.  
  130. stock GetGangID(id)
  131. {
  132.     foreach(new i : Gangs)
  133.         if(Gang[i][GangID] == id)
  134.             return i;
  135.     return -1;
  136. }
  137.  
  138. stock GetID(const name[])
  139. {
  140.     foreach(new i : Player)
  141.     {
  142.         if(!strcmp(name, Name(i)))
  143.             return i;
  144.     }
  145.     return -1;
  146. }
  147.  
  148. SaveStats(playerid)
  149. {
  150.     new query[128], name[MAX_PLAYER_NAME], i = Player[playerid][PlayerGang];
  151.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  152.     if(Iter_Contains(Gangs, i) && i != -1)
  153.         mysql_format(connection, query, sizeof(query), "UPDATE `member` SET `gang` = %d, `status` = %d, `name` = '%e' WHERE `id` = '%d'", Gang[i][GangID], Player[playerid][PlayerStatus], name, Player[playerid][PlayerID]);
  154.     else
  155.         mysql_format(connection, query, sizeof(query), "UPDATE `member` SET `gang` = -1, `name` = '%e' WHERE `id` = %d", name, Player[playerid][PlayerID]);
  156.     mysql_query(connection, query, false);
  157.     return 1;
  158. }
  159.  
  160. SaveGang(i)
  161. {
  162.     new query[128];
  163.     mysql_format(connection, query, sizeof(query), "UPDATE `gang` SET `color` = '%e', `score` = %d WHERE `id` = '%d'", Gang[i][GangColor], Gang[i][GangScore], Gang[i][GangID]);
  164.     mysql_query(connection, query, false);
  165.     return 1;
  166. }
  167.  
  168. SaveZone(i)
  169. {
  170.     if(GangZone[i][ZoneOwner] != -1 && Iter_Contains(Gangs, GangZone[i][ZoneOwner]))
  171.     {
  172.         new query[128];
  173.         mysql_format(connection, query, sizeof(query), "UPDATE `zone` SET `owner` = '%d' WHERE `id` = '%d'", Gang[GangZone[i][ZoneOwner]][GangID], GangZone[i][ZoneID]);
  174.         mysql_query(connection, query, false);
  175.     }
  176.     return 1;
  177. }
  178.  
  179. LoadPlayerGang(playerid)
  180. {
  181.     Player[playerid][PlayerGang] = -1;
  182.     Player[playerid][PlayerStatus] = GANG_MEMBER;
  183.     Player[playerid][GangRequest] = -1;
  184.     new name[MAX_PLAYER_NAME], query[128];
  185.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  186.     mysql_format(connection, query, sizeof(query), "SELECT * FROM `member` WHERE `name` = '%e'", name);
  187.     mysql_query(connection, query, true);
  188.     new count = cache_num_rows();
  189.     if(count > 0)
  190.     {
  191.         new id = cache_get_field_content_int(0, "gang");
  192.         foreach(new i : Gangs)
  193.         {
  194.             if(Gang[i][GangID] == id)
  195.             {
  196.                 Player[playerid][PlayerGang] = i;
  197.                 break;
  198.             }
  199.         }
  200.         Player[playerid][PlayerStatus] = cache_get_field_content_int(0, "status");
  201.         Player[playerid][PlayerID] = cache_get_field_content_int(0, "id");
  202.     }
  203.     else
  204.     {
  205.         mysql_format(connection, query, sizeof(query), "INSERT INTO `member`(`name`) VALUES ('%e')", name);
  206.         mysql_query(connection, query, true);
  207.         Player[playerid][PlayerID] = cache_insert_id();
  208.     }
  209.     return 1;  
  210. }
  211.  
  212. SendGangMessage(i, msg[])
  213. {
  214.     foreach(new p : Player)
  215.     {
  216.         if(i == Player[p][PlayerGang])
  217.             SendClientMessage(p, -1, msg);
  218.     }
  219.     return 1;
  220. }
  221.  
  222. stock Name(playerid)
  223. {
  224.     new name[MAX_PLAYER_NAME];
  225.     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  226.     return name;
  227. }
  228.  
  229. public OnFilterScriptInit()
  230. {
  231.     print("\n\n\n========================================================");
  232.     print("||                 X-Gang System by X337               ||");
  233.     connection = mysql_connect(HOSTNAME, USERNAME, DATABASENAME, PASSWORD);
  234.     if(mysql_errno(connection) != 0)
  235.     {
  236.         print("\n++++++++++++++++++    WARNING    ++++++++++++++++++++++\n");
  237.         print("X-Gang System Filterscript failed to connect to database !\n");
  238.         print("++++++++++++++++++    WARNING    ++++++++++++++++++++++\n");
  239.         SendRconCommand("unloadfs X-Gang");
  240.     }
  241.     else
  242.     {
  243.         mysql_log(LOG_ERROR | LOG_WARNING, LOG_TYPE_HTML);
  244.         print("||           Succesfully connected to database !       ||");
  245.         mysql_query(connection, "SELECT * FROM `zone`", true);
  246.         new count = cache_num_rows(), TempString[56], time = GetTickCount(), i;
  247.         for(new z = 0; z < count; z++)
  248.         {
  249.             i = Iter_Free(GangZones);
  250.             GangZone[i][ZoneMinPos][0] = cache_get_field_content_float(z, "minx");
  251.             GangZone[i][ZoneMinPos][1] = cache_get_field_content_float(z, "miny");
  252.             GangZone[i][ZoneMaxPos][0] = cache_get_field_content_float(z, "maxx");
  253.             GangZone[i][ZoneMaxPos][1] = cache_get_field_content_float(z, "maxy");
  254.             GangZone[i][ZoneOwner]  = GetGangID(cache_get_field_content_int(z, "owner"));
  255.             GangZone[i][ZoneID] = cache_get_field_content_int(z, "id");
  256.             cache_get_field_content(z, "name", TempString);
  257.             format(GangZone[i][ZoneName], 50, "%s", TempString);
  258.             GangZone[i][ZoneArea] = Area_AddBox(GangZone[i][ZoneMinPos][0], GangZone[i][ZoneMinPos][1], GangZone[i][ZoneMaxPos][0], GangZone[i][ZoneMaxPos][1]);
  259.             GangZone[i][ZoneHolder] = GangZoneCreate(GangZone[i][ZoneMinPos][0], GangZone[i][ZoneMinPos][1], GangZone[i][ZoneMaxPos][0], GangZone[i][ZoneMaxPos][1]);
  260.             GangZone[i][ZoneLocked] = 0;
  261.             GangZone[i][ZoneStatus] = false;
  262.             Iter_Add(GangZones, i);
  263.         }
  264.         printf("||         %d Zone(s) Succesfully Loaded!!! (%d ms)     ||", count, (GetTickCount() - time));
  265.         mysql_query(connection, "SELECT * FROM `gang`", true);
  266.         count = cache_num_rows(), time = GetTickCount();
  267.         for(new z = 0; z < count; z++)
  268.         {
  269.             i = Iter_Free(Gangs);
  270.             Gang[i][GangID] = cache_get_field_content_int(z, "id");
  271.             Gang[i][GangScore] = cache_get_field_content_int(z, "score");
  272.             Gang[i][CurrentZone] = -1;
  273.             cache_get_field_content(z, "name", TempString);
  274.             format(Gang[i][GangName], 30, "%s", TempString);
  275.             cache_get_field_content(z, "color", TempString);
  276.             format(Gang[i][GangColor], 7, "%s", TempString);
  277.             cache_get_field_content(z, "tag", TempString);
  278.             format(Gang[i][GangTag], 4, "%s", TempString);
  279.             Iter_Add(Gangs, i);
  280.         }
  281.         printf("||         %d Gang(s) Succesfully Loaded!!! (%d ms)     ||", count, (GetTickCount() - time));
  282.         print("========================================================");
  283.         foreach(new p : Player)
  284.         {
  285.             CallLocalFunction("OnPlayerConnect", "d", p);
  286.         }
  287.         AutoSaveTimer = SetTimer("AutoSave", AUTOSAVE * 60000, true);
  288.     }
  289.     return 1;
  290. }
  291.  
  292. public OnFilterScriptExit()
  293. {
  294.     AutoSave();
  295.     foreach(new i : GangZones)
  296.     {
  297.         GangZoneDestroy(GangZone[i][ZoneHolder]);
  298.         Area_Delete(GangZone[i][ZoneArea]);
  299.     }
  300.     Iter_Clear(GangZones);
  301.     foreach(new i : Player)
  302.     {
  303.         PlayerTextDrawHide(i, Player[i][TDZone][0]);
  304.         PlayerTextDrawHide(i, Player[i][TDZone][1]);
  305.     }
  306.     KillTimer(AutoSaveTimer);
  307.     print("X-Gang System Filterscript unloaded!\n");
  308.     return 1;
  309. }
  310.  
  311. COMMAND:creategang(playerid, params[])
  312. {
  313.     if(GetPlayerScore(playerid) >= REQUIRED_SCORE)
  314.     {
  315.         if(Player[playerid][PlayerGang] == -1)
  316.             ShowPlayerDialog(playerid, DIALOG_CREATEGANG, DIALOG_STYLE_INPUT, "X337 Gang System - Gang Name", "Insert the gang name below :", "Submit", "Cancel");
  317.         else
  318.             SendClientMessage(playerid, -1, "{FF0000}You already in gang!");
  319.     }
  320.     else
  321.     {
  322.         new string[128];
  323.         format(string, sizeof(string), "{FF0000}You need %d score to create a gang!", REQUIRED_SCORE);
  324.         SendClientMessage(playerid, -1, string);
  325.     }
  326.     return 1;
  327. }
  328.  
  329. COMMAND:gangcolor(playerid, params[])
  330. {
  331.     new i = Player[playerid][PlayerGang];
  332.     if(i != -1)
  333.     {
  334.         new color[7];
  335.         if(sscanf(params, "h", color) || strlen(params) != 6)
  336.             SendClientMessage(playerid, -1, "{FF0000}Invalid hex color!");
  337.         else
  338.         {
  339.             new msg[56];
  340.             format(msg, sizeof(msg), "{%s}Your gang color has been changed!", params);
  341.             SendClientMessage(playerid, -1, msg);
  342.             format(Gang[i][GangColor], 7, "%s", params);
  343.         }
  344.     }
  345.     else
  346.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang leader to use this command!");
  347.     return 1;
  348. }
  349.  
  350. COMMAND:changeleader(playerid, params[])
  351. {
  352.     if(Player[playerid][PlayerGang] != -1)
  353.     {
  354.         if(Player[playerid][PlayerStatus] == GANG_LEADER)
  355.         {
  356.             new id;
  357.             if(sscanf(params, "u", id))
  358.             {
  359.                 SendClientMessage(playerid, -1, "{FF0000}Usage : /changeleader <playerid>");
  360.             }
  361.             else
  362.             {
  363.                 if(IsPlayerConnected(id))
  364.                 {
  365.                     if(Player[playerid][PlayerGang] == Player[id][PlayerGang])
  366.                     {
  367.                         Player[playerid][PlayerStatus] = GANG_MEMBER;
  368.                         Player[id][PlayerStatus] = GANG_LEADER;
  369.                         new msg[56];
  370.                         format(msg, sizeof(msg), "{FF0000}Succesfully promoted %s as new gang leader!", Name(id));
  371.                         SendClientMessage(playerid, -1, msg);
  372.                         SendClientMessage(id, -1, "{FF0000}You have been promoted as new gang leader!");
  373.                         SaveStats(id);
  374.                         SaveStats(playerid);
  375.                     }
  376.                     else
  377.                         SendClientMessage(playerid, -1, "{FF0000}That player isn't your gang member!");
  378.                 }
  379.                 else
  380.                     SendClientMessage(playerid, -1, "{FF0000}That player isn't connected!");
  381.             }
  382.         }
  383.         else
  384.             SendClientMessage(playerid, -1, "{FF0000}You must be a gang leader to use this command!");
  385.     }
  386.     else
  387.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang member to use this command!");
  388.     return 1;
  389. }
  390.  
  391. COMMAND:territory(playerid, params[])
  392. {
  393.     new msg[512], p;
  394.     foreach(new i : GangZones)
  395.     {
  396.         p = GangZone[i][ZoneOwner];
  397.         if(p == -1)
  398.             format(msg, sizeof(msg), "%s{B7B7B7}%s (-)\n", msg, GangZone[i][ZoneName]);
  399.         else
  400.             format(msg, sizeof(msg), "%s{%s}%s (%s)\n", msg, Gang[p][GangColor], GangZone[i][ZoneName], Gang[p][GangName]);
  401.     }
  402.     ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Territory", msg, "Close", "");
  403.     return 1;
  404. }
  405.  
  406. COMMAND:gangmembers(playerid, params[])
  407. {
  408.     new i = Player[playerid][PlayerGang];
  409.     if(i != -1)
  410.     {
  411.         new query[256];
  412.         mysql_format(connection, query, sizeof(query), "SELECT * FROM `member` WHERE `gang` = %d", Gang[i][GangID]);
  413.         mysql_query(connection, query, true);
  414.         format(query, sizeof(query), "{FFFFFF}");
  415.         new count = cache_num_rows();
  416.         if(count > 0)
  417.         {
  418.             new TempString[MAX_PLAYER_NAME], tempid;
  419.             for(new r = 0; r < count; r++)
  420.             {
  421.                 cache_get_field_content(r, "name", TempString);
  422.                 tempid = GetID(TempString);
  423.                 format(query, sizeof(query), "%s%d. %s ", query, (r+1), TempString);
  424.                 if(IsPlayerConnected(tempid))
  425.                     strcat(query, "{FE9A2E}(ONLINE) ");
  426.                 else
  427.                     strcat(query, "{FF0000}(OFFLINE) ");
  428.                 if(cache_get_field_content_int(r, "status") == GANG_LEADER)
  429.                     strcat(query, "{58D3F7} (LEADER) ");
  430.                 if(cache_get_field_content_int(r, "status") == GANG_STAFF)
  431.                     strcat(query, "{58D3F7} (STAFF) ");
  432.                 strcat(query, "\n{FFFFFF}");
  433.             }
  434.             ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Gang Members", query, "Close", "");
  435.         }
  436.     }
  437.     else
  438.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang member to use this command!");
  439.     return 1;
  440. }
  441.  
  442. COMMAND:gcp(playerid, params[])
  443. {
  444.     new i = Player[playerid][PlayerGang];
  445.     if(i != -1)
  446.     {
  447.         if(Iter_Contains(Gangs, i))
  448.         {
  449.             new msg[256];
  450.             format(msg, sizeof(msg), "{FFFFFF}Gang Name : {%s}%s {FFFFFF}", Gang[i][GangColor], Gang[i][GangName]);
  451.             format(msg, sizeof(msg), "%s\nGang Tag : [%s]", msg, Gang[i][GangTag]);
  452.             format(msg, sizeof(msg), "%s\nGang Score : %d", msg, Gang[i][GangScore]);
  453.             format(msg, sizeof(msg), "%s\n{B7B7B7}Gang Member", msg);
  454.             format(msg, sizeof(msg), "%s\n{B7B7B7}Territory", msg);
  455.             ShowPlayerDialog(playerid, DIALOG_GCP, DIALOG_STYLE_LIST, "Gang Control Panel", msg, "Chooose", "Cancel");
  456.         }
  457.     }
  458.     else
  459.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang member to use this command!");
  460.     return 1;
  461. }
  462.  
  463. COMMAND:leavegang(playerid, params[])
  464. {
  465.     new i = Player[playerid][PlayerGang];
  466.     if(i != -1)
  467.     {
  468.         if(Player[playerid][PlayerStatus] != GANG_LEADER)
  469.         {
  470.             new msg[56];
  471.             format(msg, sizeof(msg), "{FF0000}%s left the gang!", Name(playerid));
  472.             SendGangMessage(Player[playerid][PlayerGang], msg);
  473.             Player[playerid][PlayerGang] = -1;
  474.             SaveStats(playerid);
  475.         }
  476.         else
  477.             SendClientMessage(playerid, -1, "{FF0000}Gang leader can't use this command!");
  478.     }
  479.     return 1;
  480. }
  481.  
  482. COMMAND:disbandgang(playerid, params[])
  483. {
  484.     new i = Player[playerid][PlayerGang];
  485.     if(i != -1)
  486.     {
  487.         if(Player[playerid][PlayerStatus] == GANG_LEADER)
  488.         {
  489.             if(Gang[i][CurrentZone] == -1)
  490.             {
  491.                 new query[256];
  492.                 format(query, sizeof(query), "{FF0000}%s has disbanded the gang!", Name(playerid));
  493.                 SendGangMessage(i, query);
  494.                 mysql_format(connection, query, sizeof(query), "DELETE FROM `gang` WHERE `id` = %d", Gang[i][GangID]);
  495.                 mysql_query(connection, query, false);
  496.                 foreach(new p : Player)
  497.                 {
  498.                     if(Player[p][PlayerGang] == i)
  499.                     {
  500.                         Player[p][PlayerGang] = -1;
  501.                         Player[p][PlayerStatus] = GANG_MEMBER;
  502.                     }
  503.                 }
  504.                 mysql_format(connection, query, sizeof(query), "UPDATE `member` SET `gang` = -1, `status` = 1 WHERE `gang` = %d", Gang[i][GangID]);
  505.                 mysql_query(connection, query, false);
  506.                 Iter_Remove(Gangs, i);
  507.                 foreach(new p : GangZones)
  508.                 {
  509.                     if(GangZone[p][ZoneOwner] == i)
  510.                     {
  511.                         GangZone[p][ZoneOwner] = -1;
  512.                         GangZoneShowForAll(GangZone[p][ZoneHolder], HexToInt(DEFAULT_ZONE_COLOR));
  513.                     }
  514.                 }
  515.             }
  516.         }
  517.         else
  518.             SendClientMessage(playerid, -1, "{FF0000}You must be gang leader to use this command!!");
  519.     }
  520.     else
  521.         SendClientMessage(playerid, -1, "{FF0000}You must be gang leader to use this command!!");
  522.     return 1;
  523. }
  524.  
  525. COMMAND:topgang(playerid, params[])
  526. {
  527.     new query[128];
  528.     mysql_format(connection, query, sizeof(query), "SELECT * FROM `gang` ORDER BY `score` DESC LIMIT 20");
  529.     mysql_query(connection, query, true);
  530.     new ganglist[512], count = cache_num_rows(), TempColor[7], TempName[30];
  531.     if(count != 0)
  532.     {
  533.         for(new i = 0; i < count; i++)
  534.         {
  535.             cache_get_field_content(i, "color", TempColor);
  536.             cache_get_field_content(i, "name", TempName);
  537.             format(ganglist, sizeof(ganglist), "%s%d. {%s}%s {FFFFFF}- Score : %d\n", ganglist, (i+1), TempColor, TempName, cache_get_field_content_int(i, "score"));
  538.         }
  539.         format(ganglist, sizeof(ganglist), "%s\n* This top list updated every %d minutes", ganglist, AUTOSAVE);
  540.         ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "Top Gangs", ganglist, "Close", "");
  541.     }
  542.     else
  543.         SendClientMessage(playerid, -1, "{FF0000}There's no gangs present!");
  544.     return 1;
  545. }
  546.  
  547. COMMAND:gangrank(playerid, params[])
  548. {
  549.     new TempName[30];
  550.     if(sscanf(params, "s[30]", TempName))
  551.     {
  552.         SendClientMessage(playerid, -1, "{FF0000}Usage : /gangrank <gang name>");
  553.     }
  554.     else
  555.     {
  556.         new query[512];
  557.         mysql_format(connection, query, sizeof(query), "SELECT `rank` FROM (SELECT `name`,`score`, @current := @current + 1 as `rank` from `gang`, (select @current := 0) r order by `score` desc) z WHERE `name` = '%e'", TempName);
  558.         mysql_query(connection, query, true);
  559.         if(cache_num_rows() != 0)
  560.         {
  561.             new msg[56];
  562.             format(msg, sizeof(msg), "{FF0000}%s - {FFFF00}Rank : %d", TempName, cache_get_field_content_int(0, "rank"));
  563.             SendClientMessage(playerid, -1, msg);
  564.         }
  565.         else
  566.             SendClientMessage(playerid, -1, "404! Gang name not found!");
  567.     }
  568.     return 1;
  569. }
  570.  
  571. COMMAND:promotestaff(playerid, params[])
  572. {
  573.     if(Player[playerid][PlayerStatus] == GANG_LEADER)
  574.     {
  575.         new id;
  576.         if(sscanf(params, "u", id))
  577.         {
  578.             SendClientMessage(playerid, -1, "{FF0000}Usage : /promotestaff <playerid>");
  579.         }
  580.         else
  581.         {
  582.             if(IsPlayerConnected(id))
  583.             {
  584.                 if(Player[id][PlayerGang] == Player[playerid][PlayerGang])
  585.                 {
  586.                     if(id != playerid)
  587.                     {
  588.                         if(Player[id][PlayerStatus] != GANG_STAFF)
  589.                         {
  590.                             SendClientMessage(playerid, -1, "{FF0000}Succesfully promoted a gang staff!");
  591.                             SendClientMessage(id, -1, "{FF0000}You have been promoted as a gang staff!");
  592.                             Player[id][PlayerStatus] = GANG_STAFF;
  593.                             SaveStats(id);
  594.                         }
  595.                         else
  596.                             SendClientMessage(playerid, -1, "{FF0000}That player already a gang staff!");
  597.                     }
  598.                     else
  599.                         SendClientMessage(playerid, -1, "{FF0000}You can't promote yourself!");
  600.                 }
  601.                 else
  602.                     SendClientMessage(playerid, -1, "{FF0000}That player isn't your gang member!");
  603.             }
  604.             else
  605.                 SendClientMessage(playerid, -1, "{FF0000}That player isn't connected!");
  606.         }
  607.     }
  608.     else
  609.         SendClientMessage(playerid, -1, "{FF0000}You must be gang leader to use this command!!");
  610.     return 1;
  611. }
  612.  
  613. COMMAND:demotestaff(playerid, params[])
  614. {
  615.     if(Player[playerid][PlayerStatus] == GANG_LEADER)
  616.     {
  617.         new id;
  618.         if(sscanf(params, "u", id))
  619.         {
  620.             SendClientMessage(playerid, -1, "{FF0000}Usage : /demotestaff <playerid>");
  621.         }
  622.         else
  623.         {
  624.             if(IsPlayerConnected(id))
  625.             {
  626.                 if(Player[id][PlayerGang] == Player[playerid][PlayerGang])
  627.                 {
  628.                     if(id != playerid)
  629.                     {
  630.                         if(Player[id][PlayerStatus] == GANG_STAFF)
  631.                         {
  632.                             SendClientMessage(playerid, -1, "{FF0000}Succesfully promoted a gang staff!");
  633.                             SendClientMessage(id, -1, "{FF0000}You have been demoted from gang staff!");
  634.                             Player[id][PlayerStatus] = GANG_MEMBER;
  635.                             SaveStats(id);
  636.                         }
  637.                         else
  638.                             SendClientMessage(playerid, -1, "{FF0000}That player isn't a gang staff!");
  639.                     }
  640.                     else
  641.                         SendClientMessage(playerid, -1, "{FF0000}You can't demote yourself!");
  642.                 }
  643.                 else
  644.                     SendClientMessage(playerid, -1, "{FF0000}That player isn't your gang member!");
  645.             }
  646.             else
  647.                 SendClientMessage(playerid, -1, "{FF0000}That player isn't connected!");
  648.         }
  649.     }
  650.     else
  651.         SendClientMessage(playerid, -1, "{FF0000}You must be gang leader to use this command!!");
  652.     return 1;
  653. }
  654.  
  655. COMMAND:createzone(playerid, params[])
  656. {
  657.     if(IsPlayerAdmin(playerid))
  658.     {
  659.         if(GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
  660.         {
  661.             if(!Player[playerid][CreatingZone])
  662.             {
  663.                 new Float:z;
  664.                 Player[playerid][CreatingZone] = true;
  665.                 new msg[128];
  666.                 format(msg, sizeof(msg), "Gangzone Mode! Use arrow keys to make the zone bigger or less");
  667.                 SendClientMessage(playerid, -1, msg);
  668.                 format(msg, sizeof(msg), "Using ~k~~PED_FIREWEAPON~ + Arrow keys you minus the height or width.");
  669.                 SendClientMessage(playerid, -1, msg);
  670.                 format(msg, sizeof(msg), "Press ~k~~VEHICLE_ENTER_EXIT~ when you are done!");
  671.                 SendClientMessage(playerid, -1, msg);
  672.                 GetPlayerPos(playerid, MinPos[playerid][0], MinPos[playerid][1], z);
  673.                 GetPlayerPos(playerid, MaxPos[playerid][0], MaxPos[playerid][1], z);
  674.                 TogglePlayerControllable(playerid, false);
  675.             }
  676.             else
  677.                 SendClientMessage(playerid, -1, "You already in create zone mode, /cancelzone to cancel");
  678.         }
  679.         else
  680.             SendClientMessage(playerid, -1, "You must be onfoot to create gang zone");
  681.     }
  682.     else
  683.         SendClientMessage(playerid, -1, "{FF0000}You must be RCON admin to use this command!");
  684.     return 1;
  685. }
  686.  
  687. COMMAND:ganginvite(playerid, params[])
  688. {
  689.     new p;
  690.     if(Player[playerid][PlayerStatus] == GANG_LEADER && Player[playerid][PlayerGang] != -1)
  691.     {
  692.         if(sscanf(params, "d", p))
  693.         {
  694.             SendClientMessage(playerid, -1, "{FF0000}Usage : /ganginvite <playerid>");
  695.         }
  696.         else
  697.         {
  698.             if(IsPlayerConnected(p))
  699.             {
  700.                 if(Player[p][PlayerGang] == -1)
  701.                 {
  702.                     if(CheckGang(Player[playerid][PlayerGang]))
  703.                     {
  704.                         new msg[128];
  705.                         format(msg, sizeof(msg), "%s want you to join %s gang! (/acceptgang)", Name(playerid), Gang[Player[playerid][PlayerGang]][GangName]);
  706.                         SendClientMessage(p, -1, msg);
  707.                         format(msg, sizeof(msg), "You have invited %s to join your gang!", Name(p));
  708.                         SendClientMessage(playerid, -1, msg);
  709.                         Player[p][GangRequest] = Player[playerid][PlayerGang];
  710.                     }
  711.                     else
  712.                         SendClientMessage(playerid, -1, "{FF0000}Your gang member is full!");
  713.                 }
  714.                 else
  715.                     SendClientMessage(playerid, -1, "{FF0000}That player already a gang member!");
  716.             }
  717.             else
  718.                 SendClientMessage(playerid, -1, "{FF0000}That player isn't connected!");
  719.         }
  720.     }
  721.     else
  722.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang leader to use this command!");
  723.     return 1;
  724. }
  725.  
  726. COMMAND:acceptgang(playerid, params[])
  727. {
  728.     if(Player[playerid][PlayerGang] == -1)
  729.     {
  730.         if(Player[playerid][GangRequest] != -1)
  731.         {
  732.             if(Iter_Contains(Gangs, Player[playerid][GangRequest]))
  733.             {
  734.                 if(CheckGang(Player[playerid][GangRequest]))
  735.                 {
  736.                     Player[playerid][PlayerGang] = Player[playerid][GangRequest];
  737.                     Player[playerid][GangRequest] = -1;
  738.                     Player[playerid][PlayerStatus] = GANG_MEMBER;
  739.                     new msg[56];
  740.                     format(msg, sizeof(msg), "%s has joined the gang!", Name(playerid));
  741.                     SendGangMessage(Player[playerid][PlayerGang], msg);
  742.                 }
  743.             }
  744.             else
  745.                 SendClientMessage(playerid, -1, "{FF0000}Invalid Session!");
  746.         }
  747.     }
  748.     else
  749.         SendClientMessage(playerid, -1, "{FF0000}You already inside a gang!");
  750.     return 1;
  751. }
  752.  
  753. COMMAND:g(playerid, params[])
  754. {
  755.     new i = Player[playerid][PlayerGang];
  756.     if(i != -1)
  757.     {
  758.         new msg[128];
  759.         format(msg, sizeof(msg), "{%s}* %s(%d) {FFFFFF}: %s", Gang[i][GangColor], Name(playerid), playerid, params);
  760.         SendGangMessage(Player[playerid][PlayerGang], msg);
  761.     }
  762.     else
  763.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang member to use this command!");
  764.     return 1;
  765. }
  766.  
  767. COMMAND:capture(playerid, params[])
  768. {
  769.     if(Player[playerid][PlayerGang] != -1)
  770.     {
  771.         if(Gang[Player[playerid][PlayerGang]][CurrentZone] == -1)
  772.         {
  773.             new bool:found = false, i, total = 0, area = Area_GetPlayerAreas(playerid, 0);
  774.             foreach(i : GangZones)
  775.             {
  776.                 if(area == GangZone[i][ZoneArea])
  777.                 {
  778.                     found = true;
  779.                     break;
  780.                 }
  781.             }
  782.             if(found)
  783.             {
  784.                 if(!GangZone[i][ZoneStatus])
  785.                 {
  786.                     if(GangZone[i][ZoneOwner] != Player[playerid][PlayerGang])
  787.                     {
  788.                         new tick = GetTickCount() - GangZone[i][ZoneLocked], msg[128];
  789.                         if(tick > (60000 * LOCKED_MINUTES))
  790.                         {
  791.                             format(msg, sizeof(msg), "Capturing ~g~%s", GangZone[i][ZoneName]);
  792.                             foreach(new p : Player)
  793.                             {
  794.                                 if(Player[p][PlayerGang] == Player[playerid][PlayerGang])
  795.                                 {
  796.                                     if(Area_GetPlayerAreas(p, 0) == area)
  797.                                         total++;
  798.                                     PlayerTextDrawSetString(p, Player[p][CaptureTD][0], msg);
  799.                                     PlayerTextDrawSetString(p, Player[p][CaptureTD][1], "-");
  800.                                     PlayerTextDrawShow(p, Player[p][CaptureTD][0]);
  801.                                     PlayerTextDrawShow(p, Player[p][CaptureTD][1]);
  802.                                     Gang[Player[playerid][PlayerGang]][GangTimer] = CAPTURE_TIME;
  803.                                 }
  804.                             }
  805.                             format(msg, sizeof(msg), "{FE9A2E}** %s gang trying to capture %s zone with %d gang member!", Gang[Player[playerid][PlayerGang]][GangName], GangZone[i][ZoneName], total);
  806.                             SendClientMessageToAll(-1, msg);
  807.                             GangZone[i][ZoneStatus] = true;
  808.                             GangZone[i][ZoneTimer] = SetTimerEx("AttackZone", 1000, true, "dd", Player[playerid][PlayerGang], i);
  809.                             Gang[Player[playerid][PlayerGang]][CurrentZone] = i;
  810.                             GangZoneFlashForAll(GangZone[i][ZoneHolder], HexToInt("FF0000AA"));
  811.                             if(GangZone[i][ZoneOwner] != -1)
  812.                             {
  813.                                 format(msg, sizeof(msg), "{FF0000}* ALERT!!! %s gang trying to capture your territory in %s", Gang[Player[playerid][PlayerGang]][GangName], GangZone[i][ZoneName]);
  814.                                 SendGangMessage(GangZone[i][ZoneOwner], msg);
  815.                             }
  816.                         }
  817.                         else
  818.                         {
  819.                             format(msg, sizeof(msg), "{FF0000}This Zone is locked, please wait %.2f minute(s) to capture!", floatdiv(60000 * LOCKED_MINUTES - tick, 60 * 1000));
  820.                             SendClientMessage(playerid, -1, msg);
  821.                         }
  822.                     }
  823.                     else
  824.                         SendClientMessage(playerid, -1, "{FF0000}Your gang already owned this zone!");
  825.                 }
  826.                 else
  827.                     SendClientMessage(playerid, -1, "{FF0000}Someone is trying to capture this zone!");
  828.             }
  829.             else
  830.                 SendClientMessage(playerid, -1, "{FF0000}You must be in gang zone to use this command!");
  831.         }
  832.         else
  833.             SendClientMessage(playerid, -1, "{FF0000}Your gang already started a war, please wait!");
  834.     }
  835.     else
  836.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang member to use this command!");
  837.     return 1;
  838. }
  839.  
  840. COMMAND:okickmember(playerid, params[])
  841. {
  842.     new TempName[MAX_PLAYER_NAME];
  843.     if(sscanf(params, "s[24]", TempName))
  844.     {
  845.         SendClientMessage(playerid, -1, "{FF0000}Usage : /okickmember <member name>");
  846.     }
  847.     else
  848.     {
  849.         new query[256], i = Player[playerid][PlayerGang];
  850.         mysql_format(connection, query, sizeof(query), "SELECT * FROM `member` WHERE `name` = '%e'", TempName);
  851.         mysql_query(connection, query, true);
  852.         if(cache_num_rows() != 0)
  853.         {
  854.             if(cache_get_field_content_int(0, "gang") == Gang[i][GangID])
  855.             {
  856.                 if(cache_get_field_content_int(0, "id") != Player[playerid][PlayerID])
  857.                 {
  858.                     if(cache_get_field_content_int(0, "status") != GANG_LEADER)
  859.                     {
  860.                         mysql_format(connection, query, sizeof(query), "UPDATE `member` SET `gang` = -1, `status` = 1 WHERE `name` = '%e'", TempName);
  861.                         mysql_query(connection, query, false);
  862.                         format(query, sizeof(query), "{FF0000}%s has been kicked from gang!", TempName);
  863.                         SendGangMessage(i, query);
  864.                         new p = GetID(TempName);
  865.                         if(IsPlayerConnected(p))
  866.                         {
  867.                             SendClientMessage(p, -1, "{FF0000}You have been kicked from gang!");
  868.                             Player[p][PlayerGang] = -1;
  869.                             Player[p][PlayerStatus] = GANG_MEMBER;
  870.                         }
  871.                     }
  872.                     else
  873.                         SendClientMessage(playerid, -1, "{FF0000}You can't kick gang leader!");
  874.                 }
  875.                 else
  876.                     SendClientMessage(playerid, -1, "{FF0000}You can't kick yourself!");
  877.             }
  878.             else
  879.                 SendClientMessage(playerid, -1, "{FF0000}That player isn't in your gang!");
  880.         }
  881.         else
  882.             SendClientMessage(playerid, -1, "{FF0000}404! Name not found!");
  883.     }
  884.     return 1;
  885. }
  886.  
  887. COMMAND:kickmember(playerid, params[])
  888. {
  889.     new p;
  890.     if(Player[playerid][PlayerStatus] != GANG_MEMBER && Player[playerid][PlayerGang] != -1)
  891.     {
  892.         if(sscanf(params, "d", p))
  893.         {
  894.             SendClientMessage(playerid, -1, "{FF0000}Usage : /kickmember <playerid>");
  895.         }
  896.         else
  897.         {
  898.             if(IsPlayerConnected(p))
  899.             {
  900.                 if(Player[playerid][PlayerGang] == Player[p][PlayerGang])
  901.                 {
  902.                     if(playerid != p)
  903.                     {
  904.                         if(Player[p][PlayerStatus] != GANG_LEADER)
  905.                         {
  906.                             new msg[56], query[256];
  907.                             format(msg, sizeof(msg), "{FF0000}%s has been kicked from gang!", Name(p));
  908.                             SendGangMessage(Player[playerid][PlayerGang], msg);
  909.                             Player[p][PlayerGang] = -1;
  910.                             Player[p][PlayerStatus] = GANG_MEMBER;
  911.                             mysql_format(connection, query, sizeof(query), "UPDATE `member` SET `gang` = -1, `status` = 1 WHERE `id` = '%d'", Player[p][PlayerID]);
  912.                             mysql_query(connection, query, false);
  913.                         }
  914.                         else
  915.                             SendClientMessage(playerid, -1, "{FF0000}You can't kick gang leader!");
  916.                     }
  917.                     else
  918.                         SendClientMessage(playerid, -1, "{FF0000}You can't kick yourself!");
  919.                 }
  920.                 else
  921.                     SendClientMessage(playerid, -1, "{FF0000}That player isn't in your gang!");
  922.             }
  923.             else
  924.                 SendClientMessage(playerid, -1, "{FF0000}That player isn't connected!");
  925.         }
  926.     }
  927.     else
  928.         SendClientMessage(playerid, -1, "{FF0000}You must be a gang leader to use this command!");
  929.     return 1;
  930. }
  931.  
  932. public OnPlayerConnect(playerid)
  933. {
  934.     Player[playerid][CreatingZone] = false;
  935.     Player[playerid][TDZone][0] = CreatePlayerTextDraw(playerid, 320.000000, 376.666290, "ZONE NAME");
  936.     PlayerTextDrawLetterSize(playerid, Player[playerid][TDZone][0], 0.400000, 1.600000);
  937.     PlayerTextDrawAlignment(playerid, Player[playerid][TDZone][0], 2);
  938.     PlayerTextDrawColor(playerid, Player[playerid][TDZone][0], -1);
  939.     PlayerTextDrawSetShadow(playerid, Player[playerid][TDZone][0], 0);
  940.     PlayerTextDrawSetOutline(playerid, Player[playerid][TDZone][0], 1);
  941.     PlayerTextDrawBackgroundColor(playerid, Player[playerid][TDZone][0], 255);
  942.     PlayerTextDrawFont(playerid, Player[playerid][TDZone][0], 3);
  943.     PlayerTextDrawSetProportional(playerid, Player[playerid][TDZone][0], 1);
  944.     PlayerTextDrawSetShadow(playerid, Player[playerid][TDZone][0], 0);
  945.  
  946.     Player[playerid][TDZone][1] = CreatePlayerTextDraw(playerid, 318.000000, 391.599609, "Owned By : ~r~Unowned");
  947.     PlayerTextDrawLetterSize(playerid, Player[playerid][TDZone][1], 0.264999, 1.310666);
  948.     PlayerTextDrawAlignment(playerid, Player[playerid][TDZone][1], 2);
  949.     PlayerTextDrawColor(playerid, Player[playerid][TDZone][1], -1);
  950.     PlayerTextDrawSetShadow(playerid, Player[playerid][TDZone][1], 1);
  951.     PlayerTextDrawSetOutline(playerid, Player[playerid][TDZone][1], 0);
  952.     PlayerTextDrawBackgroundColor(playerid, Player[playerid][TDZone][1], 255);
  953.     PlayerTextDrawFont(playerid, Player[playerid][TDZone][1], 1);
  954.     PlayerTextDrawSetProportional(playerid, Player[playerid][TDZone][1], 1);
  955.     PlayerTextDrawSetShadow(playerid, Player[playerid][TDZone][1], 1);
  956.    
  957.     Player[playerid][CaptureTD][0] = CreatePlayerTextDraw(playerid, 633.000000, 358.000030, "");
  958.     PlayerTextDrawLetterSize(playerid, Player[playerid][CaptureTD][0], 0.323000, 1.357333);
  959.     PlayerTextDrawAlignment(playerid, Player[playerid][CaptureTD][0], 3);
  960.     PlayerTextDrawColor(playerid, Player[playerid][CaptureTD][0], -1);
  961.     PlayerTextDrawSetShadow(playerid, Player[playerid][CaptureTD][0], 1);
  962.     PlayerTextDrawSetOutline(playerid, Player[playerid][CaptureTD][0], 0);
  963.     PlayerTextDrawBackgroundColor(playerid, Player[playerid][CaptureTD][0], 255);
  964.     PlayerTextDrawFont(playerid, Player[playerid][CaptureTD][0], 1);
  965.     PlayerTextDrawSetProportional(playerid, Player[playerid][CaptureTD][0], 1);
  966.     PlayerTextDrawSetShadow(playerid, Player[playerid][CaptureTD][0], 1);
  967.  
  968.     Player[playerid][CaptureTD][1] = CreatePlayerTextDraw(playerid, 633.000000, 343.999938, "00:00");
  969.     PlayerTextDrawLetterSize(playerid, Player[playerid][CaptureTD][1], 0.400000, 1.600000);
  970.     PlayerTextDrawAlignment(playerid, Player[playerid][CaptureTD][1], 3);
  971.     PlayerTextDrawColor(playerid, Player[playerid][CaptureTD][1], -1);
  972.     PlayerTextDrawSetShadow(playerid, Player[playerid][CaptureTD][1], 0);
  973.     PlayerTextDrawSetOutline(playerid, Player[playerid][CaptureTD][1], 1);
  974.     PlayerTextDrawBackgroundColor(playerid, Player[playerid][CaptureTD][1], 255);
  975.     PlayerTextDrawFont(playerid, Player[playerid][CaptureTD][1], 3);
  976.     PlayerTextDrawSetProportional(playerid, Player[playerid][CaptureTD][1], 1);
  977.     PlayerTextDrawSetShadow(playerid, Player[playerid][CaptureTD][1], 0);
  978.  
  979.     LoadPlayerGang(playerid);
  980.     foreach(new i : GangZones)
  981.     {
  982.         if(GangZone[i][ZoneOwner] == -1)
  983.             GangZoneShowForPlayer(playerid, GangZone[i][ZoneHolder], HexToInt(DEFAULT_ZONE_COLOR));
  984.         else
  985.         {
  986.             new colour[9];
  987.             format(colour, 9, "%s50", Gang[GangZone[i][ZoneOwner]][GangColor]);
  988.             GangZoneShowForPlayer(playerid, GangZone[i][ZoneHolder], HexToInt(colour));
  989.         }
  990.     }
  991.     return 1;
  992. }
  993.  
  994. public OnPlayerDisconnect(playerid, reason)
  995. {
  996.     new i = Player[playerid][PlayerGang], msg[56];
  997.     SaveStats(playerid);
  998.     if(Iter_Contains(Gangs, i) && i != -1)
  999.     {
  1000.         new zone = Gang[i][CurrentZone], total = -1;
  1001.         if(zone != -1)
  1002.         {
  1003.             total = 0;
  1004.             foreach(new p : Player)
  1005.             {
  1006.                 if(Player[p][PlayerGang] == Player[playerid][PlayerGang])
  1007.                 {
  1008.                     if(Area_GetPlayerAreas(p, 0) == GangZone[zone][ZoneArea])
  1009.                         total++;
  1010.                 }
  1011.             }
  1012.         }
  1013.         if(total == 0)
  1014.         {
  1015.             format(msg, sizeof(msg), "{FF0000}** %s gang failed to capture %s zone!", Gang[Player[playerid][PlayerGang]][GangName], GangZone[zone][ZoneName]);
  1016.             SendClientMessageToAll(-1, msg);
  1017.             format(msg, sizeof(msg), "{FF0000}** %s zone will be locked for %d minutes!", GangZone[zone][ZoneName], LOCKED_MINUTES);
  1018.             SendClientMessageToAll(-1, msg);
  1019.             Gang[Player[playerid][PlayerGang]][CurrentZone] = -1;
  1020.             GangZone[zone][ZoneLocked] = GetTickCount();
  1021.             GangZone[zone][ZoneStatus] = false;
  1022.             GangZoneStopFlashForAll(GangZone[zone][ZoneHolder]);
  1023.         }
  1024.         format(msg, sizeof(msg), "%s has been logged out!", Name(playerid));
  1025.         SendGangMessage(i, msg);
  1026.     }  
  1027.     return 1;
  1028. }
  1029.  
  1030. public OnPlayerUpdate(playerid) //RyDer
  1031. {
  1032.     if(Player[playerid][CreatingZone])
  1033.     {
  1034.         new Keys, UpDown, LeftRight;
  1035.         GetPlayerKeys(playerid, Keys, UpDown, LeftRight);
  1036.         TogglePlayerControllable(playerid, false);
  1037.         if(LeftRight == KEY_LEFT)
  1038.         {
  1039.             MinPos[playerid][0] -= 8.0;
  1040.             GangZoneDestroy(PlayerZone[playerid]);
  1041.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1042.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1043.         }
  1044.         else if(LeftRight & KEY_LEFT && Keys & KEY_FIRE)
  1045.         {
  1046.             MinPos[playerid][0] += 8.0;
  1047.             GangZoneDestroy(PlayerZone[playerid]);
  1048.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1049.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1050.         }
  1051.         else if(LeftRight == KEY_RIGHT)
  1052.         {
  1053.             MaxPos[playerid][0] += 8.0;
  1054.             GangZoneDestroy(PlayerZone[playerid]);
  1055.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1056.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1057.         }
  1058.         else if(LeftRight & KEY_RIGHT && Keys & KEY_FIRE)
  1059.         {
  1060.             MaxPos[playerid][0] -= 8.0;
  1061.             GangZoneDestroy(PlayerZone[playerid]);
  1062.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1063.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1064.         }
  1065.         else if(UpDown == KEY_UP)
  1066.         {
  1067.             MaxPos[playerid][1] += 8.0;
  1068.             GangZoneDestroy(PlayerZone[playerid]);
  1069.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1070.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1071.         }
  1072.         else if(UpDown & KEY_UP && Keys & KEY_FIRE)
  1073.         {
  1074.             MaxPos[playerid][1] -= 8.0;
  1075.             GangZoneDestroy(PlayerZone[playerid]);
  1076.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1077.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1078.         }
  1079.         else if(UpDown == KEY_DOWN)
  1080.         {
  1081.             MinPos[playerid][1] -= 8.0;
  1082.             GangZoneDestroy(PlayerZone[playerid]);
  1083.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1084.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1085.         }
  1086.         else if(UpDown & KEY_DOWN && Keys & KEY_FIRE)
  1087.         {
  1088.             MinPos[playerid][1] += 8.0;
  1089.             GangZoneDestroy(PlayerZone[playerid]);
  1090.             PlayerZone[playerid] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1091.             GangZoneShowForPlayer(playerid, PlayerZone[playerid], HexToInt("000000FF"));
  1092.         }
  1093.         else if(Keys & KEY_SECONDARY_ATTACK)
  1094.         {
  1095.             TogglePlayerControllable(playerid, true);
  1096.             Player[playerid][CreatingZone] = false;
  1097.             ShowPlayerDialog(playerid, DIALOG_SAVEZONE, DIALOG_STYLE_INPUT, "X337 Gang System", "Input gang zone name below, press \"Delete\" to delete current zone", "Save", "Delete");
  1098.         }
  1099.     }
  1100.     return 1;
  1101. }
  1102.  
  1103. public OnPlayerDeath(playerid, killerid, reason)
  1104. {
  1105.     if(Player[playerid][PlayerGang] != -1)
  1106.     {
  1107.         new zone = Gang[Player[playerid][PlayerGang]][CurrentZone], total = -1;
  1108.         if(zone != -1)
  1109.         {
  1110.             total = 0;
  1111.             foreach(new p : Player)
  1112.             {
  1113.                 if(Player[p][PlayerGang] == Player[playerid][PlayerGang])
  1114.                 {
  1115.                     if(Area_GetPlayerAreas(p, 0) == GangZone[zone][ZoneArea])
  1116.                         total++;
  1117.                 }
  1118.             }
  1119.         }
  1120.         if(total == 0)
  1121.         {
  1122.             new msg[128];
  1123.             format(msg, sizeof(msg), "{FF0000}** %s gang failed to capture %s zone!", Gang[Player[playerid][PlayerGang]][GangName], GangZone[zone][ZoneName]);
  1124.             SendClientMessageToAll(-1, msg);
  1125.             format(msg, sizeof(msg), "{FF0000}** %s zone will be locked for %d minutes!", GangZone[zone][ZoneName], LOCKED_MINUTES);
  1126.             SendClientMessageToAll(-1, msg);
  1127.             Gang[Player[playerid][PlayerGang]][CurrentZone] = -1;
  1128.             GangZone[zone][ZoneLocked] = GetTickCount();
  1129.             GangZone[zone][ZoneStatus] = false;
  1130.             GangZoneStopFlashForAll(GangZone[zone][ZoneHolder]);
  1131.         }
  1132.     }
  1133.     return 1;
  1134. }
  1135.  
  1136. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  1137. {
  1138.     switch(dialogid)
  1139.     {
  1140.         case DIALOG_SAVEZONE:
  1141.         {
  1142.             if(response)
  1143.             {
  1144.                 if(strlen(inputtext) < 3 || strlen(inputtext) > 50)
  1145.                     ShowPlayerDialog(playerid, DIALOG_SAVEZONE, DIALOG_STYLE_INPUT, "X337 Gang System", "{FF0000}Gang zone name must be between 3 - 50 characters! \nInput gang zone name below, press \"Delete\" to delete current zone", "Save", "Delete");
  1146.                 else
  1147.                 {
  1148.                     new query[256];
  1149.                     mysql_format(connection, query, sizeof(query), "INSERT INTO `zone` (`minx`, `miny`, `maxx`, `maxy`, `name`) VALUES('%f', '%f', '%f', '%f', '%e')", MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1], inputtext);
  1150.                     mysql_query(connection, query, true);
  1151.                     GangZoneDestroy(PlayerZone[playerid]);
  1152.                     new i = Iter_Free(GangZones);
  1153.                     GangZone[i][ZoneMinPos][0] = MinPos[playerid][0];
  1154.                     GangZone[i][ZoneMinPos][1] = MinPos[playerid][1];
  1155.                     GangZone[i][ZoneMaxPos][0] = MaxPos[playerid][0];
  1156.                     GangZone[i][ZoneMaxPos][1] = MaxPos[playerid][1];
  1157.                     GangZone[i][ZoneOwner] = -1;
  1158.                     format(GangZone[i][ZoneName], 50, "%s", inputtext);
  1159.                     GangZone[i][ZoneID] = cache_insert_id();
  1160.                     GangZone[i][ZoneArea] = Area_AddBox(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1161.                     GangZone[i][ZoneHolder] = GangZoneCreate(MinPos[playerid][0], MinPos[playerid][1], MaxPos[playerid][0], MaxPos[playerid][1]);
  1162.                     GangZone[i][ZoneLocked] = 0;
  1163.                     GangZone[i][ZoneStatus] = false;
  1164.                     GangZoneShowForAll(GangZone[i][ZoneHolder], HexToInt(DEFAULT_ZONE_COLOR));
  1165.                     Iter_Add(GangZones, i);
  1166.                 }
  1167.             }
  1168.             else
  1169.                 GangZoneDestroy(PlayerZone[playerid]);
  1170.         }
  1171.         case DIALOG_CREATEGANG:
  1172.         {
  1173.             if(response)
  1174.             {
  1175.                 if(strlen(inputtext) < 5 || strlen(inputtext) > 30)
  1176.                 {
  1177.                     ShowPlayerDialog(playerid, DIALOG_CREATEGANG, DIALOG_STYLE_INPUT, "X337 Gang System - Gang Name", "{FF0000}Gang name must be between 5 - 30 characters! \nInsert the gang name below :", "Submit", "Cancel");
  1178.                 }
  1179.                 else if(!IsAlpha(inputtext))
  1180.                 {
  1181.                     ShowPlayerDialog(playerid, DIALOG_CREATEGANG, DIALOG_STYLE_INPUT, "X337 Gang System - Gang Name", "{FF0000}Please insert only a-z,A-Z,0-9 character! \nInsert the gang name below :", "Submit", "Cancel");
  1182.                 }
  1183.                 else
  1184.                 {
  1185.                     strcpy(TempGangName[playerid], inputtext);
  1186.                     ShowPlayerDialog(playerid, DIALOG_GANGTAG, DIALOG_STYLE_INPUT, "X337 Gang System - Gang Tag", "Insert the gang tag below :", "Submit", "Cancel");
  1187.                 }
  1188.             }
  1189.         }
  1190.         case DIALOG_GANGTAG:
  1191.         {
  1192.             if(response)
  1193.             {
  1194.                 if(strlen(inputtext) < 1 || strlen(inputtext) > 3)
  1195.                 {
  1196.                     ShowPlayerDialog(playerid, DIALOG_GANGTAG, DIALOG_STYLE_INPUT, "X337 Gang System - Gang Tag", "{FF0000}Gang tag must be between 1 - 3 character! \nInsert the gang tag below :", "Submit", "Cancel");
  1197.                 }
  1198.                 else if(!IsAlpha(inputtext))
  1199.                 {
  1200.                     ShowPlayerDialog(playerid, DIALOG_GANGTAG, DIALOG_STYLE_INPUT, "X337 Gang System - Gang Tag", "{FF0000}Please insert only a-z,A-Z,0-9 character! \nInsert the gang tag below :", "Submit", "Cancel");
  1201.                 }
  1202.                 else
  1203.                 {
  1204.                     strcpy(TempGangTag[playerid], inputtext);
  1205.                     ShowPlayerDialog(playerid, DIALOG_GANGCOLOUR, DIALOG_STYLE_LIST, "X337 Gang System - Gang Colour",
  1206.                     "{00FFFF}Aqua \n{000000}Black \n{0000FF}Blue \n{A52A2A}Brown \n{FF0000}Red \n{FFFFFF}Use HEX Colour", "Choose", "Cancel");
  1207.                 }
  1208.             }
  1209.         }
  1210.         case DIALOG_GANGCOLOUR:
  1211.         {
  1212.             if(response)
  1213.             {
  1214.                 switch(listitem)
  1215.                 {
  1216.                     case 0:
  1217.                         strcpy(TempGangColour[playerid], "00FFFF");
  1218.                     case 1:
  1219.                         strcpy(TempGangColour[playerid], "000000");
  1220.                     case 2:
  1221.                         strcpy(TempGangColour[playerid], "0000FF");
  1222.                     case 3:
  1223.                         strcpy(TempGangColour[playerid], "A52A2A");
  1224.                     case 4:
  1225.                         strcpy(TempGangColour[playerid], "FF0000");
  1226.                     case 5:
  1227.                     {
  1228.                         ShowPlayerDialog(playerid, DIALOG_HEXCOLOUR, DIALOG_STYLE_INPUT, "X337 Gang System - Hex Colour", "Enter hexadecimal colour below :", "Submit", "Back");
  1229.                     }
  1230.                 }
  1231.                 if(listitem != 5)
  1232.                 {
  1233.                     new msg[128];
  1234.                     format(msg, sizeof(msg), "Are you sure you want to make a gang? \
  1235.                     \nGang Name : %s \
  1236.                     \nGang Tag : [%s] \
  1237.                     \nGang Colour : {%s}%s", TempGangName[playerid], TempGangTag[playerid], TempGangColour[playerid], TempGangColour[playerid]);
  1238.                     ShowPlayerDialog(playerid, DIALOG_CREATEGANG_CONFIRM, DIALOG_STYLE_MSGBOX, "X337 Gang System - Create Gang", msg, "Sure", "Cancel");
  1239.                 }
  1240.             }
  1241.         }
  1242.         case DIALOG_HEXCOLOUR:
  1243.         {
  1244.             if(response)
  1245.             {
  1246.                 if(strlen(inputtext) != 6)
  1247.                     ShowPlayerDialog(playerid, DIALOG_HEXCOLOUR, DIALOG_STYLE_INPUT, "X337 Gang System - Hex Colour", "{FF0000}Hex colour must be 6 character!\n{FFFFFF}Enter hexadecimal colour below :", "Submit", "Back");
  1248.                 else
  1249.                 {
  1250.                     if(sscanf(inputtext, "h", TempGangColour[playerid]))
  1251.                         ShowPlayerDialog(playerid, DIALOG_HEXCOLOUR, DIALOG_STYLE_INPUT, "X337 Gang System - Hex Colour", "{FF0000}Invalid HEX colour!\n{FFFFFF}Enter hexadecimal colour below :", "Submit", "Back");
  1252.                     else
  1253.                     {
  1254.                         new msg[128];
  1255.                         format(msg, sizeof(msg), "Are you sure you want to make a gang? \
  1256.                         \nGang Name : %s \
  1257.                         \nGang Tag : [%s] \
  1258.                         \nGang Colour : {%s}%s", TempGangName[playerid], TempGangTag[playerid], TempGangColour[playerid], TempGangColour[playerid]);
  1259.                         ShowPlayerDialog(playerid, DIALOG_CREATEGANG_CONFIRM, DIALOG_STYLE_MSGBOX, "X337 Gang System - Create Gang", msg, "Sure", "Cancel");
  1260.                     }
  1261.                 }
  1262.             }
  1263.             else
  1264.             {
  1265.                 ShowPlayerDialog(playerid, DIALOG_GANGCOLOUR, DIALOG_STYLE_LIST, "X337 Gang System - Gang Colour",
  1266.                 "{00FFFF}Aqua \n{000000}Black \n{0000FF}Blue \n{A52A2A}Brown \n{FF0000}Red \n{FFFFFF}Use HEX Colour", "Choose", "Cancel");
  1267.             }
  1268.         }
  1269.         case DIALOG_CREATEGANG_CONFIRM:
  1270.         {
  1271.             if(response)
  1272.             {
  1273.                 new bool:found = false;
  1274.                 foreach(new i : Gangs)
  1275.                 {
  1276.                     if(!strcmp(Gang[i][GangName], TempGangName[playerid], true))
  1277.                     {
  1278.                         found = true;
  1279.                         SendClientMessage(playerid, -1, "{FF0000}Gang name already used!");
  1280.                         break;
  1281.                     }
  1282.                     if(!strcmp(Gang[i][GangTag], TempGangTag[playerid], true))
  1283.                     {
  1284.                         found = true;
  1285.                         SendClientMessage(playerid, -1, "{FF0000}Gang tag already used!");
  1286.                         break;
  1287.                     }
  1288.                 }
  1289.                 if(!found)
  1290.                 {
  1291.                     new query[256];
  1292.                     mysql_format(connection, query, sizeof(query), "INSERT INTO `gang` (`name`, `color`, `tag`) VALUES('%e', '%e', '%e')", TempGangName[playerid], TempGangColour[playerid], TempGangTag[playerid]);
  1293.                     mysql_query(connection, query, true);
  1294.                     new i = Iter_Free(Gangs);
  1295.                     strcpy(Gang[i][GangColor], TempGangColour[playerid]);
  1296.                     Gang[i][GangID] = cache_insert_id();
  1297.                     Gang[i][GangName] = TempGangName[playerid];
  1298.                     Gang[i][GangScore] = 0;
  1299.                     Gang[i][GangTag] = TempGangTag[playerid];
  1300.                     Gang[i][CurrentZone] = -1;
  1301.                     Player[playerid][PlayerGang] = i;
  1302.                     Player[playerid][PlayerStatus] = GANG_LEADER;
  1303.                     Iter_Add(Gangs, i);
  1304.                     format(query, sizeof(query), "{%s}[%s]%s {FFFFFF}gang has been created!", TempGangColour[playerid], TempGangTag[playerid], TempGangName[playerid]);
  1305.                     SendClientMessageToAll(-1, query);
  1306.                     SaveStats(playerid);
  1307.                 }
  1308.             }
  1309.         }
  1310.         case DIALOG_GCP:
  1311.         {
  1312.             if(response)
  1313.             {
  1314.                 switch(listitem)
  1315.                 {
  1316.                     case 3:
  1317.                         cmd_gangmembers(playerid, "");
  1318.                     case 4:
  1319.                         cmd_territory(playerid, "");
  1320.                 }
  1321.             }
  1322.         }
  1323.     }
  1324.     return 1;
  1325. }
  1326.  
  1327. public OnPlayerEnterArea(playerid, areaid)
  1328. {
  1329.     foreach(new i : GangZones)
  1330.     {
  1331.         if(areaid == GangZone[i][ZoneArea])
  1332.         {
  1333.             PlayerTextDrawSetString(playerid, Player[playerid][TDZone][0], GangZone[i][ZoneName]);
  1334.             new msg[128];
  1335.             if(GangZone[i][ZoneOwner] == -1)
  1336.                 format(msg, sizeof(msg), "Owned by : ~r~Unowned");
  1337.             else
  1338.                 format(msg, sizeof(msg), "Owned by : ~r~%s", Gang[GangZone[i][ZoneOwner]][GangName]);
  1339.             PlayerTextDrawSetString(playerid, Player[playerid][TDZone][1], msg);
  1340.             PlayerTextDrawShow(playerid, Player[playerid][TDZone][0]);
  1341.             PlayerTextDrawShow(playerid, Player[playerid][TDZone][1]);
  1342.             return 1;
  1343.         }
  1344.     }
  1345.     return 1;
  1346. }
  1347.  
  1348. public OnPlayerLeaveArea(playerid, areaid)
  1349. {
  1350.     PlayerTextDrawHide(playerid, Player[playerid][TDZone][0]);
  1351.     PlayerTextDrawHide(playerid, Player[playerid][TDZone][1]);
  1352.     if(Player[playerid][PlayerGang] != -1)
  1353.     {
  1354.         new zone = Gang[Player[playerid][PlayerGang]][CurrentZone], total = -1;
  1355.         if(zone != -1)
  1356.         {
  1357.             total = 0;
  1358.             foreach(new p : Player)
  1359.             {
  1360.                 if(Player[p][PlayerGang] == Player[playerid][PlayerGang])
  1361.                 {
  1362.                     if(Area_GetPlayerAreas(p, 0) == GangZone[zone][ZoneArea])
  1363.                         total++;
  1364.                 }
  1365.             }
  1366.         }
  1367.         if(total == 0)
  1368.         {
  1369.             new msg[128];
  1370.             format(msg, sizeof(msg), "{FF0000}** %s gang failed to capture %s zone!", Gang[Player[playerid][PlayerGang]][GangName], GangZone[zone][ZoneName]);
  1371.             SendClientMessageToAll(-1, msg);
  1372.             format(msg, sizeof(msg), "{FF0000}** %s zone will be locked for %d minutes!", GangZone[zone][ZoneName], LOCKED_MINUTES);
  1373.             SendClientMessageToAll(-1, msg);
  1374.             Gang[Player[playerid][PlayerGang]][CurrentZone] = -1;
  1375.             GangZone[zone][ZoneLocked] = GetTickCount();
  1376.             GangZone[zone][ZoneStatus] = false;
  1377.             GangZoneStopFlashForAll(GangZone[zone][ZoneHolder]);
  1378.         }
  1379.     }
  1380.     return 1;
  1381. }
  1382.  
  1383. forward AttackZone(gangid, zoneid);
  1384. public AttackZone(gangid, zoneid)
  1385. {
  1386.     if(Gang[gangid][CurrentZone] == zoneid && Iter_Contains(Gangs, gangid))
  1387.     {
  1388.         Gang[gangid][GangTimer]--;
  1389.         if(Gang[gangid][GangTimer] > 0)
  1390.         {
  1391.             new minutes = Gang[gangid][GangTimer] / 60, seconds = Gang[gangid][GangTimer] % 60, msg[10];
  1392.             format(msg, sizeof(msg), "%02d:%02d", minutes, seconds);
  1393.             foreach(new p : Player)
  1394.             {
  1395.                 if(Player[p][PlayerGang] == gangid)
  1396.                     PlayerTextDrawSetString(p, Player[p][CaptureTD][1], msg);
  1397.             }
  1398.         }
  1399.         else
  1400.         {
  1401.             KillTimer(GangZone[zoneid][ZoneTimer]);        
  1402.             new msg[128];
  1403.             format(msg, sizeof(msg), "Owned by : ~r~%s", Gang[gangid][GangName]);
  1404.             foreach(new p : Player)
  1405.             {
  1406.                 if(Player[p][PlayerGang] == gangid)
  1407.                 {
  1408.                     PlayerTextDrawHide(p, Player[p][CaptureTD][0]);
  1409.                     PlayerTextDrawHide(p, Player[p][CaptureTD][1]);
  1410.                 }
  1411.                 if(Area_GetPlayerAreas(p, 0) == GangZone[zoneid][ZoneArea])
  1412.                     PlayerTextDrawSetString(p, Player[p][TDZone][1], msg);
  1413.                
  1414.             }
  1415.             GangZoneStopFlashForAll(GangZone[zoneid][ZoneHolder]);
  1416.             new colour[9];
  1417.             format(colour, 9, "%s50", Gang[gangid][GangColor]);
  1418.             GangZoneShowForAll(GangZone[zoneid][ZoneHolder], HexToInt(colour));
  1419.             GangZone[zoneid][ZoneOwner] = gangid;
  1420.             format(msg, sizeof(msg), "{FF0000}** %s gang succesfully captured %s zone!", Gang[gangid][GangName], GangZone[zoneid][ZoneName]);
  1421.             SendClientMessageToAll(-1, msg);
  1422.             format(msg, sizeof(msg), "{FF0000}** %s zone will be locked for %d minutes!", GangZone[zoneid][ZoneName], LOCKED_MINUTES);
  1423.             SendClientMessageToAll(-1, msg);
  1424.             Gang[gangid][CurrentZone] = -1;
  1425.             GangZone[zoneid][ZoneLocked] = GetTickCount();
  1426.             GangZone[zoneid][ZoneStatus] = false;
  1427.             Gang[gangid][GangScore]+=5;
  1428.         }
  1429.     }
  1430.     else
  1431.     {
  1432.         foreach(new p : Player)
  1433.         {
  1434.             if(Player[p][PlayerGang] == gangid)
  1435.             {
  1436.                 PlayerTextDrawHide(p, Player[p][CaptureTD][0]);
  1437.                 PlayerTextDrawHide(p, Player[p][CaptureTD][1]);
  1438.             }
  1439.         }
  1440.         KillTimer(GangZone[zoneid][ZoneTimer]);
  1441.         GangZoneStopFlashForAll(GangZone[zoneid][ZoneHolder]);
  1442.     }
  1443.     return 1;
  1444. }
  1445.  
  1446. forward AutoSave();
  1447. public AutoSave()
  1448. {
  1449.     foreach(new i : Player)
  1450.         SaveStats(i);
  1451.     foreach(new i : Gangs)
  1452.         SaveGang(i);
  1453.     foreach(new i : GangZones)
  1454.         SaveZone(i);
  1455.     return 1;
  1456. }
  1457.  
  1458. COMMAND:gangcmds(playerid, params[])
  1459. {
  1460.     new msg[512];
  1461.     strcat(msg, "/creategang /gangcolor /changeleader /territory /gangmembers \n");
  1462.     strcat(msg, "/gcp /leavegang /disbandgang /topgang /gangrank /promotestaff \n");
  1463.     strcat(msg, "/demotestaff /createzone /ganginvite /acceptgang /g /capture \n");
  1464.     strcat(msg, "/okickmember /kickmember\n");
  1465.     ShowPlayerDialog(playerid, DIALOG_UNUSED, DIALOG_STYLE_MSGBOX, "X337 Gang System - Commands", msg, "Close", "");
  1466. }
  1467.  
  1468. /*
  1469.     SQL DUMP <X-Gang.sql>
  1470. -- phpMyAdmin SQL Dump
  1471. -- version 4.2.7.1
  1472. -- http://www.phpmyadmin.net
  1473. -- --------------------------------------------------------
  1474.  
  1475. --
  1476. -- Table structure for table `gang`
  1477. --
  1478.  
  1479. CREATE TABLE IF NOT EXISTS `gang` (
  1480. `id` int(10) NOT NULL,
  1481.   `name` varchar(30) NOT NULL,
  1482.   `color` varchar(6) NOT NULL,
  1483.   `tag` varchar(3) NOT NULL,
  1484.   `score` int(10) NOT NULL DEFAULT '0'
  1485. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  1486.  
  1487. -- --------------------------------------------------------
  1488.  
  1489. --
  1490. -- Table structure for table `member`
  1491. --
  1492.  
  1493. CREATE TABLE IF NOT EXISTS `member` (
  1494. `id` int(10) NOT NULL,
  1495.   `name` varchar(30) NOT NULL,
  1496.   `status` int(1) NOT NULL DEFAULT '1',
  1497.   `gang` int(10) NOT NULL DEFAULT '-1'
  1498. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  1499.  
  1500. -- --------------------------------------------------------
  1501.  
  1502. --
  1503. -- Table structure for table `zone`
  1504. --
  1505.  
  1506. CREATE TABLE IF NOT EXISTS `zone` (
  1507. `id` int(10) NOT NULL,
  1508.   `minx` varchar(10) NOT NULL,
  1509.   `miny` varchar(10) NOT NULL,
  1510.   `maxx` varchar(10) NOT NULL,
  1511.   `maxy` varchar(10) NOT NULL,
  1512.   `owner` int(10) NOT NULL DEFAULT '-1',
  1513.   `name` varchar(50) NOT NULL DEFAULT 'Undefined Zone'
  1514. ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
  1515.  
  1516. --
  1517. -- Indexes for dumped tables
  1518. --
  1519.  
  1520. --
  1521. -- Indexes for table `gang`
  1522. --
  1523. ALTER TABLE `gang`
  1524.  ADD PRIMARY KEY (`id`);
  1525.  
  1526. --
  1527. -- Indexes for table `member`
  1528. --
  1529. ALTER TABLE `member`
  1530.  ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`);
  1531.  
  1532. --
  1533. -- Indexes for table `zone`
  1534. --
  1535. ALTER TABLE `zone`
  1536.  ADD PRIMARY KEY (`id`);
  1537.  
  1538. --
  1539. -- AUTO_INCREMENT for dumped tables
  1540. --
  1541.  
  1542. --
  1543. -- AUTO_INCREMENT for table `gang`
  1544. --
  1545. ALTER TABLE `gang`
  1546. MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
  1547. --
  1548. -- AUTO_INCREMENT for table `member`
  1549. --
  1550. ALTER TABLE `member`
  1551. MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
  1552. --
  1553. -- AUTO_INCREMENT for table `zone`
  1554. --
  1555. ALTER TABLE `zone`
  1556. MODIFY `id` int(10) NOT NULL AUTO_INCREMENT;
  1557. -- ------------------------------------------------
  1558. */
Advertisement
RAW Paste Data Copied
Advertisement