Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 12.10 KB | None | 0 0
  1.  
  2.                     ////////////////////////////
  3.                     //        Gang FS         //
  4.                     //           by           //
  5.                     //     Marino Varesio     //
  6.                     //                        //
  7.                     ////////////////////////////
  8.  
  9.                     ////////////////////////////
  10.                     //     Do not remove      //
  11.                     //      the credits.      //
  12.                     //    Fell free to use    //
  13.                     //     on your server.    //
  14.                     //  Do not upload again   //
  15.                     // without my permission. //
  16.                     //                        //
  17.                     ////////////////////////////
  18.                    
  19.                     ////////////////////////////
  20.                     // Remove the // in front //
  21.                     //           of           //
  22.                     //  #define FILTERSCRIPT  //
  23.                     //    to make it work     //
  24.                     ////////////////////////////
  25.  
  26.  
  27.  
  28.  
  29.  
  30. //#define FILTERSCRIPT
  31.  
  32. #include <a_samp>
  33.  
  34. #if defined FILTERSCRIPT
  35.  
  36.  
  37.  
  38. #define MAX_STRING 256
  39. #define COLOR_GREY 0xAFAFAFAA
  40. #define COLOR_GREEN 0x33AA33AA
  41. #define COLOR_RED 0xFF0000FF
  42. #define COLOR_YELLOW 0xFFFF00AA
  43. #define COLOR_WHITE 0xFFFFFFAA
  44. #define COLOR_LIGHTBLUE 0x33CCFFAA
  45. #define COLOR_ORANGE 0xFF9900AA
  46. #define COLOR_PINK 0xFF66FFAA
  47. #define COLOR_PURPLE 0x9933CCAA
  48. #define COLOR_TURQ 0x00A3C0AA
  49. #define COLOR_CYAN 0x99FFFFAA
  50. #define COLOR_ORANGERED 0xE9370DFC
  51. #define COLOR_AQUA 0x7CFC00AA
  52. #define COLOR_INDIGO 0x4B00B0AA
  53. #define COLOR_LIGHTGREEN 0x33FF33AA
  54. #define MAX_GANGS           50
  55. #define MAX_GANG_MEMBERS    5
  56. #define MAX_GANG_NAME       15
  57.  
  58.  
  59. forward PlayerLeaveGang(playerid);
  60.  
  61.  
  62. //groups
  63. new gangMembers[MAX_GANGS][MAX_GANG_MEMBERS];
  64. new gangNames[MAX_GANGS][MAX_GANG_NAME];
  65. new gangInfo[MAX_GANGS][3]; //Don't change unless you know what you doing
  66. new playerGang[MAX_PLAYERS];
  67. new gangInvite[MAX_PLAYERS];
  68.  
  69.  
  70.  
  71.  
  72. public OnFilterScriptInit()
  73. {
  74.     print("\n--------------------------------------");
  75.     print(" Gangs FS by Marino Varesio");
  76.     print("--------------------------------------\n");
  77.     return 1;
  78. }
  79.  
  80. public OnFilterScriptExit()
  81. {
  82.     return 1;
  83. }
  84.  
  85. #else
  86.  
  87. main()
  88. {
  89.     print("\n----------------------------------");
  90.     print(" Blank Gamemode by your name here");
  91.     print("----------------------------------\n");
  92. }
  93.  
  94. #endif
  95.  
  96. public OnGameModeInit()
  97. {
  98.     // Don't use these lines if it's a filterscript
  99.     SetGameModeText("Blank Script");
  100.     AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
  101.     return 1;
  102. }
  103.  
  104. public OnGameModeExit()
  105. {
  106.     return 1;
  107. }
  108.  
  109. public OnPlayerRequestClass(playerid, classid)
  110. {
  111.     SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
  112.     SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
  113.     SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
  114.     return 1;
  115. }
  116.  
  117. public OnPlayerConnect(playerid)
  118. {
  119.     return 1;
  120. }
  121.  
  122. public OnPlayerDisconnect(playerid, reason)
  123. {
  124.     return 1;
  125. }
  126.  
  127. public OnPlayerSpawn(playerid)
  128. {
  129.     return 1;
  130. }
  131.  
  132. public OnPlayerDeath(playerid, killerid, reason)
  133. {
  134.     return 1;
  135. }
  136.  
  137. public OnVehicleSpawn(vehicleid)
  138. {
  139.     return 1;
  140. }
  141.  
  142. public OnVehicleDeath(vehicleid, killerid)
  143. {
  144.     return 1;
  145. }
  146.  
  147. public OnPlayerText(playerid, text[])
  148. {
  149.     return 1;
  150. }
  151.  
  152. public OnPlayerCommandText(playerid, cmdtext[])
  153. {
  154.     new string[256];
  155.     new playername[MAX_PLAYER_NAME];
  156.     new sendername[MAX_PLAYER_NAME];
  157.     new giveplayer[MAX_PLAYER_NAME];
  158.     new giveplayerid;
  159.     new cmd[256];
  160.     new idx;
  161.     cmd = strtok(cmdtext, idx);
  162.     GetPlayerName(playerid, playername, sizeof playername);
  163.     if(strcmp(cmd, "/team", true) == 0) {  //teams
  164.         new tmp[256];
  165.         new gangcmd, gangnum;
  166.         tmp = strtok(cmdtext, idx);
  167.  
  168.         if(!strlen(tmp)) {
  169.             SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create/join/invite/quit] [name/id]");
  170.             return 1;
  171.         }
  172.         giveplayerid = strval(tmp);
  173.  
  174.         if(strcmp(tmp, "create", true)==0)
  175.             gangcmd = 1;
  176.         else if(strcmp(tmp, "invite", true)==0)
  177.             gangcmd = 2;
  178.         else if(strcmp(tmp, "join", true)==0)
  179.             gangcmd = 3;
  180.         else if(strcmp(tmp, "quit", true)==0)
  181.             gangcmd = 4;
  182.  
  183.         tmp = strtok(cmdtext, idx);
  184.         if(gangcmd < 3 && !strlen(tmp)) {
  185.             if(gangcmd==0)
  186.                 SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create/join/invite/quit] [name/id]");
  187.             else if(gangcmd==1)
  188.                 SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create] [name]");
  189.             else if(gangcmd==2)
  190.                 SendClientMessage(playerid, COLOR_WHITE, "USE: /team [invite] [playerid]");
  191.             return 1;
  192.         }
  193.  
  194.         //create
  195.         if(gangcmd==1) {
  196.             if(playerGang[playerid]>0) {
  197.                 SendClientMessage(playerid, COLOR_RED, "You're already in a team!");
  198.                 return 1;
  199.             }
  200.  
  201.             for(new i = 1; i < MAX_GANGS; i++) {
  202.                 if(gangInfo[i][0]==0) {
  203.                     format(gangNames[i], MAX_GANG_NAME, "%s", tmp);
  204.                     gangInfo[i][0]=1;
  205.                     gangInfo[i][1]=1;
  206.                     gangMembers[i][0] = playerid;
  207.                     format(string, sizeof(string),"You created a team '%s' (id: %d)", gangNames[i], i);
  208.                     SendClientMessage(playerid, COLOR_GREEN, string);
  209.                     playerGang[playerid]=i;
  210.  
  211.                     return 1;
  212.                 }
  213.             }
  214.             return 1;
  215.         //joining team
  216.         } else if (gangcmd==3) {
  217.             gangnum = gangInvite[playerid];
  218.  
  219.             if(playerGang[playerid]>0) {
  220.                 SendClientMessage(playerid, COLOR_RED, "You're already in a team!");
  221.                 return 1;
  222.             }
  223.             if(gangInvite[playerid]==0) {
  224.                 SendClientMessage(playerid, COLOR_RED, "You weren't invited.");
  225.                 return 1;
  226.             }
  227.             if(gangInfo[gangnum][0]==0) {
  228.                 SendClientMessage(playerid, COLOR_RED, "This team does not exist!");
  229.                 return 1;
  230.             }
  231.  
  232.             if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS) {
  233.                 new i = gangInfo[gangnum][1];
  234.                 gangInvite[playerid]=0;
  235.                 gangMembers[gangnum][i] = playerid;
  236.                 GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
  237.                 for(new j = 0; j < gangInfo[gangnum][1]; j++) {
  238.                     format(string, sizeof(string),"%s joined a team.", sendername);
  239.                     SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
  240.                 }
  241.                 gangInfo[gangnum][1]++;
  242.                 playerGang[playerid] = gangnum;
  243.                 format(string, sizeof(string),"You joined a team'%s' (id: %d)", gangNames[gangnum], gangnum);
  244.                 SendClientMessage(playerid, COLOR_GREEN, string);
  245.                 return 1;
  246.             }
  247.             SendClientMessage(playerid, COLOR_RED, "This team is full.");
  248.             return 1;
  249.         //invite
  250.         } else if (gangcmd==2) {
  251.             giveplayerid = strval(tmp);
  252.             if(playerGang[playerid]==0) {
  253.                 SendClientMessage(playerid, COLOR_RED, "You're not in a team!");
  254.                 return 1;
  255.             }
  256.             if(gangMembers[playerGang[playerid]][0]!=playerid) {
  257.                 SendClientMessage(playerid, COLOR_RED, "You must be the team leader.");
  258.                 return 1;
  259.             }
  260.             if(IsPlayerConnected(giveplayerid)) {
  261.                 GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
  262.                 GetPlayerName(playerid, sendername, sizeof(sendername));
  263.                 format(string, sizeof(string),"You invited %s.", giveplayer);
  264.                 SendClientMessage(playerid, COLOR_GREEN, string);
  265.                 format(string, sizeof(string),"You were invited to join '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
  266.                 SendClientMessage(giveplayerid, COLOR_GREEN, string);
  267.                 gangInvite[giveplayerid]=playerGang[playerid];
  268.             } else
  269.                 SendClientMessage(playerid, COLOR_RED, "Player does not exist!");
  270.         //quit
  271.         } else if (gangcmd==4) {
  272.             PlayerLeaveGang(playerid);
  273.         }
  274.         return 1;
  275.     }
  276.     //info
  277.     if(strcmp(cmd, "/teaminfo", true) == 0) {
  278.         new tmp[256];
  279.         new gangnum;
  280.         tmp = strtok(cmdtext, idx);
  281.         if(!strlen(tmp) && playerGang[playerid]==0) {
  282.             SendClientMessage(playerid, COLOR_WHITE, "USE: /teaminfo [name/number]");
  283.             return 1;
  284.         } else if (!strlen(tmp))
  285.             gangnum = playerGang[playerid];
  286.         else
  287.             gangnum = strval(tmp);
  288.         if(gangInfo[gangnum][0]==0) {
  289.             SendClientMessage(playerid, COLOR_RED, "This team does not exist!");
  290.             return 1;
  291.         }
  292.         format(string, sizeof(string),"'%s' Team Members (id: %d)", gangNames[gangnum], gangnum);
  293.         SendClientMessage(playerid, COLOR_GREEN, string);
  294.         for(new i = 0; i < gangInfo[gangnum][1]; i++) {
  295.             GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
  296.             format(string, sizeof(string),"%s (%d)", giveplayer, gangMembers[gangnum][i]);
  297.             SendClientMessage(playerid, COLOR_YELLOW, string);
  298.         }
  299.         return 1;
  300.     }
  301.     //teams
  302.     if(strcmp(cmd, "/teams", true) == 0)
  303.     {
  304.         new AB;
  305.         SendClientMessage(playerid, COLOR_GREEN, "Teams:");
  306.         for(new i=0; i < MAX_GANGS; i++) {
  307.             if(gangInfo[i][0]==1) {
  308.                 format(string, sizeof(string), "%s%s(%d) - %d members", string,gangNames[i],i,gangInfo[i][1]);
  309.                 AB++;
  310.                 if(AB > 2) {
  311.                     SendClientMessage(playerid, COLOR_YELLOW, string);
  312.                     AB = 0;
  313.                     format(string, sizeof(string), "..." );
  314.                 } else {
  315.                     format(string, sizeof(string), "%s, ", string);
  316.                 }
  317.             }
  318.         }
  319.         if(AB <= 2 && AB > 0) {
  320.             string[strlen(string)-2] = '.';
  321.             SendClientMessage(playerid, COLOR_YELLOW, string);
  322.         }
  323.         return 1;
  324.     }
  325.     return 0;
  326. }
  327. public PlayerLeaveGang(playerid) {
  328.     new string[256];
  329.     new playername[MAX_PLAYER_NAME];
  330.     new gangnum = playerGang[playerid];
  331.  
  332.     if(gangnum > 0) {
  333.         for(new i = 0; i < gangInfo[gangnum][1]; i++) {
  334.             if(gangMembers[gangnum][i]==playerid) {
  335.  
  336.                 //One less team member
  337.                 gangInfo[gangnum][1]--;
  338.  
  339.                 for(new j = i; j < gangInfo[gangnum][1]; j++) {
  340.                     //Shift team members
  341.                     gangMembers[gangnum][j]=gangMembers[gangnum][j+1];
  342.                 }
  343.  
  344.                 //Disband team if no more members
  345.                 if(gangInfo[gangnum][1]<1) {
  346.                     gangInfo[gangnum][0]=0;
  347.                     gangInfo[gangnum][1]=0;
  348.                 }
  349.  
  350.                 //Notify other members
  351.                 for(new j = 0; j < gangInfo[gangnum][1]; j++) {
  352.                     GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
  353.                     format(string, sizeof(string),"%s has quit your gang.", playername);
  354.                     SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
  355.                 }
  356.                 format(string, sizeof(string),"You have quit the gang '%s' (id: %d)", gangNames[gangnum], gangnum);
  357.                 SendClientMessage(playerid, COLOR_ORANGE, string);
  358.                 playerGang[playerid]=0;
  359.                 return;
  360.             }
  361.         }
  362.     } else {
  363.         SendClientMessage(playerid, COLOR_RED, "You are not in a gang.");
  364.     }
  365. }
  366.  
  367. public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
  368. {
  369.     return 1;
  370. }
  371.  
  372. public OnPlayerExitVehicle(playerid, vehicleid)
  373. {
  374.     return 1;
  375. }
  376.  
  377. public OnPlayerStateChange(playerid, newstate, oldstate)
  378. {
  379.     return 1;
  380. }
  381.  
  382. public OnPlayerEnterCheckpoint(playerid)
  383. {
  384.     return 1;
  385. }
  386.  
  387. public OnPlayerLeaveCheckpoint(playerid)
  388. {
  389.     return 1;
  390. }
  391.  
  392. public OnPlayerEnterRaceCheckpoint(playerid)
  393. {
  394.     return 1;
  395. }
  396.  
  397. public OnPlayerLeaveRaceCheckpoint(playerid)
  398. {
  399.     return 1;
  400. }
  401.  
  402. public OnRconCommand(cmd[])
  403. {
  404.     return 1;
  405. }
  406.  
  407. public OnPlayerRequestSpawn(playerid)
  408. {
  409.     return 1;
  410. }
  411.  
  412. public OnObjectMoved(objectid)
  413. {
  414.     return 1;
  415. }
  416.  
  417. public OnPlayerObjectMoved(playerid, objectid)
  418. {
  419.     return 1;
  420. }
  421.  
  422. public OnPlayerPickUpPickup(playerid, pickupid)
  423. {
  424.     return 1;
  425. }
  426.  
  427. public OnVehicleMod(playerid, vehicleid, componentid)
  428. {
  429.     return 1;
  430. }
  431.  
  432. public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
  433. {
  434.     return 1;
  435. }
  436.  
  437. public OnVehicleRespray(playerid, vehicleid, color1, color2)
  438. {
  439.     return 1;
  440. }
  441.  
  442. public OnPlayerSelectedMenuRow(playerid, row)
  443. {
  444.     return 1;
  445. }
  446.  
  447. public OnPlayerExitedMenu(playerid)
  448. {
  449.     return 1;
  450. }
  451.  
  452. public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
  453. {
  454.     return 1;
  455. }
  456.  
  457. public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
  458. {
  459.     return 1;
  460. }
  461.  
  462. public OnRconLoginAttempt(ip[], password[], success)
  463. {
  464.     return 1;
  465. }
  466.  
  467. public OnPlayerUpdate(playerid)
  468. {
  469.     return 1;
  470. }
  471.  
  472. public OnPlayerStreamIn(playerid, forplayerid)
  473. {
  474.     return 1;
  475. }
  476.  
  477. public OnPlayerStreamOut(playerid, forplayerid)
  478. {
  479.     return 1;
  480. }
  481.  
  482. public OnVehicleStreamIn(vehicleid, forplayerid)
  483. {
  484.     return 1;
  485. }
  486.  
  487. public OnVehicleStreamOut(vehicleid, forplayerid)
  488. {
  489.     return 1;
  490. }
  491.  
  492. public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
  493. {
  494.     return 1;
  495. }
  496.  
  497. public OnPlayerClickPlayer(playerid, clickedplayerid, source)
  498. {
  499.     return 1;
  500. }
  501. strtok(const string[], &index)
  502. {
  503.     new length = strlen(string);
  504.     while ((index < length) && (string[index] <= ' '))
  505.     {
  506.         index++;
  507.     }
  508.  
  509.     new offset = index;
  510.     new result[20];
  511.     while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
  512.     {
  513.         result[index - offset] = string[index];
  514.         index++;
  515.     }
  516.     result[index - offset] = EOS;
  517.     return result;
  518. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement