Guest User

Untitled

a guest
Apr 20th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 11.56 KB | None | 0 0
  1. //Clan Creator System by §ñ†¶e®ÐµÐe
  2. //do NOT remove the credits
  3. //You are allowed to modify this filterscript as you wish
  4. #include <a_samp>
  5.  
  6.  
  7. #define FILTERSCRIPT
  8. #define msg SendClientMessage
  9. #if defined FILTERSCRIPT
  10. forward PlayerLeaveGang(playerid);
  11. #define COLOR_ORANGERED 0xE9370DFC
  12. #define COLOR_GOLD 0xDEAD4370
  13. #define COLOR_MEDIUMAQUA 0x83BFBFFF
  14. #define COLOR_BLUE 0x0000FFAA
  15. #define COLOR_GREY 0xAFAFAFAA
  16. #define COLOR_GREEN 0x33AA33AA
  17. #define COLOR_YELLOW 0xFFFF00AA
  18. #define COLOR_WHITE 0xFFFFFFAA
  19. #define COLOR_PURPLE 0x9900FFAA
  20. #define COLOR_BROWN 0x993300AA
  21. #define COLOR_ORANGE 0xFF9933AA
  22. #define COLOR_CYAN 0x99FFFFAA
  23. #define COLOR_TAN 0xFFFFCCAA
  24. #define COLOR_PINK 0xFF66FFAA
  25. #define COLOR_KHAKI 0x999900AA
  26. #define COLOR_LIME 0x99FF00AA
  27. #define COLOR_BLACK 0x000000AA
  28. #define COLOR_TURQ 0x00A3C0AA
  29. #define COLOR_LIGHTBLUE 0x00BFFFAA
  30. #define COLOR_GREENISHGOLD 0xCCFFDD56
  31. #define COLOR_LIGHTBLUEGREEN 0x0FFDD349
  32. #define COLOR_LIGHTCYAN 0xAAFFCC33
  33. #define COLOR_LEMON 0xDDDD2357
  34. #define COLOR_LIGHTGREEN 0x7CFC00AA
  35. #define COLOR_WHITEYELLOW 0xFFE87DAA
  36. #define COLOR_BLUEAQUA 0x7E60FFAA
  37. #define COLOR_GREENYELLOWWHITE 0xCBFF45AA
  38. #define COLOR_DARKBLUE 0x15005EAA
  39. #define COLOR_RED 0xAA3333AA
  40. #define COLOR_LIGHTRED 0xFF0000AA
  41. #define NUMVALUES 4
  42.  
  43. new playerColors[100] = {
  44. 0xFF8C13FF,0xC715FFFF,0x20B2AAFF,0xDC143CFF,0x6495EDFF,0xf0e68cFF,0x778899FF,0xFF1493FF,0xF4A460FF,0xEE82EEFF,0xFFD720FF,
  45. 0x8b4513FF,0x4949A0FF,0x148b8bFF,0x14ff7fFF,0x556b2fFF,0x0FD9FAFF,0x10DC29FF,0x534081FF,0x0495CDFF,0xEF6CE8FF,0xBD34DAFF,
  46. 0x247C1BFF,0x0C8E5DFF,0x635B03FF,0xCB7ED3FF,0x65ADEBFF,0x5C1ACCFF,0xF2F853FF,0x11F891FF,0x7B39AAFF,0x53EB10FF,0x54137DFF,
  47. 0x275222FF,0xF09F5BFF,0x3D0A4FFF,0x22F767FF,0xD63034FF,0x9A6980FF,0xDFB935FF,0x3793FAFF,0x90239DFF,0xE9AB2FFF,0xAF2FF3FF,
  48. 0x057F94FF,0xB98519FF,0x388EEAFF,0x028151FF,0xA55043FF,0x0DE018FF,0x93AB1CFF,0x95BAF0FF,0x369976FF,0x18F71FFF,0x4B8987FF,
  49. 0x491B9EFF,0x829DC7FF,0xBCE635FF,0xCEA6DFFF,0x20D4ADFF,0x2D74FDFF,0x3C1C0DFF,0x12D6D4FF,0x48C000FF,0x2A51E2FF,0xE3AC12FF,
  50. 0xFC42A8FF,0x2FC827FF,0x1A30BFFF,0xB740C2FF,0x42ACF5FF,0x2FD9DEFF,0xFAFB71FF,0x05D1CDFF,0xC471BDFF,0x94436EFF,0xC1F7ECFF,
  51. 0xCE79EEFF,0xBD1EF2FF,0x93B7E4FF,0x3214AAFF,0x184D3BFF,0xAE4B99FF,0x7E49D7FF,0x4C436EFF,0xFA24CCFF,0xCE76BEFF,0xA04E0AFF,
  52. 0x9F945CFF,0xDCDE3DFF,0x10C9C5FF,0x70524DFF,0x0BE472FF,0x8A2CD7FF,0x6152C2FF,0xCF72A9FF,0xE59338FF,0xEEDC2DFF,0xD8C762FF,
  53. 0x3FE65CFF
  54. };
  55.  
  56. #define MAX_GANGS           32
  57. #define MAX_GANG_MEMBERS    20
  58. #define MAX_GANG_NAME       30
  59. new gangMembers[MAX_GANGS][MAX_GANG_MEMBERS];
  60. new gangNames[MAX_GANGS][MAX_GANG_NAME];
  61. new gangInfo[MAX_GANGS][3];
  62. new gangBank[MAX_GANGS];
  63. new playerGang[MAX_PLAYERS];
  64. new gangInvite[MAX_PLAYERS];
  65.  
  66.  
  67.  
  68. public OnFilterScriptInit()
  69. {
  70.     print("==========================");
  71.     print("Clan Creator by §ñ†¶e®ÐµÐe");  
  72.     print("==========================");
  73.     return 1;
  74. }
  75.  
  76. public OnFilterScriptExit()
  77. {
  78.     return 1;
  79. }
  80.  
  81. #endif
  82.  
  83. public OnPlayerText(playerid, text[])
  84. {
  85.     if(text[0] == '!') {
  86.         if(playerGang[playerid] > 0) {
  87.             new gangChat[256];
  88.             new senderName[MAX_PLAYER_NAME];
  89.             new string[256];
  90.  
  91.             strmid(gangChat,text,1,strlen(text));
  92.  
  93.             GetPlayerName(playerid, senderName, sizeof(senderName));
  94.             format(string, sizeof(string),"[GANG %s:] %s", senderName, gangChat);
  95.  
  96.             for(new i = 0; i < gangInfo[playerGang[playerid]][1]; i++) {
  97.                 msg(gangMembers[playerGang[playerid]][i], COLOR_LIGHTBLUE, string);
  98.             }
  99.         }
  100.  
  101.         return 0;
  102.     }
  103.     return 1;
  104. }
  105.  
  106. public OnPlayerConnect(playerid)
  107. {
  108.     playerGang[playerid]=0;
  109.     gangInvite[playerid]=0;
  110.     return 1;
  111. }
  112.  
  113. public OnPlayerDisconnect(playerid, reason)
  114. {
  115.     PlayerLeaveGang(playerid);
  116.     return 1;
  117. }
  118.  
  119. public OnPlayerCommandText(playerid, cmdtext[])
  120. {
  121.     new string[256];
  122.     new sendername[MAX_PLAYER_NAME];
  123.     new giveplayer[MAX_PLAYER_NAME];
  124.     new cmd[256];
  125.     new giveplayerid,idx;
  126.  
  127.     cmd = strtok(cmdtext, idx);
  128.  
  129.     if(strcmp(cmd, "/ganghelp", true) == 0) {
  130.     msg(playerid, COLOR_YELLOW,"/createclan [Name]");
  131.     msg(playerid, COLOR_YELLOW,"/caccept");
  132.     msg(playerid, COLOR_YELLOW,"/cinvite [Player ID]");
  133.     msg(playerid, COLOR_YELLOW,"/lclan");
  134.     msg(playerid, COLOR_YELLOW,"/claninfo [Gang ID]");
  135.     msg(playerid, COLOR_YELLOW,"! [Text] Gang chat");
  136.     return 1;
  137.     }
  138.  
  139.  
  140.     //------------------- gang
  141.  
  142.     if(strcmp(cmd, "/gang", true) == 0) {
  143.         new tmp[256];
  144.         new gangcmd, gangnum;
  145.         tmp = strtok(cmdtext, idx);
  146.  
  147.         if(!strlen(tmp)) {
  148.             msg(playerid, 0x83BFBFFF, "Write /clanhelp for details.");
  149.             return 1;
  150.         }
  151.         giveplayerid = strval(tmp);
  152.  
  153.         if(strcmp(tmp, "create", true)==0)
  154.             gangcmd = 1;
  155.         else if(strcmp(tmp, "invite", true)==0)
  156.             gangcmd = 2;
  157.         else if(strcmp(tmp, "enter", true)==0)
  158.             gangcmd = 3;
  159.         else if(strcmp(tmp, "abandon", true)==0) // I think LEAVE goes better but ... abandoneaza = abandon
  160.             gangcmd = 4;
  161.  
  162.         tmp = strtok(cmdtext, idx);
  163.         if(gangcmd < 3 && !strlen(tmp)) {
  164.             if(gangcmd==0)
  165.                 msg(playerid, 0x83BFBFFF, "Write /clanhelp for details.");
  166.             else if(gangcmd==1)
  167.                 msg(playerid, 0x83BFBFFF, "Write: /createclan [Name]");
  168.             else if(gangcmd==2)
  169.                 msg(playerid, 0x83BFBFFF, "Write: /cinvite [PlayerID]");
  170.             return 1;
  171.         }
  172.  
  173.         //Create//
  174.         if(gangcmd==1) {
  175.             if(playerGang[playerid]>0) {
  176.                 msg(playerid, 0x83BFBFFF, "You are already in a clan !");
  177.                 return 1;
  178.             }
  179.  
  180.             for(new i = 1; i < MAX_GANGS; i++) {
  181.                 if(gangInfo[i][0]==0) {
  182.                     //Gang name
  183.                     format(gangNames[i], MAX_GANG_NAME, "%s", tmp);
  184.                     //Existing gang
  185.                     gangInfo[i][0]=1;
  186.                     //Only one member
  187.                     gangInfo[i][1]=1;
  188.                     //Gang color is player's color
  189.                     gangInfo[i][2]=playerColors[playerid];
  190.  
  191.                     //Player is 1st (first) member
  192.                     gangMembers[i][0] = playerid;
  193.                     format(string, sizeof(string),"You've created gang '%s' (ID: %d)", gangNames[i], i);
  194.                     msg(playerid, 0x83BFBFFF, string);
  195.  
  196.                     playerGang[playerid]=i;
  197.  
  198.                     return 1;
  199.                 }
  200.             }
  201.  
  202.             return 1;
  203.  
  204.         //Enter gang//
  205.         } else if (gangcmd==3) {
  206.             gangnum = gangInvite[playerid];
  207.  
  208.             if(playerGang[playerid]>0) {
  209.                 msg(playerid, 0x83BFBFFF, "You are already in a gang.");
  210.                 return 1;
  211.             }
  212.             if(gangInvite[playerid]==0) {
  213.                 msg(playerid, 0x83BFBFFF, "You are not invited in a gang.");
  214.                 return 1;
  215.             }
  216.             if(gangInfo[gangnum][0]==0) {
  217.                 msg(playerid, 0x83BFBFFF, "Gang doesn't exist.");
  218.                 return 1;
  219.             }
  220.  
  221.             if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS) {
  222.                 new i = gangInfo[gangnum][1];
  223.  
  224.                 gangInvite[playerid]=0;
  225.  
  226.                 gangMembers[gangnum][i] = playerid;
  227.  
  228.                 GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
  229.                 for(new j = 0; j < gangInfo[gangnum][1]; j++) {
  230.                     format(string, sizeof(string),"%s entered your gang.Say hi to %s and help him fit.", sendername);
  231.                     msg(gangMembers[gangnum][j], COLOR_ORANGE, string);
  232.                 }
  233.  
  234.                 gangInfo[gangnum][1]++;
  235.                 playerGang[playerid] = gangnum;
  236.  
  237.                 SetPlayerColor(playerid,gangInfo[gangnum][2]);
  238.  
  239.                 format(string, sizeof(string),"You've entered in gang '%s'(id: %d)", gangNames[gangnum], gangnum);
  240.                 msg(playerid, 0x83BFBFFF, string);
  241.  
  242.                 return 1;
  243.             }
  244.  
  245.             msg(playerid, 0x83BFBFFF, "No member found");
  246.             return 1;
  247.  
  248.         //Invite//
  249.         } else if (gangcmd==2) {
  250.             giveplayerid = strval(tmp);
  251.  
  252.             if(playerGang[playerid]==0) {
  253.                 msg(playerid, 0x83BFBFFF, "You aren't in a gang.");
  254.                 return 1;
  255.             }
  256. //          if(gangMembers[playerGang[playerid]][0]!=playerid) {
  257. //              msg(playerid, COLOR_RED, "You have to be the gang leader to invite someone.");
  258. //              return 1;
  259. //          }
  260.  
  261.             if(IsPlayerConnected(giveplayerid)) {
  262.                 GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  263.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  264.  
  265.                 format(string, sizeof(string),"You invited %s in your gang.", giveplayer);
  266.                 msg(playerid, 0x83BFBFFF, string);
  267.                 format(string, sizeof(string),"You got an invitation from %s to enter his gang '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
  268.                 msg(giveplayerid, 0x83BFBFFF, string);
  269.  
  270.                 gangInvite[giveplayerid]=playerGang[playerid];
  271.  
  272.             } else
  273.                 msg(playerid, 0x83BFBFFF, "That member doesn't exist !");
  274.  
  275.         //Parasets//
  276.         } else if (gangcmd==4) {
  277.             PlayerLeaveGang(playerid);
  278.         }
  279.  
  280.         return 1;
  281.     }
  282.  
  283.     //------------------- /claninfo
  284.  
  285.     if(strcmp(cmd, "/claninfo", true) == 0) {
  286.         new tmp[256];
  287.         new gangnum;
  288.         tmp = strtok(cmdtext, idx);
  289.  
  290.         if(!strlen(tmp) && playerGang[playerid]==0) {
  291.             msg(playerid, 0x83BFBFFF, "Write: /ganginfo [Gang ID]");
  292.             return 1;
  293.         } else if (!strlen(tmp))
  294.             gangnum = playerGang[playerid];
  295.         else
  296.             gangnum = strval(tmp);
  297.  
  298.         if(gangInfo[gangnum][0]==0) {
  299.             msg(playerid, 0x83BFBFFF, "This gang ID doesn't exist !");
  300.             return 1;
  301.         }
  302.  
  303.         format(string, sizeof(string),"'%s' Gang members (id: %d)", gangNames[gangnum], gangnum);
  304.         msg(playerid, 0x83BFBFFF, string);
  305.  
  306.         for(new i = 0; i < gangInfo[gangnum][1]; i++) {
  307.             GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
  308.             format(string, sizeof(string),"%s (%d)", giveplayer, gangMembers[gangnum][i]);
  309.             msg(playerid, 0x83BFBFFF, string);
  310.         }
  311.  
  312.         return 1;
  313.     }
  314.  
  315.     //------------------- /clans
  316.  
  317.     if(strcmp(cmd, "/clans", true) == 0)
  318.     {
  319.         new x;
  320.  
  321.         msg(playerid, 0x83BFBFFF, "Existing gangs:");
  322.         for(new i=0; i < MAX_GANGS; i++) {
  323.             if(gangInfo[i][0]==1) {
  324.                 format(string, sizeof(string), "%s%s(%d) - %d members", string,gangNames[i],i,gangInfo[i][1]);
  325.  
  326.                 x++;
  327.                 if(x > 2) {
  328.                     msg(playerid, 0x83BFBFFF, string);
  329.                     x = 0;
  330.                     format(string, sizeof(string), "");
  331.                 } else {
  332.                     format(string, sizeof(string), "%s, ", string);
  333.                 }
  334.             }
  335.         }
  336.  
  337.         if(x <= 2 && x > 0) {
  338.             string[strlen(string)-2] = '.';
  339.             msg(playerid, 0x83BFBFFF, string);
  340.         }
  341.  
  342.         return 1;
  343.     }
  344.     return 0;
  345. }
  346.  
  347. stock PlayerName(playerid) {
  348.   new name[255];
  349.   GetPlayerName(playerid, name, 255);
  350.   return name;
  351. }
  352.  
  353. public PlayerLeaveGang(playerid) {
  354.     new string[256];
  355.     new playername[MAX_PLAYER_NAME];
  356.     new gangnum = playerGang[playerid];
  357.  
  358.     if(gangnum > 0) {
  359.         for(new i = 0; i < gangInfo[gangnum][1]; i++) {
  360.             if(gangMembers[gangnum][i]==playerid) {
  361.  
  362.                 // Only one member
  363.                 gangInfo[gangnum][1]--;
  364.  
  365.                 for(new j = i; j < gangInfo[gangnum][1]; j++) {
  366.                     //Shift banda de membri   -------- I dont know this one ... Something about members ans shift xD
  367.                     gangMembers[gangnum][j]=gangMembers[gangnum][j+1];
  368.                 }
  369.  
  370.                 //Destroy gang if there's no members
  371.                 if(gangInfo[gangnum][1]<1) {
  372.                     gangInfo[gangnum][0]=0;
  373.                     gangInfo[gangnum][1]=0;
  374.                     gangBank[gangnum]=0;
  375.                 }
  376.  
  377.                 //Warn members
  378.                 for(new j = 0; j < gangInfo[gangnum][1]; j++) {
  379.                     GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  380.                     format(string, sizeof(string),"%s left your gang !", playername);
  381.                     msg(gangMembers[gangnum][j], COLOR_ORANGE, string);
  382.                 }
  383.  
  384.                 format(string, sizeof(string),"You left gang '%s'(id: %d)", gangNames[gangnum], gangnum);
  385.                 msg(playerid, 0x83BFBFFF, string);
  386.  
  387.                 playerGang[playerid]=0;
  388.  
  389.                 SetPlayerColor(playerid,playerColors[playerid]);
  390.  
  391.                 return;
  392.             }
  393.         }
  394.     } else {
  395.         msg(playerid, 0x83BFBFFF, "You are not in any gang.");
  396.         }
  397. }
  398.  
  399. strtok(const string[], &index)
  400. {
  401.     new length = strlen(string);
  402.     while ((index < length) && (string[index] <= ' '))
  403.     {
  404.         index++;
  405.     }
  406.  
  407.     new offset = index;
  408.     new result[20];
  409.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  410.     {
  411.         result[index - offset] = string[index];
  412.         index++;
  413.     }
  414.     result[index - offset] = EOS;
  415.     return result;
  416. }
Add Comment
Please, Sign In to add comment