Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////////////////////////////
- // Gang FS //
- // by //
- // Marino Varesio //
- // //
- ////////////////////////////
- ////////////////////////////
- // Do not remove //
- // the credits. //
- // Fell free to use //
- // on your server. //
- // Do not upload again //
- // without my permission. //
- // //
- ////////////////////////////
- ////////////////////////////
- // Remove the // in front //
- // of //
- // #define FILTERSCRIPT //
- // to make it work //
- ////////////////////////////
- //#define FILTERSCRIPT
- #include <a_samp>
- #if defined FILTERSCRIPT
- #define MAX_STRING 256
- #define COLOR_GREY 0xAFAFAFAA
- #define COLOR_GREEN 0x33AA33AA
- #define COLOR_RED 0xFF0000FF
- #define COLOR_YELLOW 0xFFFF00AA
- #define COLOR_WHITE 0xFFFFFFAA
- #define COLOR_LIGHTBLUE 0x33CCFFAA
- #define COLOR_ORANGE 0xFF9900AA
- #define COLOR_PINK 0xFF66FFAA
- #define COLOR_PURPLE 0x9933CCAA
- #define COLOR_TURQ 0x00A3C0AA
- #define COLOR_CYAN 0x99FFFFAA
- #define COLOR_ORANGERED 0xE9370DFC
- #define COLOR_AQUA 0x7CFC00AA
- #define COLOR_INDIGO 0x4B00B0AA
- #define COLOR_LIGHTGREEN 0x33FF33AA
- #define MAX_GANGS 50
- #define MAX_GANG_MEMBERS 5
- #define MAX_GANG_NAME 15
- forward PlayerLeaveGang(playerid);
- //groups
- new gangMembers[MAX_GANGS][MAX_GANG_MEMBERS];
- new gangNames[MAX_GANGS][MAX_GANG_NAME];
- new gangInfo[MAX_GANGS][3]; //Don't change unless you know what you doing
- new playerGang[MAX_PLAYERS];
- new gangInvite[MAX_PLAYERS];
- public OnFilterScriptInit()
- {
- print("\n--------------------------------------");
- print(" Gangs FS by Marino Varesio");
- print("--------------------------------------\n");
- return 1;
- }
- public OnFilterScriptExit()
- {
- return 1;
- }
- #else
- main()
- {
- print("\n----------------------------------");
- print(" Blank Gamemode by your name here");
- print("----------------------------------\n");
- }
- #endif
- public OnGameModeInit()
- {
- // Don't use these lines if it's a filterscript
- SetGameModeText("Blank Script");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnGameModeExit()
- {
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- return 1;
- }
- public OnVehicleSpawn(vehicleid)
- {
- return 1;
- }
- public OnVehicleDeath(vehicleid, killerid)
- {
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new string[256];
- new playername[MAX_PLAYER_NAME];
- new sendername[MAX_PLAYER_NAME];
- new giveplayer[MAX_PLAYER_NAME];
- new giveplayerid;
- new cmd[256];
- new idx;
- cmd = strtok(cmdtext, idx);
- GetPlayerName(playerid, playername, sizeof playername);
- if(strcmp(cmd, "/team", true) == 0) { //teams
- new tmp[256];
- new gangcmd, gangnum;
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp)) {
- SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create/join/invite/quit] [name/id]");
- return 1;
- }
- giveplayerid = strval(tmp);
- if(strcmp(tmp, "create", true)==0)
- gangcmd = 1;
- else if(strcmp(tmp, "invite", true)==0)
- gangcmd = 2;
- else if(strcmp(tmp, "join", true)==0)
- gangcmd = 3;
- else if(strcmp(tmp, "quit", true)==0)
- gangcmd = 4;
- tmp = strtok(cmdtext, idx);
- if(gangcmd < 3 && !strlen(tmp)) {
- if(gangcmd==0)
- SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create/join/invite/quit] [name/id]");
- else if(gangcmd==1)
- SendClientMessage(playerid, COLOR_WHITE, "USE: /team [create] [name]");
- else if(gangcmd==2)
- SendClientMessage(playerid, COLOR_WHITE, "USE: /team [invite] [playerid]");
- return 1;
- }
- //create
- if(gangcmd==1) {
- if(playerGang[playerid]>0) {
- SendClientMessage(playerid, COLOR_RED, "You're already in a team!");
- return 1;
- }
- for(new i = 1; i < MAX_GANGS; i++) {
- if(gangInfo[i][0]==0) {
- format(gangNames[i], MAX_GANG_NAME, "%s", tmp);
- gangInfo[i][0]=1;
- gangInfo[i][1]=1;
- gangMembers[i][0] = playerid;
- format(string, sizeof(string),"You created a team '%s' (id: %d)", gangNames[i], i);
- SendClientMessage(playerid, COLOR_GREEN, string);
- playerGang[playerid]=i;
- return 1;
- }
- }
- return 1;
- //joining team
- } else if (gangcmd==3) {
- gangnum = gangInvite[playerid];
- if(playerGang[playerid]>0) {
- SendClientMessage(playerid, COLOR_RED, "You're already in a team!");
- return 1;
- }
- if(gangInvite[playerid]==0) {
- SendClientMessage(playerid, COLOR_RED, "You weren't invited.");
- return 1;
- }
- if(gangInfo[gangnum][0]==0) {
- SendClientMessage(playerid, COLOR_RED, "This team does not exist!");
- return 1;
- }
- if(gangInfo[gangnum][1] < MAX_GANG_MEMBERS) {
- new i = gangInfo[gangnum][1];
- gangInvite[playerid]=0;
- gangMembers[gangnum][i] = playerid;
- GetPlayerName(playerid, sendername, MAX_PLAYER_NAME);
- for(new j = 0; j < gangInfo[gangnum][1]; j++) {
- format(string, sizeof(string),"%s joined a team.", sendername);
- SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
- }
- gangInfo[gangnum][1]++;
- playerGang[playerid] = gangnum;
- format(string, sizeof(string),"You joined a team'%s' (id: %d)", gangNames[gangnum], gangnum);
- SendClientMessage(playerid, COLOR_GREEN, string);
- return 1;
- }
- SendClientMessage(playerid, COLOR_RED, "This team is full.");
- return 1;
- //invite
- } else if (gangcmd==2) {
- giveplayerid = strval(tmp);
- if(playerGang[playerid]==0) {
- SendClientMessage(playerid, COLOR_RED, "You're not in a team!");
- return 1;
- }
- if(gangMembers[playerGang[playerid]][0]!=playerid) {
- SendClientMessage(playerid, COLOR_RED, "You must be the team leader.");
- return 1;
- }
- if(IsPlayerConnected(giveplayerid)) {
- GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
- GetPlayerName(playerid, sendername, sizeof(sendername));
- format(string, sizeof(string),"You invited %s.", giveplayer);
- SendClientMessage(playerid, COLOR_GREEN, string);
- format(string, sizeof(string),"You were invited to join '%s' (id: %d)", sendername, gangNames[playerGang[playerid]],playerGang[playerid]);
- SendClientMessage(giveplayerid, COLOR_GREEN, string);
- gangInvite[giveplayerid]=playerGang[playerid];
- } else
- SendClientMessage(playerid, COLOR_RED, "Player does not exist!");
- //quit
- } else if (gangcmd==4) {
- PlayerLeaveGang(playerid);
- }
- return 1;
- }
- //info
- if(strcmp(cmd, "/teaminfo", true) == 0) {
- new tmp[256];
- new gangnum;
- tmp = strtok(cmdtext, idx);
- if(!strlen(tmp) && playerGang[playerid]==0) {
- SendClientMessage(playerid, COLOR_WHITE, "USE: /teaminfo [name/number]");
- return 1;
- } else if (!strlen(tmp))
- gangnum = playerGang[playerid];
- else
- gangnum = strval(tmp);
- if(gangInfo[gangnum][0]==0) {
- SendClientMessage(playerid, COLOR_RED, "This team does not exist!");
- return 1;
- }
- format(string, sizeof(string),"'%s' Team Members (id: %d)", gangNames[gangnum], gangnum);
- SendClientMessage(playerid, COLOR_GREEN, string);
- for(new i = 0; i < gangInfo[gangnum][1]; i++) {
- GetPlayerName(gangMembers[gangnum][i], giveplayer, sizeof(giveplayer));
- format(string, sizeof(string),"%s (%d)", giveplayer, gangMembers[gangnum][i]);
- SendClientMessage(playerid, COLOR_YELLOW, string);
- }
- return 1;
- }
- //teams
- if(strcmp(cmd, "/teams", true) == 0)
- {
- new AB;
- SendClientMessage(playerid, COLOR_GREEN, "Teams:");
- for(new i=0; i < MAX_GANGS; i++) {
- if(gangInfo[i][0]==1) {
- format(string, sizeof(string), "%s%s(%d) - %d members", string,gangNames[i],i,gangInfo[i][1]);
- AB++;
- if(AB > 2) {
- SendClientMessage(playerid, COLOR_YELLOW, string);
- AB = 0;
- format(string, sizeof(string), "..." );
- } else {
- format(string, sizeof(string), "%s, ", string);
- }
- }
- }
- if(AB <= 2 && AB > 0) {
- string[strlen(string)-2] = '.';
- SendClientMessage(playerid, COLOR_YELLOW, string);
- }
- return 1;
- }
- return 0;
- }
- public PlayerLeaveGang(playerid) {
- new string[256];
- new playername[MAX_PLAYER_NAME];
- new gangnum = playerGang[playerid];
- if(gangnum > 0) {
- for(new i = 0; i < gangInfo[gangnum][1]; i++) {
- if(gangMembers[gangnum][i]==playerid) {
- //One less team member
- gangInfo[gangnum][1]--;
- for(new j = i; j < gangInfo[gangnum][1]; j++) {
- //Shift team members
- gangMembers[gangnum][j]=gangMembers[gangnum][j+1];
- }
- //Disband team if no more members
- if(gangInfo[gangnum][1]<1) {
- gangInfo[gangnum][0]=0;
- gangInfo[gangnum][1]=0;
- }
- //Notify other members
- for(new j = 0; j < gangInfo[gangnum][1]; j++) {
- GetPlayerName(playerid, playername, MAX_PLAYER_NAME);
- format(string, sizeof(string),"%s has quit your gang.", playername);
- SendClientMessage(gangMembers[gangnum][j], COLOR_ORANGE, string);
- }
- format(string, sizeof(string),"You have quit the gang '%s' (id: %d)", gangNames[gangnum], gangnum);
- SendClientMessage(playerid, COLOR_ORANGE, string);
- playerGang[playerid]=0;
- return;
- }
- }
- } else {
- SendClientMessage(playerid, COLOR_RED, "You are not in a gang.");
- }
- }
- public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
- {
- return 1;
- }
- public OnPlayerExitVehicle(playerid, vehicleid)
- {
- return 1;
- }
- public OnPlayerStateChange(playerid, newstate, oldstate)
- {
- return 1;
- }
- public OnPlayerEnterCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerEnterRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnPlayerLeaveRaceCheckpoint(playerid)
- {
- return 1;
- }
- public OnRconCommand(cmd[])
- {
- return 1;
- }
- public OnPlayerRequestSpawn(playerid)
- {
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- return 1;
- }
- public OnPlayerObjectMoved(playerid, objectid)
- {
- return 1;
- }
- public OnPlayerPickUpPickup(playerid, pickupid)
- {
- return 1;
- }
- public OnVehicleMod(playerid, vehicleid, componentid)
- {
- return 1;
- }
- public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
- {
- return 1;
- }
- public OnVehicleRespray(playerid, vehicleid, color1, color2)
- {
- return 1;
- }
- public OnPlayerSelectedMenuRow(playerid, row)
- {
- return 1;
- }
- public OnPlayerExitedMenu(playerid)
- {
- return 1;
- }
- public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
- {
- return 1;
- }
- public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
- {
- return 1;
- }
- public OnRconLoginAttempt(ip[], password[], success)
- {
- return 1;
- }
- public OnPlayerUpdate(playerid)
- {
- return 1;
- }
- public OnPlayerStreamIn(playerid, forplayerid)
- {
- return 1;
- }
- public OnPlayerStreamOut(playerid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamIn(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnVehicleStreamOut(vehicleid, forplayerid)
- {
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- return 1;
- }
- public OnPlayerClickPlayer(playerid, clickedplayerid, source)
- {
- return 1;
- }
- strtok(const string[], &index)
- {
- new length = strlen(string);
- while ((index < length) && (string[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = string[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement