Advertisement
Gireada

Gang System

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