Rei_Ayanami

Gang System

Jan 17th, 2024
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <a_samp>
  2. #include <dini>
  3. #include <sscanf2>
  4. #include <zcmd>
  5. #include <mSelection>
  6.  
  7. #define MAX_GANGS 50 // cãte ganguri vrei.
  8.  
  9.  
  10. #define Public:%0(%1) \
  11.     forward%0(%1); public%0(%1)
  12.  
  13. new gpickup[MAX_GANGS];
  14. new gangs = 0;
  15. new arma1 = mS_INVALID_LISTID;
  16. new arma2 = mS_INVALID_LISTID;
  17. new arma3 = mS_INVALID_LISTID;
  18. new arma4 = mS_INVALID_LISTID;
  19. new arma5 = mS_INVALID_LISTID;
  20. new arma6 = mS_INVALID_LISTID;
  21. new GangInvite[MAX_PLAYERS];
  22. new GangInviteTime[MAX_PLAYERS];
  23.  
  24. public OnFilterScriptInit()
  25. {
  26.     LoadGangs();
  27.     print("\n--------------------------------------");
  28.     print(" Gang System by Gireada");
  29.     print("--------------------------------------\n");
  30.     arma1 = LoadModelSelectionMenu("arma1.txt");
  31.     arma2 = LoadModelSelectionMenu("arma2.txt");
  32.     arma3 = LoadModelSelectionMenu("arma3.txt");
  33.     arma4 = LoadModelSelectionMenu("arma4.txt");
  34.     arma5 = LoadModelSelectionMenu("arma5.txt");
  35.     arma6 = LoadModelSelectionMenu("arma6.txt");
  36.     SetTimer("SaveGangs", 1000, 1);
  37.     SetTimer("SaveAccounts", 5000, 1);
  38.     return 1;
  39. }
  40.  
  41. public OnFilterScriptExit()
  42. {
  43.     return 1;
  44. }
  45.  
  46. enum
  47. {
  48.     DIALOG_INVITE = 99,//ultimul id din GameMode | last id of dialog from GameMode
  49.     DIALOG_SETTINGS,
  50.     DIALOG_COLOR,
  51.     DIALOG_STATS,
  52. }
  53.  
  54. main()
  55. {
  56.     print("\n----------------------------------");
  57.     print(" Gang System by Gireada");
  58.     print("----------------------------------\n");
  59. }
  60.  
  61. enum PlayerData
  62. {
  63.     GangID,
  64.     GangRank,
  65.     GangName[50],
  66. }
  67. new PlayerInfo[MAX_PLAYERS][PlayerData];
  68.  
  69. enum GangData
  70. {
  71.     ID,
  72.     Name[50],
  73.     Leader[MAX_PLAYER_NAME],
  74.     Float:Spawnx,
  75.     Float:Spawny,
  76.     Float:Spawnz,
  77.     Weapon1,
  78.     Weapon2,
  79.     Weapon3,
  80.     Weapon4,
  81.     Weapon5,
  82.     Weapon6,
  83.     Color[10],
  84.     Interior,
  85.     Virtual,
  86.     Day,
  87.     Month,
  88.     Year,
  89.     Kills,
  90.     Deaths,
  91.     Members,
  92. }
  93. new GangInfo[MAX_GANGS][GangData];
  94.  
  95. stock PlayerName(playerid)
  96. {
  97.     new nume[MAX_PLAYER_NAME];
  98.     GetPlayerName(playerid, nume, sizeof(nume));
  99.     return nume;
  100. }
  101.  
  102. public OnPlayerConnect(playerid)
  103. {
  104.     new file[MAX_PLAYER_NAME];
  105.     format(file, sizeof(file), "GangPlayers/%s.ini",PlayerName(playerid));
  106.     if(dini_Exists(file))
  107.     {
  108.         PlayerInfo[playerid][GangID] = dini_Int(file,"GangID");
  109.         PlayerInfo[playerid][GangRank] = dini_Int(file,"GangRank");
  110.         strmid(PlayerInfo[playerid][GangName], dini_Get(file,"GangName"), 0, strlen(dini_Get(file,"GangName")), 255);
  111.     }
  112.     else
  113.     {
  114.         dini_Create(file);
  115.         dini_IntSet(file,"GangID",0);
  116.         dini_IntSet(file,"GangRank",0);
  117.         dini_Set(file,"GangName"," ");
  118.     }
  119.     return 1;
  120. }
  121.  
  122. public OnPlayerDisconnect(playerid, reason)
  123. {
  124.     return 1;
  125. }
  126.  
  127. forward SaveAccounts();
  128. public SaveAccounts()
  129. {
  130.     new file[MAX_PLAYER_NAME];
  131.     for(new i=0;i<=MAX_GANGS;i++)
  132.     {
  133.         if(IsPlayerConnected(i))
  134.         {
  135.             if(GangInviteTime[i] > 0) GangInviteTime[i]--;
  136.             format(file, sizeof(file), "GangPlayers/%s.ini",PlayerName(i));
  137.             dini_IntSet(file,"GangID",PlayerInfo[i][GangID]);
  138.             dini_IntSet(file,"GangRank",PlayerInfo[i][GangRank]);
  139.             dini_Set(file,"GangName",PlayerInfo[i][GangName]);
  140.         }
  141.     }
  142.     return 1;
  143. }
  144.  
  145.  
  146. public OnPlayerSpawn(playerid)
  147. {
  148.     new file[256];
  149.     format(file, sizeof(file), "Gangs/%d.ini",PlayerInfo[playerid][GangID]);
  150.     new gangid = PlayerInfo[playerid][GangID];
  151.     if(gangid > 0)
  152.     {
  153.         if(!(dini_Exists(file)) || strcmp(PlayerInfo[playerid][GangName], GangInfo[gangid][Name], false, strlen(PlayerInfo[playerid][GangName])))
  154.         {
  155.             SendClientMessage(playerid, 0xFFFFFFFF , "The Gang has been abolished");
  156.             PlayerInfo[playerid][GangID] = 0;
  157.             PlayerInfo[playerid][GangRank] = 0;
  158.             strmid(PlayerInfo[playerid][GangName], " ", 0, strlen(" "), 255);
  159.         }
  160.         else
  161.         {
  162.             GiveGangWeapon(playerid);
  163.         }
  164.         return 1;
  165.     }
  166.     return 1;
  167. }
  168.  
  169. CMD:gangstats(playerid, params[])
  170. {
  171.     if(PlayerInfo[playerid][GangID] == 0) return SendClientMessage(playerid, 0xFF0000AA, "You need to be in a gang to use this command.");
  172.     new gangid = PlayerInfo[playerid][GangID],string[1024];
  173.     new weapon1[32],  weapon2[32],  weapon3[32],  weapon4[32],  weapon5[32],  weapon6[32], kills, death, members,day,month,year,leader[MAX_PLAYER_NAME],name[50];
  174.     GetWeaponName(GangInfo[gangid][Weapon1],weapon1,sizeof(weapon1)); GetWeaponName(GangInfo[gangid][Weapon2],weapon2,sizeof(weapon2)); GetWeaponName(GangInfo[gangid][Weapon3],weapon3,sizeof(weapon3));
  175.     GetWeaponName(GangInfo[gangid][Weapon4],weapon4,sizeof(weapon4)); GetWeaponName(GangInfo[gangid][Weapon5],weapon5,sizeof(weapon5)); GetWeaponName(GangInfo[gangid][Weapon6],weapon6,sizeof(weapon6));
  176.     kills = GangInfo[gangid][Kills]; death = GangInfo[gangid][Deaths]; members = GangInfo[gangid][Members]; day = GangInfo[gangid][Day]; month = GangInfo[gangid][Month];
  177.     year = GangInfo[gangid][Year]; format(leader, sizeof(leader), GangInfo[gangid][Leader]); format(name, sizeof(name), GangInfo[gangid][Name]);
  178.    
  179.    
  180.     format(string, sizeof(string), "{FFFF00}%s{FFFFFF} Gang Stats\n\nGang Leader: %s\nGang Weapons:\n1.%s\n2.%s\n3.%s\n4.%s\n5.%s\n6.%s\nKills: %d\nDeaths: %d\nFounded in %d.%d.%d\
  181.     \nMembers: %d\nRation: %d",name,leader,weapon1,weapon2,weapon3,weapon4,weapon5,weapon6,kills,death,day,month,year,members,kills-death);
  182.     ShowPlayerDialog(playerid, DIALOG_STATS, DIALOG_STYLE_MSGBOX, "Gang Stats", string, "Accept", "");
  183.    
  184.    
  185.     return 1;
  186. }
  187.    
  188. CMD:desgang(playerid, params[])
  189. {
  190.     new file[256],string[256];
  191.     if(!(PlayerInfo[playerid][GangRank] > 5)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  192.     new gangid = PlayerInfo[playerid][GangID];
  193.     format(file, sizeof(file), "Gangs/%d.ini",gangid);
  194.     dini_Remove(file);
  195.     for(new i = 0; i<MAX_PLAYERS;i++)
  196.     {
  197.         if(IsPlayerConnected(playerid))
  198.         {
  199.             if(i != playerid)
  200.             {
  201.                 if(PlayerInfo[i][GangID] == gangid)
  202.                 {
  203.                     PlayerInfo[i][GangID] = 0;
  204.                     format(PlayerInfo[i][GangName], 50, " ");
  205.                     PlayerInfo[i][GangRank] = 0;
  206.                     format(string, sizeof(string), "%s has disbanded gang.",PlayerName(playerid));
  207.                     SendClientMessage(i,0xFFFFFFFF, string);
  208.  
  209.                 }
  210.             }
  211.         }
  212.     }
  213.     format(string, sizeof(string), "%s has disbanded gang.",PlayerName(playerid));
  214.     SendClientMessage(playerid,0xFFFFFFFF, string);
  215.     PlayerInfo[playerid][GangID] = 0;
  216.     format(PlayerInfo[playerid][GangName], 50, " ");
  217.     PlayerInfo[playerid][GangRank] = 0;
  218.     return 1;
  219. }
  220.  
  221. CMD:qgang(playerid, params[])
  222. {
  223.     new string[256];
  224.     if(PlayerInfo[playerid][GangID] == 0) return SendClientMessage(playerid, 0xFF0000AA, "You need to be in a gang to use this command.");
  225.     if(PlayerInfo[playerid][GangRank] == 6) return SendClientMessage(playerid, 0xFF0000AA, "You are Big Dog Gangstar. If you want to quit gang use /desgang");
  226.     new gangid = PlayerInfo[playerid][GangID];
  227.     GangInfo[gangid][Members]--;
  228.     format(string, sizeof(string), "%s has quit the gang.", PlayerName(playerid));
  229.     SendGangMessage(PlayerInfo[playerid][GangID],string,-1);
  230.     PlayerInfo[playerid][GangID] = 0;
  231.     PlayerInfo[playerid][GangRank] = 0;
  232.     format(PlayerInfo[playerid][GangName], 50, " ");
  233.     return 1;
  234. }
  235.  
  236. CMD:invite(playerid, params[])
  237. {
  238.     new giveplayerid,string[256],caption[64];
  239.     new gangid = PlayerInfo[playerid][GangID];
  240.     if(unformat(params, "u", giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /invite <playerid/name>");
  241.     if(!(PlayerInfo[playerid][GangRank] > 5)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  242.     if(PlayerInfo[giveplayerid][GangID] > 0) return SendClientMessage(playerid, 0xFF0000AA, "Player is already in an another gang.");
  243.     if(GangInviteTime[giveplayerid] > 0) return SendClientMessage(playerid, 0xFF0000AA, "That already have an invitation");
  244.     if(giveplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You can not invite you");
  245.    
  246.     GangInvite[playerid] = PlayerInfo[playerid][GangID];
  247.     GangInviteTime[playerid] = 30;
  248.     format(caption, sizeof(caption), "%s invitation",GangInfo[gangid][Name]);
  249.     format(string, sizeof(string), "%s has invite you in the gang %s with:\n\n%d members\n%d kills\n%d deaths\n%d ration\n\nPress Accept or Cancel",PlayerName(playerid),\
  250.     GangInfo[gangid][Name],GangInfo[gangid][Members], GangInfo[gangid][Kills], GangInfo[gangid][Deaths], GangInfo[gangid][Kills] - GangInfo[gangid][Deaths]);
  251.     ShowPlayerDialog(giveplayerid, DIALOG_INVITE, DIALOG_STYLE_MSGBOX, caption, string, "Accept", "Cancel");
  252.        
  253.     return 1;
  254. }
  255.  
  256. CMD:setrank(playerid, params[])
  257. {
  258.     new string[256], giveplayerid, rank;
  259.     if(unformat(params, "ui", giveplayerid,rank)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /setrank <playerid/name> <rank>(1-5)");
  260.     if(!(IsPlayerConnected(giveplayerid))) return SendClientMessage(playerid, 0xFF0000AA, "Thet player is not connected.");
  261.     if(!(PlayerInfo[playerid][GangID] == PlayerInfo[giveplayerid][GangID])) return SendClientMessage(playerid, 0xFF0000AA, "Thet player is not in your gang.");
  262.     if(!(rank >= 1 && rank <=5)) return SendClientMessage(playerid, 0xFF0000AA, "Rank must be between 1 and 5.");
  263.     if(!(PlayerInfo[playerid][GangRank] == 6)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  264.     if(giveplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You are Big Dog Gangstar no one can't change your rank.");
  265.     PlayerInfo[giveplayerid][GangRank] = rank;
  266.     format(string, sizeof(string), "Big Dog Gangstar %s has set your rank to %d",PlayerName(playerid),rank);
  267.     SendClientMessage(giveplayerid, 0xFFFFFFFF, string);
  268.     format(string, sizeof(string), "You set %s rank to %d",PlayerName(giveplayerid),rank);
  269.     SendClientMessage(playerid, 0xFFFFFFFF, string);
  270.     return 1;
  271. }
  272.    
  273. CMD:eject(playerid, params[])
  274. {
  275.     new giveplayerid,string[256];
  276.     new gangid = PlayerInfo[playerid][GangID];
  277.     if(unformat(params, "u", giveplayerid)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /eject <playerid/name>");
  278.     if(!(PlayerInfo[playerid][GangRank] > 5)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  279.     if(!(PlayerInfo[giveplayerid][GangID] == gangid)) return SendClientMessage(playerid, 0xFF0000AA, "Player is not in your gang.");
  280.     if(giveplayerid == playerid) return SendClientMessage(playerid, 0xFF0000AA, "You can't eject your self");
  281.     format(string, sizeof(string), "%s has eject %s from gang.",PlayerName(playerid), PlayerName(giveplayerid));
  282.     SendGangMessage(gangid,string,-1);
  283.     PlayerInfo[giveplayerid][GangRank] = 0;
  284.     PlayerInfo[giveplayerid][GangID] = 0;
  285.     GangInfo[gangid][Members]--;
  286.     return 1;
  287. }
  288.  
  289. CMD:setspawn(playerid, params[])
  290. {
  291.     if(!(PlayerInfo[playerid][GangRank] > 5)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  292.     new gangid = PlayerInfo[playerid][GangID],string[256];
  293.     new Float:x,Float:y,Float:z;
  294.     GetPlayerPos(playerid,x,y,z);
  295.     GangInfo[gangid][Spawnx] = x; GangInfo[gangid][Spawny] = y; GangInfo[gangid][Spawnz] = z;
  296.     format(string, sizeof(string), "%s has change the spawn.",PlayerName(playerid));
  297.     SendGangMessage(gangid,string,-1);
  298.     DestroyPickup(gpickup[gangid]);
  299.     gpickup[gangid] = CreatePickup(1314, 1, x,y,z, -1);
  300.     return 1;
  301. }
  302.  
  303. CMD:gangchat(playerid, params[])
  304. {
  305.     new string[500];
  306.     if(unformat(params, "s[500]", string)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /gangchat(/gc) <text>");
  307.     if(!(PlayerInfo[playerid][GangID] > 0)) return SendClientMessage(playerid, 0xFF0000AA, "You are not in a gang>");
  308.     new gangid = PlayerInfo[playerid][GangID];
  309.     SendGangMessage(gangid,string,playerid);
  310.     return 1;
  311. }
  312.  
  313. CMD:alertall(playerid, params[])
  314. {
  315.     if(!(PlayerInfo[playerid][GangRank] > 5)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  316.     new Float:x,Float:y,Float:z;
  317.     GetPlayerPos(playerid,x,y,z);
  318.     new interior = GetPlayerInterior(playerid);
  319.     new virtualw = GetPlayerVirtualWorld(playerid);
  320.     for(new i=0;i<MAX_PLAYERS;i++)
  321.     {
  322.         if(IsPlayerConnected(i))
  323.         {
  324.             if(PlayerInfo[i][GangID] == PlayerInfo[playerid][GangID])
  325.             {
  326.                 SetPlayerPos(i,x,y,z);
  327.                 SetPlayerInterior(i,interior);
  328.                 SetPlayerVirtualWorld(i,virtualw);
  329.                 GameTextForPlayer(playerid, "The Big Dog Gangstar teleport you", 2000, 6);
  330.             }
  331.         }
  332.     }
  333.     return 1;
  334. }
  335.  
  336. CMD:gangweapon(playerid, params[])
  337. {
  338.     new gangid = PlayerInfo[playerid][GangID];
  339.     if(!(gangid > 0)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be in a gang to use this commnad.");
  340.     if(!(IsPlayerInRangeOfPoint(playerid, 3.5, GangInfo[gangid][Spawnx], GangInfo[gangid][Spawny], GangInfo[gangid][Spawnz]))) return SendClientMessage(playerid, 0xFF0000AA, "You need to be on the spawn.");
  341.     GiveGangWeapon(playerid);
  342.     return 1;
  343. }
  344.  
  345. COMMAND:gc(playerid, params[])
  346. {
  347.     return cmd_gangchat(playerid, params);
  348. }
  349.  
  350.  
  351. CMD:creategang(playerid, params[])
  352. {
  353.     new GangName2[50],day,month,year,file[256],string[256];
  354.     if(unformat(params, "s[50]", GangName2)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /creategang <name>(MAX 50)");
  355.     if(PlayerInfo[playerid][GangID] > 0) return SendClientMessage(playerid, 0xFF0000AA, "You aleardy have a gang.");
  356.  
  357.     for(new i=1;i<=MAX_GANGS;i++)
  358.     {
  359.         format(file, sizeof(file), "Gangs/%i.ini",i);
  360.         if(!dini_Exists(file))
  361.         {
  362.             getdate(year, month, day);
  363.             CreateGang(i,GangName2, PlayerName(playerid), day, month, year, "0xFFFFFFFF");
  364.             PlayerInfo[playerid][GangID] = i;
  365.             PlayerInfo[playerid][GangRank] = 6;
  366.             format(PlayerInfo[playerid][GangName], 50, GangName2);break;
  367.         }
  368.     }
  369.     format(string, sizeof(string), "You have create gang %s",GangName2);
  370.     SendClientMessage(playerid, 0xFF0000AA, string);
  371.     return 1;
  372. }
  373.  
  374. CMD:gangsetting(playerid, params[])
  375. {
  376.     if(!(PlayerInfo[playerid][GangRank] > 5)) return SendClientMessage(playerid, 0xFF0000AA, "You need to be the Big Dog Gangstar to use this command.");
  377.     ShowPlayerDialog(playerid, DIALOG_SETTINGS, DIALOG_STYLE_LIST, "Gang Setting", "Weapons\nColor", "Accept", "Cancel");
  378.     return 1;
  379. }
  380.  
  381. forward SendGangMessage(gangid,const msj[],playerid);
  382. public SendGangMessage(gangid,const msj[],playerid)
  383. {
  384.     new string[500];
  385.     for(new i=0;i<MAX_PLAYERS;i++)
  386.     {
  387.         if(IsPlayerConnected(i))
  388.         {
  389.             if(PlayerInfo[i][GangID] == gangid)
  390.             {
  391.                 switch(playerid)
  392.                 {
  393.                     case -1:
  394.                     {
  395.                         SendClientMessage(i, 0xFF0000AA, msj);
  396.                     }
  397.                     default:
  398.                     {
  399.                         switch(PlayerInfo[playerid][GangRank])
  400.                         {
  401.                             case 1: format(string, sizeof(string), "1*Little Gangsta %s: %s",PlayerName(playerid), msj);
  402.                             case 2: format(string, sizeof(string), "2*Gangsta %s: %s",PlayerName(playerid), msj);
  403.                             case 3: format(string, sizeof(string), "3*Trouble Gangsta %s: %s",PlayerName(playerid), msj);
  404.                             case 4: format(string, sizeof(string), "4*First Gangsta %s: %s",PlayerName(playerid), msj);
  405.                             case 5: format(string, sizeof(string), "5*Big Gangsta %s: %s",PlayerName(playerid), msj);
  406.                             case 6: format(string, sizeof(string), "6*Big Dog Gangsta %s: %s",PlayerName(playerid), msj);
  407.                         }
  408.                         SendClientMessage(i, 0xFF0000AA, string);
  409.                     }
  410.                 }
  411.             }
  412.         }
  413.     }
  414.     return 1;
  415. }
  416.        
  417.  
  418. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  419. {
  420.     new string[256];
  421.     new gangid = PlayerInfo[playerid][GangID];
  422.     if(response)
  423.     {
  424.         switch(dialogid)
  425.         {
  426.             case DIALOG_INVITE:
  427.             {
  428.                 PlayerInfo[playerid][GangID] = GangInvite[playerid];
  429.                 GangInviteTime[playerid] = 0;
  430.                 GangInvite[playerid] = 0;
  431.                 GangInfo[gangid][Members]++;
  432.                 format(string, sizeof(string), "[ %s ][ %d ] has enjoy in the gang.",PlayerName(playerid),playerid);
  433.                 SendGangMessage(PlayerInfo[playerid][GangID], string,-1);
  434.             }
  435.             case DIALOG_SETTINGS:
  436.             {
  437.                 switch(listitem)
  438.                 {
  439.                     case 0: ShowModelSelectionMenu(playerid, arma1, "Weapon1");
  440.                     case 1: ShowPlayerDialog(playerid, DIALOG_COLOR, DIALOG_STYLE_LIST, "Gang Setting", "Red\nBlue\nYellow\nGreen\nWhite\nPurple", "Accept", "Cancel");
  441.                 }
  442.             }
  443.             case DIALOG_COLOR:
  444.             {
  445.                 switch(listitem)
  446.                 {
  447.                     case 0: format(GangInfo[gangid][Color], 10, "0xF90505AA");
  448.                     case 1: format(GangInfo[gangid][Color], 10, "0x0026FFAA");
  449.                     case 2: format(GangInfo[gangid][Color], 10, "0xE6FB00AA");
  450.                     case 3: format(GangInfo[gangid][Color], 10, "0x00FF04AA");
  451.                     case 4: format(GangInfo[gangid][Color], 10, "0xFFFFFFAA");
  452.                     case 5: format(GangInfo[gangid][Color], 10, "0xDD00FFAA");
  453.                 }
  454.             }
  455.         }
  456.     }
  457.     if(!response)
  458.     {
  459.         switch(dialogid)
  460.         {
  461.             case DIALOG_INVITE:
  462.             {
  463.                 format(string, sizeof(string), "[ %s ][ %d ] has refuze the invitation.",PlayerName(playerid),playerid);
  464.                 SendGangMessage(GangInvite[playerid],string, -1);
  465.                 GangInviteTime[playerid] = 0;
  466.                 GangInvite[playerid] = 0;
  467.             }
  468.         }
  469.     }
  470.     return 1;
  471. }
  472.  
  473. public OnPlayerDeath(playerid, killerid, reason)
  474. {
  475.     if(reason > 47)
  476.     {
  477.         new gangid = PlayerInfo[playerid][GangID];
  478.         new gangid2 = PlayerInfo[killerid][GangID];
  479.         GangInfo[gangid][Deaths]++;
  480.         GangInfo[gangid2][Kills]++;
  481.     }
  482.     return 1;
  483. }
  484.  
  485. forward LoadGangs();
  486. public LoadGangs()
  487. {
  488.     new file[256];
  489.     for(new i=1;i<=MAX_GANGS;i++)
  490.     {
  491.         format(file, sizeof(file), "Gangs/%i.ini",i);
  492.         if(dini_Exists(file))
  493.         {
  494.             GangInfo[i][ID] = dini_Int(file,"ID");
  495.             strmid(GangInfo[i][Name], dini_Get(file,"Name"), 0, strlen(dini_Get(file,"Name")), 255);
  496.             strmid(GangInfo[i][Leader], dini_Get(file,"Leader"), 0, strlen(dini_Get(file,"Leader")), 255);
  497.             GangInfo[i][Spawnx] = dini_Float(file,"Spawnx");
  498.             GangInfo[i][Spawnx] = dini_Float(file,"Spawny");
  499.             GangInfo[i][Spawnx] = dini_Float(file,"Spawnz");
  500.             GangInfo[i][Weapon1] = dini_Int(file,"Weapon1");
  501.             GangInfo[i][Weapon2] = dini_Int(file,"Weapon2");
  502.             GangInfo[i][Weapon3] = dini_Int(file,"Weapon3");
  503.             GangInfo[i][Weapon4] = dini_Int(file,"Weapon4");
  504.             GangInfo[i][Weapon5] = dini_Int(file,"Weapon5");
  505.             GangInfo[i][Weapon6] = dini_Int(file,"Weapon6");
  506.             strmid(GangInfo[i][Color], dini_Get(file,"Color"), 0, strlen(dini_Get(file,"Color")), 255);
  507.             GangInfo[i][Interior] = dini_Int(file,"Interior");
  508.             GangInfo[i][Virtual] = dini_Int(file,"Virtual");
  509.             GangInfo[i][Day] = dini_Int(file,"Day");
  510.             GangInfo[i][Month] = dini_Int(file,"Month");
  511.             GangInfo[i][Year] = dini_Int(file,"Year");
  512.             GangInfo[i][Kills] = dini_Int(file,"Kills");
  513.             GangInfo[i][Deaths] = dini_Int(file,"Deaths");
  514.             GangInfo[i][Members] = dini_Int(file,"Members");
  515.             gangs++;
  516.         }
  517.     }
  518.     return 1;
  519. }
  520.  
  521. forward CreateGang(i,const Nume[], const gLeader[], Zi, Luna, An, const color[]);
  522. public CreateGang(i,const Nume[], const gLeader[], Zi, Luna, An, const color[])
  523. {
  524.     new file[256];
  525.     format(file, sizeof(file), "Gangs/%i.ini",i);
  526.     dini_Create(file);
  527.    
  528.     GangInfo[i][ID] = i;
  529.     format(GangInfo[i][Name], 50, Nume);
  530.     format(GangInfo[i][Leader], 50, gLeader);
  531.     GangInfo[i][Spawnx] = 0.0000; GangInfo[i][Spawny] = 0.0000; GangInfo[i][Spawnz] = 0.0000;
  532.     GangInfo[i][Weapon1] = 0; GangInfo[i][Weapon2] = 0; GangInfo[i][Weapon3] = 0;
  533.     GangInfo[i][Weapon4] = 0; GangInfo[i][Weapon5] = 0; GangInfo[i][Weapon6] = 0;
  534.     format(GangInfo[i][Color], 10, color);
  535.     GangInfo[i][Interior] = 0; GangInfo[i][Virtual] = 0; GangInfo[i][Day] = Zi;
  536.     GangInfo[i][Month] = Luna; GangInfo[i][Year] = An; GangInfo[i][Kills] = 0; GangInfo[i][Members] = 0;
  537.     return 1;
  538. }
  539.  
  540.  
  541. forward SaveGangs();
  542. public SaveGangs()
  543. {
  544.     new file[256];
  545.     for(new i=1;i<=MAX_GANGS;i++)
  546.     {
  547.         format(file,sizeof(file), "Gangs/%i.ini",i);
  548.         if(dini_Exists(file))
  549.         {
  550.             dini_IntSet(file,"ID",GangInfo[i][ID]);
  551.             dini_Set(file,"Name", GangInfo[i][Name]);
  552.             dini_Set(file,"Leader", GangInfo[i][Leader]);
  553.             dini_FloatSet(file,"Spawnx",GangInfo[i][Spawnx]);
  554.             dini_FloatSet(file,"Spawny",GangInfo[i][Spawny]);
  555.             dini_FloatSet(file,"Spawnz",GangInfo[i][Spawnz]);
  556.             dini_IntSet(file,"Weapon1",GangInfo[i][Weapon1]);
  557.             dini_IntSet(file,"Weapon2",GangInfo[i][Weapon2]);
  558.             dini_IntSet(file,"Weapon3",GangInfo[i][Weapon3]);
  559.             dini_IntSet(file,"Weapon4",GangInfo[i][Weapon4]);
  560.             dini_IntSet(file,"Weapon5",GangInfo[i][Weapon5]);
  561.             dini_IntSet(file,"Weapon6",GangInfo[i][Weapon6]);
  562.             dini_Set(file,"Color",GangInfo[i][Color]);
  563.             dini_IntSet(file,"Interior",GangInfo[i][Interior]);
  564.             dini_IntSet(file,"Virtual",GangInfo[i][Virtual]);
  565.             dini_IntSet(file,"Day",GangInfo[i][Day]);
  566.             dini_IntSet(file,"Month",GangInfo[i][Month]);
  567.             dini_IntSet(file,"Year",GangInfo[i][Year]);
  568.             dini_IntSet(file,"Kills",GangInfo[i][Kills]);
  569.             dini_IntSet(file,"Deaths",GangInfo[i][Deaths]);
  570.             dini_IntSet(file,"Members",GangInfo[i][Members]);
  571.         }
  572.     }
  573.     return 1;
  574. }
  575.  
  576. public OnPlayerModelSelection(playerid, response, listid, modelid)
  577. {
  578.     new gangid = PlayerInfo[playerid][GangID];
  579.     if(listid == arma1)
  580.     {
  581.         if(response)
  582.         {
  583.             switch(modelid)
  584.             {
  585.                 case 333: GangInfo[gangid][Weapon1] = 2; // Golf Club
  586.                 case 334: GangInfo[gangid][Weapon1] = 3;// Nightstick
  587.                 case 335: GangInfo[gangid][Weapon1] = 4;// Knife
  588.                 case 336: GangInfo[gangid][Weapon1] = 5;// Baseball Bat
  589.                 case 338: GangInfo[gangid][Weapon1] = 7;// Pool Cue
  590.                 case 339: GangInfo[gangid][Weapon1] = 8;// Katana
  591.                 case 341: GangInfo[gangid][Weapon1] = 9;// Chainsaw
  592.             }
  593.             ShowModelSelectionMenu(playerid, arma2, "Weapon2");
  594.         }
  595.         else SendClientMessage(playerid, 0xFF0000FF, "Canceled weapons selection");
  596.         return 1;
  597.     }
  598.     if(listid == arma2)
  599.     {
  600.         if(response)
  601.         {
  602.             switch(modelid)
  603.             {
  604.                 case 346: GangInfo[gangid][Weapon2] = 22;// 9mm
  605.                 case 347: GangInfo[gangid][Weapon2] = 23;// Silenced 9mm
  606.                 case 348: GangInfo[gangid][Weapon2] = 24;// Desert Eagle
  607.             }
  608.             ShowModelSelectionMenu(playerid, arma3, "Weapon3");
  609.         }
  610.         else SendClientMessage(playerid, 0xFF0000FF, "Canceled weapon selection");
  611.         return 1;
  612.     }
  613.     if(listid == arma3)
  614.     {
  615.         if(response)
  616.         {
  617.             switch(modelid)
  618.             {
  619.                 case 349: GangInfo[gangid][Weapon3] = 25;// Shotgun
  620.                 case 350: GangInfo[gangid][Weapon3] = 26;// Sawnoff
  621.                 case 351: GangInfo[gangid][Weapon3] = 27;// Combat Shotgun
  622.             }
  623.             ShowModelSelectionMenu(playerid, arma4, "Weapon4");
  624.         }
  625.         else SendClientMessage(playerid, 0xFF0000FF, "Canceled weapon selection");
  626.         return 1;
  627.     }
  628.     if(listid == arma4)
  629.     {
  630.         if(response)
  631.         {
  632.             switch(modelid)
  633.             {
  634.                 case 352: GangInfo[gangid][Weapon4] = 28;// Micro SMG/Uzi
  635.                 case 353: GangInfo[gangid][Weapon4] = 29;// MP5
  636.             }
  637.             ShowModelSelectionMenu(playerid, arma5, "Weapon5");
  638.         }
  639.         else SendClientMessage(playerid, 0xFF0000FF, "Canceled weapons selection");
  640.         return 1;
  641.     }
  642.     if(listid == arma5)
  643.     {
  644.         if(response)
  645.         {
  646.             switch(modelid)
  647.             {
  648.                 case 355: GangInfo[gangid][Weapon5] = 30;
  649.                 case 356: GangInfo[gangid][Weapon5] = 31;
  650.             }
  651.             ShowModelSelectionMenu(playerid, arma6, "Weapon6");
  652.         }
  653.         else SendClientMessage(playerid, 0xFF0000FF, "Canceled weapon selection");
  654.         return 1;
  655.     }
  656.     if(listid == arma6)
  657.     {
  658.         if(response)
  659.         {
  660.             switch(modelid)
  661.             {
  662.                 case 357: GangInfo[gangid][Weapon6] = 33;// Country Rifle
  663.                 case 358: GangInfo[gangid][Weapon6] = 34;// Sniper Rifle
  664.             }
  665.         }
  666.         else SendClientMessage(playerid, 0xFF0000FF, "Canceled skin selection");
  667.         return 1;
  668.     }
  669.     return 1;
  670. }
  671.  
  672. forward GangExist(gangid);
  673. public GangExist(gangid)
  674. {
  675.     new file[256];
  676.     format(file, sizeof(file), "Gangs/%i.ini",gangid);
  677.     if(dini_Exists(file))
  678.         return 1;
  679.     else
  680.         return 0;
  681. }
  682.  
  683. forward GiveGangWeapon(playerid);
  684. public GiveGangWeapon(playerid)
  685. {
  686.     new gangid = PlayerInfo[playerid][GangID];
  687.     if(!(GangInfo[gangid][Weapon1] == 0))  GivePlayerWeapon(playerid, GangInfo[gangid][Weapon1], 1);
  688.     if(!(GangInfo[gangid][Weapon2] == 0))  GivePlayerWeapon(playerid, GangInfo[gangid][Weapon2], 500);
  689.     if(!(GangInfo[gangid][Weapon3] == 0))  GivePlayerWeapon(playerid, GangInfo[gangid][Weapon3], 500);
  690.     if(!(GangInfo[gangid][Weapon4] == 0))  GivePlayerWeapon(playerid, GangInfo[gangid][Weapon4], 500);
  691.     if(!(GangInfo[gangid][Weapon5] == 0))  GivePlayerWeapon(playerid, GangInfo[gangid][Weapon5], 500);
  692.     if(!(GangInfo[gangid][Weapon6] == 0))  GivePlayerWeapon(playerid, GangInfo[gangid][Weapon6], 500);
  693.     return 1;
  694. }
Add Comment
Please, Sign In to add comment