JhnzRep

Faction

Oct 29th, 2012
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 10.04 KB | None | 0 0
  1. #define FPATH "/Factions/%i.ini"
  2. #define SCM SendClientMessage
  3.  
  4. enum pInfo
  5. {
  6.     Faction,
  7.     FacLeader,
  8.     FacRank
  9. }
  10. new PlayerInfo[MAX_PLAYERS][pInfo];
  11.  
  12. enum fcInfo
  13. {
  14.     fName[40],
  15.     fLeader[24],
  16.     fMOTD[128],
  17.     Float:fHqX,
  18.     Float:fHqY,
  19.     Float:fHqZ,
  20.     Float:fHqInX,
  21.     Float:fHqInY,
  22.     Float:fHqInZ,
  23.     fWorld,
  24.     fInt,
  25.     fInsideWorld,
  26.     fInsideInt,
  27.     fMoney,
  28.     fActive,
  29.     fInsideIcon,
  30.     fOutsideIcon,
  31.     fRank1[24],
  32.     fRank2[24],
  33.     fRank3[24],
  34.     fRank4[24],
  35.     fRank5[24],
  36.     fRank6[24]
  37. }
  38. new FacInfo[MAX_FACTIONS][fcInfo];
  39.  
  40. YCMD:accept(playerid, params[])
  41. {
  42.     if(isnull(params)) return SCM(playerid, COLOR_GREY, "/accept [invite]");
  43.     if(strcmp(params, "invite") == 0)
  44.     {
  45.         if(invite[playerid] == 0) return SCM(playerid, COLOR_GREY, "You were not invited to any faction!");
  46.         SCM(playerid, COLOR_LIGHTBLUE, "You have accepted your faction!");
  47.         PlayerInfo[playerid][Faction] = invite[playerid];
  48.         invite[playerid] = 0;
  49.         PlayerInfo[playerid][FacRank] = 1;
  50.     }
  51.     return 1;
  52. }
  53.  
  54. YCMD:rank(playerid, params[])
  55. {
  56.     new ID, number, string[128];
  57.     if(PlayerInfo[playerid][FacRank] != 6) return SCM(playerid, COLOR_GREY, "You are not rank 6 in your faction!");
  58.     if(sscanf(params, "ui", ID, number)) return SCM(playerid, COLOR_GREY, "YCMD:/rank [PlayerID] [Rank]");
  59.     PlayerInfo[ID][FacRank] = number;
  60.     format(string, sizeof(string), "%s has made you rank %i, in your faction! Good job!", RemoveUnderScore(playerid), number);
  61.     SCM(ID, COLOR_LIGHTBLUE, string);
  62.     return 1;
  63. }
  64.  
  65. forward SaveFac(id);
  66. public SaveFac(id)
  67. {
  68.     new file4[40];
  69.     format(file4, sizeof(file4), FPATH, id);
  70.     new INI:File = INI_Open(file4);
  71.     INI_WriteString(File, "fName", FacInfo[id][fName]);
  72.     INI_WriteString(File, "fLeader", FacInfo[id][fLeader]);
  73.     INI_WriteString(File, "fMOTD", FacInfo[id][fMOTD]);
  74.     INI_WriteFloat(File, "fHqX", FacInfo[id][fHqX]);
  75.     INI_WriteFloat(File, "fHqY", FacInfo[id][fHqY]);
  76.     INI_WriteFloat(File, "fHqZ", FacInfo[id][fHqZ]);
  77.     INI_WriteFloat(File, "fHqInX", FacInfo[id][fHqInX]);
  78.     INI_WriteFloat(File, "fHqInY", FacInfo[id][fHqInY]);
  79.     INI_WriteFloat(File, "fHqInZ", FacInfo[id][fHqInZ]);
  80.     INI_WriteInt(File, "fWorld", FacInfo[id][fWorld]);
  81.     INI_WriteInt(File, "fInt", FacInfo[id][fInt]);
  82.     INI_WriteInt(File, "fInsideWorld", FacInfo[id][fInsideWorld]);
  83.     INI_WriteInt(File, "fInsideInt", FacInfo[id][fInsideInt]);
  84.     INI_WriteInt(File, "fMoney", FacInfo[id][fMoney]);
  85.     INI_WriteInt(File, "fActive", FacInfo[id][fActive]);
  86.     INI_WriteString(File, "fRank1", FacInfo[id][fRank1]);
  87.     INI_WriteString(File, "fRank2", FacInfo[id][fRank2]);
  88.     INI_WriteString(File, "fRank3", FacInfo[id][fRank3]);
  89.     INI_WriteString(File, "fRank4", FacInfo[id][fRank4]);
  90.     INI_WriteString(File, "fRank5", FacInfo[id][fRank5]);
  91.     INI_WriteString(File, "fRank6", FacInfo[id][fRank6]);
  92.     INI_Close(File);
  93.     return 1;
  94. }
  95.  
  96. forward loadfac_data(id, name[], value[]);
  97. public loadfac_data(id, name[], value[])
  98. {
  99.     INI_String("fName", FacInfo[id][fName], 40);
  100.     INI_String("fLeader", FacInfo[id][fLeader], 24);
  101.     INI_String("fMOTD", FacInfo[id][fMOTD], 128);
  102.     INI_Float("fHqX", FacInfo[id][fHqX]);
  103.     INI_Float("fHqY", FacInfo[id][fHqY]);
  104.     INI_Float("fHqZ", FacInfo[id][fHqZ]);
  105.     INI_Float("fHqInX", FacInfo[id][fHqInX]);
  106.     INI_Float("fHqInY", FacInfo[id][fHqInY]);
  107.     INI_Float("fHqInZ", FacInfo[id][fHqInZ]);
  108.     INI_Int("fWorld", FacInfo[id][fWorld]);
  109.     INI_Int("fInt", FacInfo[id][fInt]);
  110.     INI_Int("fInsideWorld", FacInfo[id][fInsideWorld]);
  111.     INI_Int("fInsideInt", FacInfo[id][fInsideInt]);
  112.     INI_Int("fMoney", FacInfo[id][fMoney]);
  113.     INI_Int("fActive", FacInfo[id][fActive]);
  114.     INI_String("fRank1", FacInfo[id][fRank1], 24);
  115.     INI_String("fRank2", FacInfo[id][fRank2], 24);
  116.     INI_String("fRank3", FacInfo[id][fRank3], 24);
  117.     INI_String("fRank4", FacInfo[id][fRank4], 24);
  118.     INI_String("fRank5", FacInfo[id][fRank5], 24);
  119.     INI_String("fRank6", FacInfo[id][fRank6], 24);
  120.     return 1;
  121. }
  122.  
  123. YCMD:fac(playerid, params[])
  124. {
  125.     new string[128], Fam = PlayerInfo[playerid][Faction];
  126.     if(PlayerInfo[playerid][Faction] == 0) return SCM(playerid, COLOR_GREY, "You are not in a Faction");
  127.     if(isnull(params)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: (/fac)amily [Faction chat]");
  128.     switch(PlayerInfo[playerid][FacRank])
  129.     {
  130.         case 1: format(string, sizeof(string), "(( %s %s: %s ))", FacInfo[Fam][fRank1], RemoveUnderScore(playerid), params);
  131.         case 2: format(string, sizeof(string), "(( %s %s: %s ))", FacInfo[Fam][fRank2], RemoveUnderScore(playerid), params);
  132.         case 3: format(string, sizeof(string), "(( %s %s: %s ))", FacInfo[Fam][fRank3], RemoveUnderScore(playerid), params);
  133.         case 4: format(string, sizeof(string), "(( %s %s: %s ))", FacInfo[Fam][fRank4], RemoveUnderScore(playerid), params);
  134.         case 5: format(string, sizeof(string), "(( %s %s: %s ))", FacInfo[Fam][fRank5], RemoveUnderScore(playerid), params);
  135.         case 6: format(string, sizeof(string), "(( %s %s: %s ))", FacInfo[Fam][fRank6], RemoveUnderScore(playerid), params);
  136.  
  137.     }
  138.     foreach(Player, i)
  139.     {
  140.         if(PlayerInfo[i][Faction] == Fam) SCM(i, COLOR_LIGHTBLUE, string);
  141.     }
  142.     return 1;
  143. }
  144.  
  145. YCMD:editfaction(playerid, params[])
  146. {
  147.     new editop[40], string[128], Fam, ID;
  148.     if(PlayerInfo[playerid][FacLeader] == 0 && PlayerInfo[playerid][Admin] < 4) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  149.     if(sscanf(params, "s[40]", editop)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction [option](Options: leader, name, motd, rank1, rank2, rank3, rank4, rank5, rank6)");
  150.     if(strcmp(editop,"leader",true) == 0)
  151.     {
  152.         if(PlayerInfo[playerid][Admin] < 4) return SCM(playerid, COLOR_GREY, "You are not an admin, you cannot use this command");
  153.         if(sscanf(params, "s[40]ui", editop , ID, Fam)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction leader [PLAYERID] [FactionID]");
  154.         if(Fam < 1 || Fam > 5) return SCM(playerid, COLOR_GREY, "Families IDs are only 1-5.");
  155.         PlayerInfo[ID][Faction] = Fam;
  156.         print("shit got dis far");
  157.         format(string, sizeof(string), "%s has been made leader of a Faction slot %i by %s", RemoveUnderScore(ID), Fam, RemoveUnderScore(playerid));
  158.         SCM(playerid, COLOR_LIGHTRED, string);
  159.         SCM(ID, COLOR_LIGHTRED, string);
  160.         print("shit got dis far2");
  161.         PlayerInfo[ID][FacRank] = 6;
  162.         PlayerInfo[ID][FacLeader] = 1;
  163.         PlayerInfo[ID][FamLeader] = 0;
  164.         PlayerInfo[ID][Family] = 0;
  165.         PlayerInfo[ID][FamRank] = 0;
  166.         FacInfo[Fam][fLeader] = RemoveUnderScore(ID);
  167.         print("shit got realfar");
  168.     }
  169.     if(strcmp(editop,"name",true) == 0)
  170.     {
  171.         new name[40];
  172.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  173.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction name [NEWNAME]");
  174.         Fam = PlayerInfo[playerid][Faction];
  175.         FacInfo[Fam][fName] = name;
  176.         format(string, sizeof(string), "Faction ID %i, is now known as %s.", Fam, name);
  177.         SendClientMessageToAll(COLOR_LIGHTRED, string);
  178.     }
  179.  
  180.     if(strcmp(editop,"motd",true) == 0)
  181.     {
  182.         new name[128];
  183.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  184.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction motd [TEXT]");
  185.         Fam = PlayerInfo[playerid][Faction];
  186.         format(string,sizeof(string), "%s", name);
  187.         FacInfo[Fam][fMOTD] = name;
  188.         foreach(Player, i)
  189.         {
  190.             if(PlayerInfo[i][Faction] == Fam)
  191.             {
  192.                 SCM(i, COLOR_LIGHTBLUE, "MOTD Changed, read it below:");
  193.                 SCM(i, COLOR_LIGHTBLUE, string);
  194.             }
  195.         }
  196.     }
  197.  
  198.     if(strcmp(editop,"rank1",true) == 0)
  199.     {
  200.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  201.         new name[24];
  202.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction rank1 [RankName]");
  203.         Fam = PlayerInfo[playerid][Faction];
  204.         FacInfo[Fam][fRank1] = name;
  205.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Rank name changed.");
  206.     }
  207.  
  208.     if(strcmp(editop,"rank2",true) == 0)
  209.     {
  210.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  211.         new name[24];
  212.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction rank2 [RankName]");
  213.         Fam = PlayerInfo[playerid][Faction];
  214.         FacInfo[Fam][fRank2] = name;
  215.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Rank name changed.");
  216.     }
  217.  
  218.     if(strcmp(editop,"rank3",true) == 0)
  219.     {
  220.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  221.         new name[24];
  222.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction rank3 [RankName]");
  223.         Fam = PlayerInfo[playerid][Faction];
  224.         FacInfo[Fam][fRank3] = name;
  225.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Rank name changed.");
  226.     }
  227.  
  228.     if(strcmp(editop,"rank4",true) == 0)
  229.     {
  230.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  231.         new name[24];
  232.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction rank4 [RankName]");
  233.         Fam = PlayerInfo[playerid][Faction];
  234.         FacInfo[Fam][fRank4] = name;
  235.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Rank name changed.");
  236.     }
  237.  
  238.     if(strcmp(editop,"rank5",true) == 0)
  239.     {
  240.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  241.         new name[24];
  242.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction rank5 [RankName]");
  243.         Fam = PlayerInfo[playerid][Faction];
  244.         FacInfo[Fam][fRank5] = name;
  245.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Rank name changed.");
  246.     }
  247.  
  248.     if(strcmp(editop,"rank6",true) == 0)
  249.     {
  250.         if(PlayerInfo[playerid][FacLeader] == 0) return SCM(playerid, COLOR_GREY, "You are not a Faction leader.");
  251.         new name[24];
  252.         if(sscanf(params, "ss", editop, name)) return SCM(playerid, COLOR_GREY, "YCMD:/editfaction rank6 [RankName]");
  253.         Fam = PlayerInfo[playerid][Faction];
  254.         FacInfo[Fam][fRank6] = name;
  255.         SendClientMessage(playerid, COLOR_LIGHTBLUE, "Rank name changed.");
  256.     }
  257.     return 1;
  258. }
Advertisement
Add Comment
Please, Sign In to add comment