Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- - Originally created by '[HiC]TheKiller' under the request of 'Weponz'
- - Re-made by Kyance
- ------------ CHANGELOG --------------
- Date format: day/month/year || dd/mm/yyyy
- Version 1 15/04/2014
- - Re-named the 'Group' stuff to 'Squad'
- - Made the /squads a dialog instead of a message
- - Changed Squad-Chat to the '!' key
- Version 2 16/04/2014
- - Added /sreward ( /squadreward )
- - Changed and improved /sinvite ( /squadinvite )
- - Added a /shelp ( /squadhelp ) command
- - Fixed Squad-Chat
- Version 2.5 16/04/2014
- - Added another Squad Leaving message ( when a player switches his team )
- - Added /squadspawn ( Spawn on either the Leader or a Member ( RANDOM ) )
- - Fixed a small /sreward bug
- Version 3 18/04/2014
- - Fixed squad-spawn 'compatability' bug with Gamemodes which have Random Spawns etc.
- - Added /squaddisband
- - Added /squadedit
- - Fixed a small bug with /squadinvie
- - Added /squadannounce ( Announce a message to all squad-members )
- - Fixed a small bug with /squadedit
- Version 3.5 18/04/2014
- - Made /squadedit some-what easier to notice
- - Changed the way how 'MAX_SQUAD_MEMBERS' works, now it's a enum/variable or w.e, updated the /squadedit due to this too
- - Changed from the regular samp loop to foreach
- - Fixed some small loop bugs ( squad messages, they were sending 2x to the leader )
- - Fixed a bug with /squadspawn ( Leader spawning on himself.. )
- Version 4.0 18/04/2014
- - Fixed some bugs with /squadedit ( Mostly bracket fails.. )
- - Fixed a bug with renaming the squad
- Version 4.5 20/04/2014
- - Fixed a bug with /squaddisband ---
- Version 5.0 20/04/2014
- - Added a 'detailed' squad info logging ( Creaton, Squad Chat, Announcements etc.. )
- IMPORTANT: You need to create squadlogs.txt at 'scriptfiles/squadlogs', otherwise the script will unload itself.
- Version 5.5 21/04/2014 CURRENT VERSION
- - Fixed a squad-logging bug at 'LeaveSquad', the reasons were bugged.
- - Fixed ( once again ) the /squaddisband command.
- ------------ KNOWN BUGS / POSSIBLE BUGS / FIXED BUGS --------------
- +++ = Known bug(s)
- --- = Possible bug(s)
- /// = FIXED ... SOLVED ... FALSE BUG(S)
- ---/// The 'member spawn' could be possibly bugged, although it might be a NPC test problem, dunno /// Eh, i tested it with me and a NPC, so it shouldn't be bugged.. Script looks fine!
- +++ Message saying "You have been auto-removed from the squad due to changing the team" on the FIRST spawn
- +++ /squaddisband sometimes gets bugged
- /// Fixed a Squad Limit bug
- /// Fixed a Squad renaming bug
- /// Fixed a writing/squadlogging bug at 'LeaveSquad'
- */
- #include <a_samp>
- #include <zcmd>
- #include <foreach>
- #define MAX_SQUADS 20
- //#define MAX_SQUAD_MEMBERS 5
- #define DIALOG_SQUAD_LIST 1
- #define DIALOG_SQUAD_HELP_PAGE1 2
- #define DIALOG_SQUAD_HELP_PAGE2 3
- #define DIALOG_SQUAD_HELP_PAGE3 4
- #define DIALOG_SQUAD_EDIT 5
- #define DIALOG_SQUAD_EDIT_NAME 6
- #define DIALOG_SQUAD_DISBAND 7
- #define DIALOG_SQUAD_EDIT_INVITE 8
- #define DIALOG_SQUAD_EDIT_LIMIT 9
- enum sinfo
- {
- sqname[70],
- sqteam,
- sqmembers,
- sqmaxmembers,
- leader,
- invitemode,
- active
- };
- enum psinfo
- {
- sid,
- order,
- memberspawn,
- leaderspawn,
- invited,
- pteam,
- rewardtype,
- attemptjoin
- };
- new squad[MAX_PLAYERS][psinfo];
- new squadinfo[MAX_SQUADS][sinfo];
- new
- slday,
- slmonth,
- slyear,
- slsecond,
- slminute,
- slhour
- ;
- forward SquadSpawn(playerid);
- forward CheckForFile();
- forward fcreate(filename[]);
- public OnFilterScriptInit()
- {
- print("Squads System 4.0 has been successfully initialized\nOriginal creator: [HiC]TheKiller\nRemade by Kyance");
- foreach(Player, x)
- {
- squad[x][sid] = -1;
- squad[x][order] = -1;
- squad[x][invited] = -1;
- squad[x][attemptjoin] = -1;
- }
- print("Successfully reset all squad-data");
- if(!fexist("/squadlogs/squadlogs.txt"))
- {
- printf("WARNING: 'squadlogs.txt' does NOT exist at the 'scriptfiles/squadlogs' folder");
- print("NOTIFICATION: attempting to create 'squadlogs.txt'");
- SetTimer("CheckForFile", 5000, false);
- fcreate("/squadlogs/squadlogs.txt");
- }
- else
- {
- new string[132];
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - filterscript successfully loaded\r\n", slday, slmonth, slyear, slhour, slminute, slsecond);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- squad[playerid][sid] = -1;
- squad[playerid][invited] = -1;
- squad[playerid][attemptjoin] = -1;
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- LeaveSquad(playerid, 3);
- return 1;
- }
- public OnPlayerSpawn(playerid)
- {
- if(squad[playerid][sid] != -1)
- {
- if(GetPlayerTeam(playerid) != squadinfo[sid][sqteam])
- {
- LeaveSquad(playerid, 2);
- }
- SetTimerEx("SquadSpawn", 200, false, "i", playerid);
- }
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- new
- /*Float:armour = GetPlayerArmour(killerid, armour),
- Float:health = GetPlayerHealth(killerid, health),
- money = GetPlayerMoney(killerid),
- score = GetPlayerScore(killerid),
- ammo = GetPlayerAmmo(killerid),*/
- string[122],
- name[MAX_PLAYER_NAME]
- ;
- GetPlayerName(killerid, name, sizeof(name));
- if(squad[killerid][rewardtype] == 1)
- {
- /*foreach(Player, x)
- {
- if(squad[x][sid] == squad[killerid][sid] && x != killerid)
- {
- new moneyreward = 1000+random(2001);
- format(string, sizeof(string), "SQUAD: You've been rewarded %i$ from %s's kill!", moneyreward, name);
- SendClientMessage(i, 0x00FF7FAA, string);
- }
- }*/
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[killerid][sid] && x != killerid)
- {
- new
- armourreward = 5+random(20),
- Float:armour = GetPlayerArmour(x, armour)
- ;
- format(string, sizeof(string), "SQUAD: You've been rewarded %0.1f ARMOUR from %s's kill!", armourreward, name);
- SendClientMessage(x, 0x00FF7FAA, string);
- SetPlayerArmour(x, armour+armourreward);
- if(armour >= 100)
- {
- SetPlayerArmour(x, 99);
- }
- }
- }
- }
- else if(squad[killerid][rewardtype] == 2)
- {
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[killerid][sid] && x != killerid)
- {
- new
- healthreward = 5+random(15),
- Float:health = GetPlayerHealth(x, health)
- ;
- format(string, sizeof(string), "SQUAD: You've been rewarded %0.1f HEALTH from %s's kill!", healthreward, name);
- SendClientMessage(x, 0x00FF7FAA, string);
- SetPlayerHealth(x, health+healthreward);
- if(health >= 100)
- {
- SetPlayerHealth(x, 99);
- }
- }
- }
- }
- else if(squad[killerid][rewardtype] == 3)
- {
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[killerid][sid] && x != killerid)
- {
- new
- scorereward = 1+random(2),
- score = GetPlayerScore(x)
- ;
- format(string, sizeof(string), "SQUAD: You've been rewarded %d SCORE from %s's kill!", scorereward, name);
- SendClientMessage(x, 0x00FF7FAA, string);
- SetPlayerScore(x, score+scorereward);
- if(score >= 200)
- {
- squad[killerid][rewardtype] = 1;
- SendClientMessage(x, 0x00FF7FAA, "SQUAD: Since you have 200 ( or more ), your Reward type has been set to ARMOUR");
- }
- }
- }
- }
- else if(squad[killerid][rewardtype] == 4)
- {
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[killerid][sid] && x != killerid)
- {
- new
- ammo = GetPlayerAmmo(x),
- weapon = GetPlayerWeapon(x),
- ammoreward = ammo+random(100)
- ;
- if(GetPlayerWeapon(x) != 16 || GetPlayerWeapon(x) != 18 || GetPlayerWeapon(x) != 35 || GetPlayerWeapon(x) != 36)
- {
- format(string, sizeof(string), "SQUAD: You've been rewarded %d AMMO from %s's kill!", ammoreward, name);
- SendClientMessage(x, 0x00FF7FAA, string);
- //GetPlayerAmmo(x, ammo);
- SetPlayerAmmo(x, weapon, ammoreward);
- }
- }
- }
- }
- return 1;
- }
- public OnPlayerText(playerid, text[])
- {
- if(squad[playerid][sid] != -1 && text[0] == '!')
- {
- new
- pname[MAX_PLAYER_NAME],
- string[132]
- ;
- GetPlayerName(playerid, pname, sizeof(pname));
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid])
- {
- format(string, sizeof(string), "{FFCC66}SQUAD CHAT: %s[%d]: %s", pname, playerid, text[1]);
- SendClientMessage(x, -1, string);
- return 0;
- }
- }
- //SendMessageToAllsquadMembers(squad[playerid][sid], string);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has said %s in the squad-chat\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, text[1]);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_SQUAD_HELP_PAGE1:
- {
- if(!response)
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE2, DIALOG_STYLE_LIST, "Squad information - Squad commands (Page 2/3)", "Controlling and creating your squad\n ---------- \n /screate ( Creates a squad )\n /sinvite ( Invite someone to your squad )\n /sjoin ( Join a squad )\n /sleave ( Leave a squad )\n /sdisband ( Disband your squad )\n /skick ( Kick someone from your squad )\n /spromote ( Set a new leader in your squad )\n /sreward ( Set a squad kill reward )", "<<", ">>");
- }
- }
- case DIALOG_SQUAD_HELP_PAGE2:
- {
- if(response)
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE1, DIALOG_STYLE_LIST, "Squad information - Squad status (Page 1/3)", "Checking for squad information\n ---------- \n /squads ( Shows all squads, it's name and ID )\n /sinfo ( Shows more information about a specific squad, the members, leader.. )", "Close", ">>");
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE3, DIALOG_STYLE_LIST, "Squad information - Squad commands, Talking with your squad ( Page 3/3 )", "Communicating with your squad members\n ---------- \n Squad chat ( Type '!' infront of your text )\n /sannounce ( Announce a message )", "<<", "Close");
- }
- }
- case DIALOG_SQUAD_HELP_PAGE3:
- {
- if(response)
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE2, DIALOG_STYLE_LIST, "Squad information - Squad commands (Page 2/3)", "Controlling and creating your squad\n ---------- \n /screate ( Creates a squad )\n /sinvite ( Invite someone to your squad )\n /sjoin ( Join a squad )\n /sleave ( Leave a squad )\n /sdisband ( Disband your squad )\n /skick ( Kick someone from your squad )\n /spromote ( Set a new leader in your squad )\n /sreward ( Set a squad kill reward )", "<<", ">>");
- }
- }
- case DIALOG_SQUAD_EDIT:
- {
- if(response)
- {
- switch(listitem)
- {
- case 0:
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_NAME, DIALOG_STYLE_INPUT, "Editing your Squad", "Type the new Squad-Name you want your squad to have below", "Accept", "Back");
- }
- case 1:
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_DISBAND, DIALOG_STYLE_MSGBOX, "Editing your Squad", "Are you sure you want to delete this squad?", "Yes", "No");
- }
- case 2:
- {
- new sqid;
- sqid = squad[playerid][sid];
- if(!squadinfo[sqid][invitemode])
- {
- //squadinfo[sqid][invitemode] = 0;
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad doesn't needs invitation to join( PUBLIC )", "Change", "Back");
- }
- else
- {
- //squadinfo[sqid][invitemode] = 1;
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad needs invitation to join( PRIVATE )", "Change", "Back");
- }
- }
- case 3:
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_LIMIT, DIALOG_STYLE_INPUT, "Editing your Squad", "Enter the new Squad-Member limit below\nMust be between 3 and 5", "Accept", "Back");
- }
- }
- }
- else SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You can use /squadedit to edit the squad settings when-ever you want to.");
- }
- case DIALOG_SQUAD_EDIT_NAME:
- {
- if(response)
- {
- new
- sqid,
- //newname,
- string[132],
- pname[MAX_PLAYER_NAME]
- ;
- sqid = squad[playerid][sid];
- //newname = strval(inputtext);
- GetPlayerName(playerid, pname, sizeof(pname));
- if(squadinfo[sqid][active] && squad[playerid][order])
- {
- if(strlen(inputtext) > 49 || strlen(inputtext) < 3)
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad name must be between 3 to 50 characters.");
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_NAME, DIALOG_STYLE_INPUT, "Editing your Squad", "Type the new Squad-Name you want your squad to have below", "Accept", "Back");
- }
- else if(IsSquadTaken(inputtext))
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: That Squad's name is already in use!");
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_NAME, DIALOG_STYLE_INPUT, "Editing your Squad", "Type the new Squad-Name you want your squad to have below", "Accept", "Back");
- }
- else
- {
- format(squadinfo[sqid][sqname], 70, "%s", inputtext);
- //format(string, 70, "%s", inputtext);
- //squadinfo[sqid][sqname] = string[70];
- format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] has renamed the Squad to %s!", pname, playerid, inputtext);
- SendMessageToAllsquadMembers(sqid, string);
- foreach(Player, x)
- {
- if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
- {
- SendClientMessage(x, -1, string);
- }
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: You've successfully re-named your squad to %s", inputtext);
- SendClientMessage(playerid, -1, string);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has renamed his squad to %s\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, inputtext);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- }
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
- }
- }
- case DIALOG_SQUAD_DISBAND:
- {
- if(response)
- {
- //return cmd_squaddisband(playerid, inputtext);
- new
- string[132],
- pname[MAX_PLAYER_NAME],
- squadid
- ;
- GetPlayerName(playerid, pname, sizeof(pname));
- squadid = squad[playerid][sid];
- format(string, sizeof(string), "{FFCC66}SQUAD: Squad leader %s[%d] has disbanded the squad %s.", pname, playerid, squadinfo[squadid][sqname]);
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid])
- {
- LeaveSquad(x, 4);
- }
- if(GetPlayerTeam(x) == GetPlayerTeam(playerid))
- {
- if(x != playerid)
- {
- SendClientMessage(x, -1, string);
- }
- }
- }
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You've successfully disbanded the squad.");
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has disbanded his squad\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
- }
- }
- case DIALOG_SQUAD_EDIT_INVITE:
- {
- if(response)
- {
- new
- sqid,
- string[132],
- pname[MAX_PLAYER_NAME]
- ;
- GetPlayerName(playerid, pname, sizeof(pname));
- sqid = squad[playerid][sid];
- if(squadinfo[sqid][invitemode])
- {
- squadinfo[sqid][invitemode] = 0;
- //ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad doesn't needs invitation to join( PUBLIC )", "Back", "");
- format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] made the squad %s a PUBLIC squad!", pname, playerid, squadinfo[sqid][sqname]);
- SendMessageToAllsquadMembers(sqid, string);
- foreach(Player, x)
- {
- if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
- {
- SendClientMessage(x, -1, string);
- }
- }
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You've successfully made the squad PUBLIC");
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has set his squad to be public\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- else
- {
- squadinfo[sqid][invitemode] = 1;
- //ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_INVITE, DIALOG_STYLE_MSGBOX, "Editing your Squad", "This squad needs invitation to join( PRIVATE )", "Back", "");
- format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] made the squad %s a PRIVATE squad!", pname, playerid, squadinfo[sqid][sqname]);
- SendMessageToAllsquadMembers(sqid, string);
- foreach(Player, x)
- {
- if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
- {
- SendClientMessage(x, -1, string);
- }
- }
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You've successfully made the squad PRIVATE");
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has set his squad to be private\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
- }
- }
- case DIALOG_SQUAD_EDIT_LIMIT:
- {
- if(response)
- {
- new
- sqid,
- newlimit,
- string[113],
- pname[MAX_PLAYER_NAME]
- ;
- GetPlayerName(playerid, pname, sizeof(pname));
- sqid = squad[playerid][sid];
- newlimit = strval(inputtext);
- if(newlimit > 5 || newlimit < 3)
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Choose a valid Squad Member limit( 3 - 5 )");
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_LIMIT, DIALOG_STYLE_INPUT, "Editing your Squad", "Enter the new Squad-Member limit below\nMust be between 3 and 5", "Accept", "Back");
- }
- else if(squadinfo[sqid][sqmaxmembers] == newlimit)
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The Squad-Member limit is already the one you selected.");
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT_LIMIT, DIALOG_STYLE_INPUT, "Editing your Squad", "Enter the new Squad-Member limit below\nMust be between 3 and 5", "Accept", "Back");
- }
- else
- {
- squadinfo[sqid][sqmaxmembers] = newlimit;
- format(string, sizeof(string), "{FFCC66}SQUAD: Leader %s[%d] has set the Squad-Member limit to %d.", pname, playerid, newlimit);
- SendMessageToAllsquadMembers(sqid, string);
- foreach(Player, x)
- {
- if(GetPlayerTeam(x) == GetPlayerTeam(playerid) && squad[x][sid] != squad[playerid][sid])
- {
- SendClientMessage(x, -1, string);
- }
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: You've successfully set the member limit to %d", newlimit);
- SendClientMessage(playerid, -1, string);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has set the member-limit to %d\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, newlimit);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- }
- else
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
- }
- }
- }
- /*#define DIALOG_SQUAD_EDIT 5
- #define DIALOG_SQUAD_EDIT_NAME 6
- #define DIALOG_SQUAD_DISBAND 7
- #define DIALOG_SQUAD_EDIT_INVITE 8
- #define DIALOG_SQUAD_EDIT_LIMIT 9*/
- return 1;
- }
- CMD:squadhelp(playerid, params[])
- {
- //"Squad info and commands", "Checking squad information\n \n /squads ( Shows all squads )\n /sinfo ( Shows squad information )\nCreating, controlling squads \n \n \nTalking with your squad ( Type '!' infront of your text )", "Close", "");
- ShowPlayerDialog(playerid, DIALOG_SQUAD_HELP_PAGE1, DIALOG_STYLE_LIST, "Squad information, commands etc. (Page 1/3)", "Checking for squad information\n ---------- \n /squads ( Shows all squads, it's name and ID )\n /sinfo ( Shows more information about a specific squad, the members, leader.. )", "Close", ">>");
- return 1;
- }
- CMD:squadedit(playerid, params[])
- {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a Squad!");
- if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you can't edit it!");
- ShowPlayerDialog(playerid, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
- return 1;
- }
- CMD:squadannounce(playerid, params[])
- {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a Squad!");
- if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you can't announce messages!");
- if(strlen(params) > 36 || strlen(params) < 3) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadannounce (Announcement, 3 - 35 characters)!");
- new
- string[132],
- pname[MAX_PLAYER_NAME]
- ;
- format(string, sizeof(string), "%s", params);
- GetPlayerName(playerid, pname, sizeof(pname));
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid])
- {
- GameTextForPlayer(x, string, 4500, 3);
- format(string, sizeof(string), "{FFCC66}SQUAD: Announcement from Squad leader %s[%d]: %s", pname, playerid, params);
- SendClientMessage(x, -1, string);
- }
- }
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has announced %s\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, params);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return 1;
- }
- CMD:squadcreate(playerid, params[])
- {
- if(squad[playerid][sid] != -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Leave your squad with /squadleave before creating a new one!");
- if(strlen(params) > 49 || strlen(params) < 3) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadcreate (Squad name, 3-50 characters)!");
- if(IsSquadTaken(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: That Squad's name is already in use!");
- CreateSquad(params, playerid);
- return 1;
- }
- CMD:squadleave(playerid, params[])
- {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a squad to leave one!");
- LeaveSquad(playerid, 0);
- return 1;
- }
- CMD:squaddisband(playerid, params[]) {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You need to be in a Squad to disband it!");
- if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you can't disband it!");
- new
- string[132],
- pname[MAX_PLAYER_NAME],
- squadid
- ;
- GetPlayerName(playerid, pname, sizeof(pname));
- squadid = squad[playerid][sid];
- format(string, sizeof(string), "{FFCC66}SQUAD: Squad leader %s[%d] has disbanded the squad %s.", pname, playerid, squadinfo[squadid][sqname]);
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid])
- {
- LeaveSquad(x, 4);
- }
- if(GetPlayerTeam(x) == GetPlayerTeam(playerid))
- {
- if(x != playerid)
- {
- SendClientMessage(x, -1, string);
- }
- }
- }
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You've successfully disbanded the squad.");
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has disbanded his squad\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return 1;
- }
- CMD:squadspawn(playerid, params[])
- {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You're not in a Squad!");
- //if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: These settings are not available for Squad leaders.");
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadspawn [leader/member/default]");
- if(strcmp(params, "leader", true, 6) == 0)
- {
- if(squad[playerid][order] != 1)
- {
- squad[playerid][leaderspawn] = 1;
- squad[playerid][memberspawn] = 0;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will now spawn on the squad leader.");
- }
- else SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are the leader, you can't spawn on yourself..");
- }
- else if(strcmp(params, "member", true, 6) == 0)
- {
- squad[playerid][leaderspawn] = 0;
- squad[playerid][memberspawn] = 1;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will now spawn on your squad members( RANDOM ).");
- }
- else if(strcmp(params, "default", true, 6) == 0)
- {
- squad[playerid][leaderspawn] = 0;
- squad[playerid][memberspawn] = 0;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will now spawn at the default spawn points.");
- }
- else
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Invalid spawn type, use either LEADER, MEMBER or DEFAULT");
- }
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new pname[24], string[132];
- GetPlayerName(playerid, pname, 24);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has set his squad-spawn type to %s\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, params);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return 1;
- }
- CMD:squadreward(playerid, params[])
- {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You need to be in a squad to use {FFFFFF}/squadreward{FF0000}");
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadreward [armour/health/score/ammo]");
- if(strcmp(params, "armour", true, 6) == 0)
- {
- squad[playerid][rewardtype] = 1;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive ARMOUR on your squad-member kills!");
- }
- else if(strcmp(params, "health", true, 6) == 0)
- {
- squad[playerid][rewardtype] = 2;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive HEALTH on your squad-member kills!");
- }
- /*else if(strcmp(reward, "money", true, 5) == 0)
- {
- squad[playerid][rewardtype] = 3;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive MONEY on your squad-member kills!");
- }*/
- else if(strcmp(params, "score", true, 5) == 0)
- {
- if(GetPlayerScore(playerid) > 200) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You need less than 200 score to use the SCORE reward..");
- squad[playerid][rewardtype] = 3;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive SCORE on your squad-member kills!");
- }
- else if(strcmp(params, "ammo", true, 4) == 0)
- {
- squad[playerid][rewardtype] = 4;
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You will receive AMMO on your squad-member kills!");
- }
- else
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Invalid reward type, use either ARMOUR, HEALTH, MONEY, SCORE or AMMO");
- }
- new pname[24], string[132];
- GetPlayerName(playerid, pname, 24);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has changed his squad-reward to %s\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, params);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return 1;
- }
- /*CMD:squadinvite(playerid, params[])
- {
- if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you cannot invite people!");
- new cid;
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadinvite{FF0000} (playerid)");
- cid = strval(params);
- if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player not found!");
- if(GetPlayerTeam(cid) != squadinfo[sid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Target is not in your team!");
- if(squad[cid][sid] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is already in your squad!");
- if(squad[cid][invited] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player has already been invited to your squad!");
- if(squadinfo[sid][sqmembers] == MAX_SQUAD_MEMBERS) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
- if(squad[cid][attemptjoin] == squad[playerid][sid]) return squadJoin(cid, squad[playerid][sid]);
- squad[cid][invited] = squad[playerid][sid];
- new string[125], pname[24];
- GetPlayerName(playerid, pname, 24);
- format(string, sizeof(string), "* You have been invited to join squad {FFFFFF}%s[%d]{FFCC66} by {FFFFFF}%s[%d]. /squadjoin %d", squadinfo[squad[playerid][sid]][sqname], squad[playerid][sid], pname, playerid, squad[playerid][sid]);
- SendClientMessage(cid, 0xFFCC66, string);
- GetPlayerName(cid, pname, 24);
- format(string, sizeof(string), "* You have invited {FFFFFF}%s[%d]{FFCC66} to join your squad!", pname, cid);
- SendClientMessage(playerid, 0xFFCC66, string);
- return 1;
- }*/
- CMD:squadinvite(playerid, params[])
- {
- new
- cid,
- sqid,
- string[125],
- pname[24],
- tname[24]
- ;
- GetPlayerName(playerid, pname, 24);
- GetPlayerName(cid, tname, 24);
- sqid = squad[playerid][sid];
- if(squad[playerid][order] != 1)
- {
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: /squadinvite{FF0000} (playerid)");
- cid = strval(params);
- if(!IsPlayerConnected(cid) || cid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player not found!");
- if(GetPlayerTeam(cid) != squadinfo[sid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Target is not in your team!");
- if(squad[cid][sid] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is already in your squad!");
- if(squad[cid][invited] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player has already been invited to your squad!");
- if(squadinfo[sqid][sqmembers] == squadinfo[sqid][sqmaxmembers]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
- format(string, sizeof(string), "* Your invitation request of %s[%d] has been sent to the Squad Leader", tname, cid);
- SendClientMessage(playerid, 0x00FF7FAA, string);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s suggests %s to be invited\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, tname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid])
- {
- if(squad[x][order])
- {
- format(string, sizeof(string), "* Your squad-member %s wants you to invite %s[%d]", pname, tname, cid);
- SendClientMessage(x, 0x00FF7FAA, string);
- }
- }
- }
- }
- else
- {
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadinvite{FF0000} (playerid)");
- cid = strval(params);
- if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player not found!");
- if(GetPlayerTeam(cid) != squadinfo[sid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Target is not in your team!");
- if(squad[cid][sid] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is already in your squad!");
- if(squad[cid][invited] == squad[playerid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player has already been invited to your squad!");
- if(squadinfo[sqid][sqmembers] == squadinfo[sqid][sqmaxmembers]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
- if(squad[cid][attemptjoin] == squad[playerid][sid]) return squadJoin(cid, squad[playerid][sid]);
- squad[cid][invited] = squad[playerid][sid];
- format(string, sizeof(string), "* You have been invited to join squad {FFFFFF}%s[%d]{FFCC66} by {FFFFFF}%s[%d]. /squadjoin %d", squadinfo[squad[playerid][sid]][sqname], squad[playerid][sid], pname, playerid, squad[playerid][sid]);
- SendClientMessage(cid, 0xFFCC66, string);
- GetPlayerName(cid, pname, 24);
- format(string, sizeof(string), "{FFCC66}SQUAD: You have invited %s[%d] to join your squad!", pname, cid);
- SendClientMessage(playerid, -1, string);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has invited %s to his squad\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, tname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- return 1;
- }
- CMD:squadleader(playerid, params[])
- {
- if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of the squad, you cannot change the leader!");
- new cid, pname[24], tname[24], string[132];
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadleader{FF0000} (playerid)");
- cid = strval(params);
- if(!IsPlayerConnected(cid) || cid == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player Is not connected!");
- if(cid == playerid) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are already squad leader.");
- if(squad[playerid][sid] != squad[cid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is not in your squad!");
- ChangeMemberOrder(squad[playerid][sid], 1);
- squad[playerid][order] = squadMembers(squad[playerid][sid]);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- GetPlayerName(playerid, pname, 24);
- GetPlayerName(cid, tname, 24);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has made %s a squad-leader\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, tname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return 1;
- }
- CMD:squadjoin(playerid, params[])
- {
- if(squad[playerid][sid] != -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are already in a squad! Leave your current one before joining another one!");
- new sqid;
- sqid = strval(params);
- if((isnull(params) && squad[playerid][invited] != -1 && squadinfo[sqid][invitemode] == 0 ) || ( strval(params) == squad[playerid][invited] && squad[playerid][invited] != -1 && squadinfo[sqid][invitemode] == 0 ) ) return squadJoin(playerid, squad[playerid][invited]);
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadjoin{FF0000} (squadid)");
- if(!squadinfo[sqid][active]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad you tried to join doesn't exist!");
- if(GetPlayerTeam(playerid) != squadinfo[sqid][sqteam]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad you tried to join is not available for your team.");
- if(squadinfo[sqid][sqmembers] == squadinfo[sqid][sqmaxmembers]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad already has 5 members..");
- if(!squadinfo[sqid][invitemode])
- {
- squad[playerid][attemptjoin] = sqid;
- new string[125], pname[24];
- GetPlayerName(playerid, pname, 24);
- format(string, sizeof(string), "* You have requested to join squad %s(ID:%d)", squadinfo[sqid][sqname], sqid);
- SendClientMessage(playerid, 0xFFCC66, string);
- format(string, sizeof(string), "* {FFFFFF}%s[%d] {FFCC66}has attempted to join your squad. Type /squadinvite %d to accept", pname, playerid, playerid);
- SendMessageToLeader(sqid, string);
- }
- else return squadJoin(playerid, sqid/*squad[playerid][invited]*/);
- return 1;
- }
- CMD:squadkick(playerid, params[])
- {
- if(squad[playerid][order] != 1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not the leader of a squad, you cannot kick!");
- new cid;
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadkick{FF0000} (playerid)");
- cid = strval(params);
- if(!IsPlayerConnected(cid)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player Is not connected!");
- if(cid == playerid) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You can't kick yourself.");
- if(squad[playerid][sid] != squad[cid][sid]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Player is not in your squad!");
- LeaveSquad(cid, 1);
- return 1;
- }
- /*CMD:squadmessage(playerid, params[])
- {
- if(squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You are not in a squad, you cannot squad message!");
- if(isnull(params)) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/gm{FF0000} (message)");
- new pname[24], string[140+24];
- GetPlayerName(playerid, pname, 24);
- format(string, sizeof(string), "%s[%d]: %s", pname, playerid, params);
- SendMessageToAllsquadMembers(squad[playerid][sid], string);
- return 1;
- }*/
- CMD:squadinfo(playerid, params[])
- {
- if(isnull(params) && squad[playerid][sid] == -1) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: {FFFFFF}/squadinfo{FF0000} (squad)");
- if(isnull(params))
- {
- DisplaysquadMembers(squad[playerid][sid], playerid);
- return 1;
- }
- new sqid = strval(params);
- if(!squadinfo[sqid][active]) return SendClientMessage(playerid, -1, "{FFCC66}SQUAD: The squad ID you have entered is not active!");
- DisplaysquadMembers(sqid, playerid);
- return 1;
- }
- CMD:squads(playerid, params[])
- {
- //Listsquads(playerid);
- new
- amount[2],
- string[400],
- shortstr[90],
- team = GetPlayerTeam(playerid)
- ;
- for(new x=0; x<MAX_SQUADS; x++)
- {
- if(squadinfo[x][active])
- {
- amount[0] ++;
- amount[1] ++;
- format(shortstr, sizeof(shortstr), "%s (ID:%d, Members:%d/%d) \n", squadinfo[x][sqname], x, squadinfo[x][sqmembers], squadinfo[x][sqmaxmembers]);
- if(squadinfo[x][sqteam] == team)
- {
- if(amount[1] == 1)
- {
- format(string, sizeof(string), "{33AA33}%s\n", shortstr);
- strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
- }
- if(amount[1] != 1)
- {
- format(string, sizeof(string), "{33AA33}%s %s\n", string, shortstr);
- strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
- }
- }
- else
- {
- if(amount[1] == 1)
- {
- format(string, sizeof(string), "{AA3333}%s\n", shortstr);
- strcat(string, "\n\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
- }
- if(amount[1] != 1)
- {
- format(string, sizeof(string), "{AA3333}%s %s\n", string, shortstr);
- strcat(string, "\n\n{33AA33}Friendly squads are colored green\n{AA3333}Enemy squads are colored red", sizeof(string));
- }
- }
- if(amount[0] == 4)
- {
- ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads", string, "Close", "");
- string = "";
- amount[0] = 0;
- }
- }
- }
- if(amount[1] == 0) ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads", "No squads available\nUse /squadcreate to create one!", "Close", "");
- if(amount[1] != 0) ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads", string, "Close", "");
- //ShowPlayerDialog(playerid, DIALOG_SQUAD_LIST, DIALOG_STYLE_LIST, "Squads"
- return 1;
- }
- CMD:squit(playerid, params[])
- return cmd_squadleave(playerid, params);
- CMD:sleave(playerid, params[])
- return cmd_squadleave(playerid, params);
- CMD:scr(playerid, params[])
- return cmd_squadcreate(playerid, params);
- CMD:screate(playerid, params[])
- return cmd_squadcreate(playerid, params);
- CMD:sdisband(playerid, params[])
- return cmd_squaddisband(playerid, params);
- CMD:sdelete(playerid, params[])
- return cmd_squaddisband(playerid, params);
- CMD:squaddelete(playerid, params[])
- return cmd_squaddisband(playerid, params);
- CMD:shelp(playerid, params[])
- return cmd_squadhelp(playerid, params);
- CMD:sedit(playerid, params[])
- return cmd_squadedit(playerid, params);
- CMD:sann(playerid, params[])
- return cmd_squadannounce(playerid, params);
- CMD:sannounce(playerid, params[])
- return cmd_squadannounce(playerid, params);
- CMD:sinv(playerid, params[])
- return cmd_squadinvite(playerid, params);
- CMD:sinvite(playerid, params[])
- return cmd_squadinvite(playerid, params);
- CMD:spromote(playerid, params[])
- return cmd_squadleader(playerid, params);
- CMD:sleader(playerid, params[])
- return cmd_squadleader(playerid, params);
- CMD:sj(playerid, params[])
- return cmd_squadjoin(playerid, params);
- CMD:sjoin(playerid, params[])
- return cmd_squadjoin(playerid, params);
- CMD:sk(playerid, params[])
- return cmd_squadkick(playerid, params);
- CMD:skick(playerid, params[])
- return cmd_squadkick(playerid, params);
- /*CMD:smsg(playerid, params[])
- return cmd_squadmessage(playerid, params);*/
- CMD:slist(playerid, params[])
- return cmd_squadinfo(playerid, params);
- CMD:sinfo(playerid, params[])
- return cmd_squadinfo(playerid, params);
- CMD:sreward(playerid, params[])
- return cmd_squadreward(playerid, params);
- stock DisplaysquadMembers(squadid, playerid)
- {
- new amount[2], string[200], shortstr[55], pname[24];
- format(string, sizeof(string), "Squad members for %s(ID:%d)", squadinfo[squadid][sqname], squadid);
- SendClientMessage(playerid, -1, string);
- string = "";
- foreach(Player, x)
- {
- if(squad[x][sid] == squadid)
- {
- amount[0] ++;
- amount[1] ++;
- GetPlayerName(x, pname, 24);
- if(squadinfo[squadid][leader] != x) format(shortstr, sizeof(shortstr), "%s[%d],", pname, x);
- if(squadinfo[squadid][leader] == x) format(shortstr, sizeof(shortstr), "[LEADER]%s[%d],", pname, x);
- if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
- if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
- if(amount[0] == 6)
- {
- strdel(string, strlen(string)-1, strlen(string));
- SendClientMessage(playerid, 0xFFCC66, string);
- string = "";
- amount[0] = 0;
- }
- }
- }
- strdel(string, strlen(string)-1, strlen(string));
- if(amount[0] != 0) SendClientMessage(playerid, 0xFFCC66, string);
- return 1;
- }
- stock Listsquads(playerid)
- {
- new amount[2], string[200], shortstr[55];
- SendClientMessage(playerid, 0xFFFFFF, "Current squads:");
- for(new x=0; x<MAX_SQUADS; x++)
- {
- if(squadinfo[x][active])
- {
- amount[0] ++;
- amount[1] ++;
- format(shortstr, sizeof(shortstr), "%s(ID:%d)", squadinfo[x][sqname], x);
- if(amount[1] == 1) format(string, sizeof(string), "%s", shortstr);
- if(amount[1] != 1) format(string, sizeof(string), "%s %s", string, shortstr);
- if(amount[0] == 4)
- {
- SendClientMessage(playerid, 0xFFCC66, string);
- string = "";
- amount[0] = 0;
- }
- }
- }
- if(amount[1] == 0) SendClientMessage(playerid, 0xFFFF00, "There are currently no active squads!");
- if(amount[1] != 0) SendClientMessage(playerid, 0xFFCC66, string);
- return 1;
- }
- stock SendMessageToLeader(squadi, message[])
- return SendClientMessage(squadinfo[squadi][leader], 0xFFCC66, message);
- stock squadJoin(playerid, squadi)
- {
- squad[playerid][sid] = squadi;
- squad[playerid][order] = squadMembers(squadi);
- squad[playerid][attemptjoin] = -1;
- squad[playerid][invited] = -1;
- new pname[24], string[130];
- GetPlayerName(playerid, pname, 24);
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has joined your squad!", pname, playerid);
- SendMessageToAllsquadMembers(squadi, string);
- format(string, sizeof(string), "{FFCC66}SQUAD: You have joined squad %s(ID:%d)", squadinfo[squadi][sqname] ,squadi);
- SendClientMessage(playerid, -1, string);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has joined squad %s\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname, squadinfo[squadi][sqname]);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return 1;
- }
- stock FindNextSlot()
- {
- new id;
- while(squadinfo[id][active]) id ++;
- return id;
- }
- stock IsSquadTaken(sqdname[])
- {
- for(new x; x<MAX_SQUADS; x++)
- {
- if(squadinfo[x][active] == 1)
- {
- if(!strcmp(sqdname, squadinfo[x][sqname], true) && strlen(squadinfo[x][sqname]) != 0) return 1;
- }
- }
- return 0;
- }
- stock squadInvite(playerid, squadid)
- return squad[playerid][invited] = squadid;
- stock CreateSquad(sqdname[], owner)
- {
- new slotid = FindNextSlot();
- squadinfo[slotid][leader] = owner;
- format(squadinfo[slotid][sqname], 75, "%s", sqdname);
- squadinfo[slotid][active] = 1;
- squadinfo[slotid][sqteam] = GetPlayerTeam(owner);
- squadinfo[slotid][invitemode] = 0;
- squadinfo[slotid][sqmembers] = 1;
- squadinfo[slotid][sqmaxmembers] = 5;
- squad[owner][sid] = slotid;
- squad[owner][order] = 1;
- new string[120], team[MAX_PLAYERS], name[MAX_PLAYER_NAME];
- GetPlayerName(owner, name, sizeof(name));
- format(string, sizeof(string), "{FFCC66}SQUAD: You have created the squad %s(ID:%d)", sqdname, slotid);
- SendClientMessage(owner, -1, string);
- ShowPlayerDialog(owner, DIALOG_SQUAD_EDIT, DIALOG_STYLE_LIST, "Editing your Squad", "Edit Squad Name(Change the name)\nDelete Squad\nEdit Join Mode(Invite needed, or not needed)\nEdit max. squad member ammount( 3 - 5 )", "Select", "Close");
- foreach(Player, i)
- {
- team[i] = GetPlayerTeam(i);
- if(team[i] == team[owner])
- {
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has created a squad named %s", name, owner, sqdname);
- SendClientMessage(i, -1, string);
- }
- }
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s has created a squad named %s\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, name, sqdname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- return slotid;
- }
- stock LeaveSquad(playerid, reason)
- {
- new squadid = squad[playerid][sid], orderid = squad[playerid][order], string[100], pname[24];
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- squad[playerid][sid] = -1;
- squad[playerid][order] = -1;
- squadinfo[sid][sqmembers]--;
- squadCheck(squadid, orderid);
- GetPlayerName(playerid, pname, 24);
- if(reason == 0)
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You have left your squad");
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s left his squad ( Left )\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Left)!", pname, playerid);
- }
- if(reason == 1)
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You have been kicked from your squad!");
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s left his squad ( Kicked )\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Kicked)!", pname, playerid);
- }
- if(reason == 2)
- {
- SendClientMessage(playerid, -1, "{FFCC66}SQUAD: You have been auto-removed from the squad due to changing the team");
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s left his squad ( Changed team )\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Changed team)!", pname, playerid);
- }
- if(reason == 3)
- {
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s left his squad ( Disconnected )\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Disconnected)!", pname, playerid);
- }
- if(reason == 4)
- {
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - %s left his squad ( Squad disbanded )\r\n", slday, slmonth, slyear, slhour, slminute, slsecond, pname);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has left your squad (Squad disbanded)!", pname, playerid);
- }
- SendMessageToAllsquadMembers(squadid, string);
- return 1;
- }
- stock squadCheck(squadid, orderid)
- {
- new smems = squadMembers(squadid);
- if(!smems) squadinfo[squadid][active] = 0;
- if(smems != 0) ChangeMemberOrder(squadid, orderid);
- return 1;
- }
- stock squadMembers(squadid)
- {
- if(!squadinfo[squadid][active]) return 0;
- new squadmembers;
- foreach(Player, i) if(squad[i][sid] == squadid) squadmembers++;
- return squadmembers;
- }
- stock ChangeMemberOrder(squadid, orderid)
- {
- foreach(Player, x)
- {
- if(squad[x][sid] != squadid || squad[x][order] < orderid) continue;
- squad[x][order] --;
- if(squad[x][order] == 1)
- {
- squadinfo[squadid][leader] = x;
- new string[128], pname[24];
- GetPlayerName(x, pname, 24);
- format(string, sizeof(string), "{FFCC66}SQUAD: %s[%d] has been promoted to the new squad leader!", pname, x);
- SendMessageToAllsquadMembers(squadid, string);
- }
- }
- return 1;
- }
- stock SendMessageToAllsquadMembers(squadid, message[])
- {
- if(!squadinfo[squadid][active]) return 0;
- foreach(Player, x) if(squad[x][sid] == squadid) SendClientMessage(x, -1, message);
- return 1;
- }
- public SquadSpawn(playerid)
- {
- new
- string[113],
- pname[MAX_PLAYER_NAME],
- tname[MAX_PLAYER_NAME],
- Float: X,
- Float: Y,
- Float: Z,
- squadmembercount = 0
- ;
- GetPlayerName(playerid, pname, sizeof(pname));
- if(squad[playerid][sid] != -1)
- {
- if(squad[playerid][leaderspawn])
- {
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid] && x != playerid)
- {
- if(squad[x][order])
- {
- GetPlayerName(x, tname, sizeof(tname));
- format(string, sizeof(string), "{FFCC66}SQUAD: You've spawned on your Squad Leader, %s[%d]", tname, x);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "{FFCC66}SQUAD: Your squad member %s[%d] has spawned on you.", pname, playerid);
- SendClientMessage(x, -1, string);
- GetPlayerPos(x, X, Y, Z);
- SetPlayerPos(playerid, X, Y, Z);
- }
- }
- }
- }
- else if(squad[playerid][memberspawn])
- {
- foreach(Player, x)
- {
- if(squad[x][sid] == squad[playerid][sid] && x != playerid)
- {
- squadmembercount++;
- if(squadmembercount >= 1)
- {
- new RandomS = random(x);
- GetPlayerPos(RandomS, X, Y, Z);
- GetPlayerName(RandomS, tname, sizeof(tname));
- format(string, sizeof(string), "{FFCC66}SQUAD: You've spawned on your Squad Member, %s[%d]", tname, x);
- SendClientMessage(playerid, -1, string);
- format(string, sizeof(string), "{FFCC66}SQUAD: Your squad member %s[%d] has spawned on you.", pname, playerid);
- SendClientMessage(RandomS, -1, string);
- SetPlayerPos(playerid, X, Y, Z);
- }
- else SendClientMessage(playerid, -1, "{FFCC66}SQUAD: Not enough squad members to do this.");
- }
- }
- }
- }
- return 1;
- }
- public CheckForFile()
- {
- new string[132];
- if(fexist("/squadlogs/squadlogs.txt"))
- {
- print("NOTIFICATION: 'squadlogs.txt' has been successfully created at 'scriptfiles/squadlogs'");
- gettime(slhour, slminute, slsecond);
- getdate(slyear, slmonth, slday);
- new File:SquadInfo = fopen("/squadlogs/squadlogs.txt", io_append);
- if(SquadInfo)
- {
- format(string, sizeof(string), "- %i/%i/%i (%i:%i:%i) - filterscript successfully loaded\r\n", slday, slmonth, slyear, slhour, slminute, slsecond);
- fwrite(SquadInfo, string);
- fclose(SquadInfo);
- }
- }
- else
- {
- print("WARNING: could NOT create 'squadlogs.txt' at 'scriptfiles/squadlogs'.. unloading");
- SendRconCommand("unloadfs Squads");
- }
- return 1;
- }
- public fcreate(filename[])
- {
- if (fexist(filename)){return false;}
- new File:fhandle = fopen(filename,io_write);
- fclose(fhandle);
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment