/* DYNAMIC ORGANIZATIONS FILTERSCRIPT CODED FROM SCRATCH BY JAKKU COPYRIGHT (C) 2011 - 2014 RELEASE DATE: 15/12/2011 PLEASE REPORT ALL BUGS (If found) @ SA-MP FORUMS - http://forum.sa-mp.com/showthread.php?t=303864 */ /* Changelog v.2 - CreateOrganizationZone can be used to create coloured "gangzones" for orgs - IsPlayerInOrgZone(playerid, orgname) - SendClientMessageToOrg(orgname, color, message) - Fixed some small bugs, nothing serious - Added auto-save for player stats and org. leaders (45sec delay) - Added /decline command for leaders to decline incoming requests Changelog 27.12.2014 - Fixed indentation :) */ #include #include #include #include //Color defines #define COLOR_GREY 0xAFAFAFAA #define COLOR_WHITE 0xFFFFFFAA #define COLOR_ORANGE 0xFF9900AA #define COLOR_YELLOW 0xFFFF00AA #define COLOR_RED 0xFF0000FF // #define WAGE 150 //Define the wage here #define MAX_ORGS 10 //Change only if you need more than 10 orgs #define MAX_ORG_WEAPONS 3 //Max amount of weapons for orgs #define ORG_NAME_LENGTH 32 //Max name length for organization and it's leader #define MAX_ORG_VEHICLES 10 #define MAX_ZONES_PER_ORG 10 #define SAVE_LEADERS_TO "org_leaders.txt" // Script configuration #define SPAWN_WITH_ORG_SKIN //Comment this line IF YOU DON'T WANT THE PLAYERS SPAWN WITH ORGANIZATION SKIN! #define ENABLE_HQ_TELE //Comment this line IF YOU WANT TO DISABLE /teletohq // forward PayDay(); forward CheckArea(); forward AutoSave(); new OrgsCount; new ZoneCount; enum Orgs { Name[32], Leader[24], Skin, Float:X, Float:Y, Float:Z, Weapons[3], Ammo[3], Vehicles[MAX_ORG_VEHICLES], VehiclesCreated, Text3D:OrgLabel, Zones[MAX_ZONES_PER_ORG], Float:ZoneMinX[MAX_ZONES_PER_ORG], Float:ZoneMinY[MAX_ZONES_PER_ORG], Float:ZoneMaxX[MAX_ZONES_PER_ORG], Float:ZoneMaxY[MAX_ZONES_PER_ORG], ZoneColor[MAX_ZONES_PER_ORG], ZonesCreated, }; new Organization[MAX_ORGS][Orgs]; new PlayerOrg[MAX_PLAYERS]; new PlayerLeader[MAX_PLAYERS]; new PlayerRank[MAX_PLAYERS][28]; new Requesting[MAX_PLAYERS]; new CollectedWage[MAX_PLAYERS]; public OnFilterScriptInit() { print("\n--------------------------------------"); print("==Dynamic organization filterscript by Jakku - initialized!=="); print("==(C) 2011 - 2012=="); print("--------------------------------------\n"); SetTimer("PayDay",1500000,1); //PayDay every 25 minutes SetTimer("CheckArea",1000,1); SetTimer("AutoSave",45000,1); /* ALWAYS add your organization BELOW the old one, otherwise the IDs will change = leaders mix up ! ! ! ! ! Syntax for CreateOrganization: CreateOrganization(name[32], skin, Float:x,Float:y,Float:z, wp1,a1,wp2,a2,wp3,a3) Syntax for CreateOrgVehicle: CreateOrgVehicle(orgname[32], modelid, Float:x,Float:y,Float:z,Float:rotation, color1,color2) Syntax for CreateOrganizationZone: CreateOrganizationZone(orgname[32], Float:minx,Float:miny,Float:maxx,Float:maxy, color) */ //Create ORGS here: // //Create ORG VEHICLES here: // //Create ORG ZONES here: // LoadLeaders(); //This MUST BE executed AFTER the organizations are being created! new pcount = 0; for (new playerid = 0;playerid 0) { printf("==Dynamic organization filterscript by Jakku reloaded!=="); printf("==Data loaded for %d connected players==", pcount); } return 1; } public PayDay() { for (new i=0;i= MAX_ORGS) return printf("You have exceeded the MAX_ORGS- define! Aborted"); new id = OrgsCount; Organization[id][Name] = name; Organization[id][Skin] = skin; Organization[id][X] = x; Organization[id][Y] = y; Organization[id][Z] = z; Organization[id][Weapons][0] = wp1; Organization[id][Ammo][0] = a1; Organization[id][Weapons][1] = wp2; Organization[id][Ammo][1] = a2; Organization[id][Weapons][2] = wp3; Organization[id][Ammo][2] = a3; printf("Organization created: ID: %d || Name: %s",id, name); new string[100]; format(string,sizeof(string),"{5CB3FF}HQ:{FFFFFF} %s\nType {5CB3FF}/org{FFFFFF} for more information!",name); Organization[id][OrgLabel] = Create3DTextLabel(string, 0x008080FF, x, y, z, 25.0, 0); return 1; } stock PlayerPath(playerid) { new path[45]; format(path, sizeof(path),"Orginfo_%s.ini", PlayerName(playerid)); return path; } stock SaveLeaders() { new part[40]; if (!dini_Exists(SAVE_LEADERS_TO)) { dini_Create(SAVE_LEADERS_TO); } for (new i=1;i OrgsCount) return SendClientMessage(playerid, COLOR_RED,"Invalid org. ID!"); new string[140]; format(string,sizeof(string),"An admin %s has set you as the leader of %s", PlayerName(playerid), GetOrgName(orgid)); SendClientMessage(ID, COLOR_YELLOW, string); format(string,sizeof(string),"You have set %s the leader of %s", PlayerName(ID), GetOrgName(orgid)); SendClientMessage(playerid, COLOR_YELLOW, string); PlayerOrg[ID] = orgid; PlayerLeader[ID] = 1; Organization[orgid][Leader] = PlayerName(ID); SaveLeaders(); SavePlayerOrgInfo(ID); GiveOrgFeatures(ID); return 1; } CMD:setrank(playerid, params[]) { if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization"); new ID, rank[28]; if (sscanf(params, "us[28]", ID, rank)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /setrank [playerid] [rank]"); if (strlen(rank) > 28) return SendClientMessage(playerid, COLOR_RED,"The maximum rank length is 28 characters!"); if (!IsPlayerConnected(ID)) return 1; new org = PlayerOrg[playerid]; if (PlayerOrg[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player does not belong to your organization"); new string[120]; format(string,sizeof(string),"Your leader %s has given you a rank: '%s'", PlayerName(playerid), rank); SendClientMessage(ID, COLOR_YELLOW, string); format(string,sizeof(string),"You have given a rank to %s (%s)", PlayerName(ID), rank); SendClientMessage(playerid, COLOR_YELLOW, string); PlayerRank[ID] = rank; SavePlayerOrgInfo(ID); return 1; } CMD:kickmember(playerid, params[]) { if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization"); new ID; if (sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /kickmember [playerid]"); if (!IsPlayerConnected(ID) || ID == playerid) return 1; new org = PlayerOrg[playerid]; if (PlayerOrg[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player does not belong to your organization"); new string[130]; format(string,sizeof(string),"%s has kicked you from %s", PlayerName(playerid), GetOrgName(org)); SendClientMessage(ID, COLOR_YELLOW, string); format(string,sizeof(string),"You have kicked %s from %s", PlayerName(ID), GetOrgName(org)); SendClientMessage(playerid, COLOR_YELLOW, string); ResetPlayerOrg(ID); return 1; } CMD:request(playerid, params[]) { if (PlayerOrg[playerid] > 0) return SendClientMessage(playerid, COLOR_RED,"You already belong to an organization!"); if (Requesting[playerid] > 0) return SendClientMessage(playerid, COLOR_RED,"You are already requesting to join an organization!"); new ID; if (sscanf(params, "d", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /request [org id]"); if (ID < 1 || ID > OrgsCount) return SendClientMessage(playerid,COLOR_RED,"Invalid organization ID! Type /orglist for a complete list"); if (!IsLeaderOnline(ID)) return SendClientMessage(playerid,COLOR_RED,"The leader of this organization is currently offline!"); new string[120]; format(string,sizeof(string),"%s is requesting to join the %s", PlayerName(playerid), GetOrgName(ID)); SendClientMessageToAllEx(playerid, COLOR_GREY, string); format(string,sizeof(string),"Your request to %s has been sent", GetOrgName(ID)); SendClientMessage(playerid, COLOR_YELLOW, string); Requesting[playerid] = ID; return 1; } CMD:decline(playerid, params[]) { if (!IsLeader(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not the leader of an organization"); new ID; if (sscanf(params, "u", ID)) return SendClientMessage(playerid,COLOR_WHITE,"Usage: /decline [playerid]"); if (!IsPlayerConnected(ID) || ID == playerid) return 1; new org = PlayerOrg[playerid]; if (Requesting[ID] != org) return SendClientMessage(playerid, COLOR_RED,"That player is not requesting to join your organization!"); new string[120]; format(string,sizeof(string),"Your request to %s has been declined by %s", GetOrgName(org), PlayerName(playerid)); SendClientMessage(ID, COLOR_GREY, string); format(string,sizeof(string),"You have successfully declined %s's request", PlayerName(ID)); SendClientMessage(playerid, COLOR_YELLOW, string); Requesting[ID] = 0; return 1; } CMD:orglist(playerid) { new string[90]; if (OrgsCount == 0) return SendClientMessage(playerid, COLOR_RED,"Sorry, there are no organizations created at the moment!"); SendClientMessage(playerid, COLOR_WHITE, "Current organizations:"); for (new i=1;i= MAX_ORG_VEHICLES) return printf("Error: %s cannot handle more vehicles! Aborted", org); Organization[orgid][Vehicles][freeslot] = CreateVehicle(model, x,y,z,rot,clr1,clr2,900); printf("Added org. vehicle: %d to slot %d for %s",model,freeslot+1, org); Organization[orgid][VehiclesCreated]++; return 1; } stock IsLeaderOnline(org) { for (new i = 0; i < MAX_PLAYERS; i++) { if (IsPlayerConnected(i)) { if (PlayerOrg[i] == org && PlayerLeader[i] == 1) return true; } } return false; } stock IsLeader(playerid) { if (PlayerOrg[playerid] != 0 && PlayerLeader[playerid] == 1) return 1; return 0; } stock IsVehicleConnected(vehicleid) { new Float:x1,Float:y1,Float:z1; GetVehiclePos(vehicleid,x1,y1,z1); if(x1==0.0 && y1==0.0 && z1==0.0) { return 0; } return 1; } stock DoesOrgExist(orgname[32]) { for (new i=1;i= MAX_ZONES_PER_ORG) return printf("Error: You are attempting to create more than %d zones for %s", MAX_ZONES_PER_ORG, orgname); new id = Organization[orgid][ZonesCreated]; Organization[orgid][ZoneMinX][id] = minx; Organization[orgid][ZoneMinY][id] = miny; Organization[orgid][ZoneMaxX][id] = maxx; Organization[orgid][ZoneMaxY][id] = maxy; Organization[orgid][ZoneColor][id] = hexToDec(color); Organization[orgid][Zones][id] = GangZoneCreate(minx, miny, maxx, maxy); ZoneCount++; return ZoneCount; } stock hexToDec(hex) { new out[11]; format(out, 11, "%i", hex); return strval(out); } stock IsPlayerInArea(playerid, Float:MinX, Float:MinY, Float:MaxX, Float:MaxY) { new Float:AX, Float:AY, Float:AZ; GetPlayerPos(playerid, AX, AY, AZ); if (AX > MinX && AX < MaxX && AY > MinY && AY < MaxY) return true; else return false; } stock IsPlayerInOrgZone(playerid, orgname[32]) { new orgid = GetOrgID(orgname); if (DoesOrgExist(orgname)) { for (new i=1;i