Raised This Month: $ Target: $400
 0% 

[Feature Request] Free For all Day update


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-22-2013 , 08:19   [Feature Request] Free For all Day update
Reply With Quote #1

Hello modders,

I hope someone could add some features to this plugin.
Here a short explanation of the plugin:
When an admin (flag z) types !ffd the ffd will be activated. When ffd is on the players get 30 seconds to team up and find a location. During these 30 seconds the damage is off. After these 30 seconds it is free for all. At the start of ffd everyone will get a deagle and they can choose a primary weapon from a weapon menu.
Current code:
Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>

#pragma semicolon 1

#define REFRESH_RATE 0.5

new bool:FFDON = false;
new String:weaponsinfo[][] = {

    "weapon_ak47", "AK47",
    "weapon_m4a1", "M4A1",
    "weapon_awp", "AWP",
    "weapon_scout", "SCOUT",    
    "weapon_aug", "AUG",    
    "weapon_sg550", "SG550",
    "weapon_famas", "FAMAS",    
    "weapon_m3", "M3",
    "weapon_xm1014", "XM1014",
    "weapon_galil", "GALIL",
    "weapon_sg552", "SG552",
    "weapon_g3sg1", "G3SG1",
    "weapon_mac10", "MAC10",
    "weapon_tmp", "TMP",
    "weapon_mp5navy", "MP5",
    "weapon_ump45", "UMP45",
    "weapon_p90", "P90",
    "weapon_m249", "M249"

};

new Handle:Menu;
new Handle:countdownTimer = INVALID_HANDLE;
new Float:startGameTime;
new Handle:friendlyfireConvar;
new oldValue;

public OnPluginStart(){

    RegAdminCmd("sm_ffd", OnFFD, ADMFLAG_ROOT);
    HookEvent("round_start", OnRoundStart);
    Menu = CreateMenu(WeaponsHandler);
    for(new i = 0; i < sizeof(weaponsinfo); i+= 2){

        AddMenuItem(Menu, weaponsinfo[i], weaponsinfo[i+1]);

    }
    SetMenuTitle(Menu, "Weapon Menu");
    SetMenuExitButton(Menu, true);
    for(new i = 1; i <= MaxClients; i++){

        if(IsClientInGame(i)){

            SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);

        }

    }
    friendlyfireConvar = FindConVar("mp_friendlyfire");
    HookUserMessage(GetUserMessageId("TextMsg"), Hook_TextMsg, true);
    HookUserMessage(GetUserMessageId("HintText"), Hook_HintText, true);

}

public Action:OnTakeDamage(victim, &attacker, &inflictor,  &Float:damage, &damagetype, &weapon, Float:damageForce[3],  Float:damagePosition[3]){

    if(!FFDON || attacker <= 0 || attacker > MaxClients || victim <= 0 || victim > MaxClients){

        return Plugin_Continue;

    }else if(countdownTimer != INVALID_HANDLE){

        damage = 0.0;
        return Plugin_Changed;

    }else if(GetClientTeam(victim) && GetClientTeam(attacker) && inflictor == attacker){

        damage /= 0.35;
        return Plugin_Changed;

    }
    return Plugin_Continue;

public Action:OnFFD(client, args){

    if ( client > 0 && FFDON){

        PrintToChat(client, "Sorry, it's already free for all day. You can't trigger it again.");
        return Plugin_Continue;

    }
    for(new i = 1; i <= MaxClients; i++){

        if(IsClientInGame(i) && IsPlayerAlive(i)){

            GivePlayerItem(i, "weapon_deagle");
            DisplayMenu(Menu, i, MENU_TIME_FOREVER);

        }

    }
    FFDON = true;
    oldValue = GetConVarInt(friendlyfireConvar);
    SetConVarInt(friendlyfireConvar, 1);
    countdownTimer = CreateTimer(REFRESH_RATE, refreshCountdown, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE );
    startGameTime = GetEngineTime() + 30.0;
    PrintCenterTextAll("You got 30 seconds to team up and find a location");
    return Plugin_Continue;

}  
public Action:refreshCountdown(Handle:timer, any:data){

    new remainingTime = RoundFloat(startGameTime - GetEngineTime());
    if(remainingTime > 0){

        PrintCenterTextAll("You got %d seconds to team up and find a location", remainingTime);
        return Plugin_Continue;

    }else{

        PrintCenterTextAll("Kill your enemies!");
        countdownTimer = INVALID_HANDLE;
        return Plugin_Stop;

    }

}

public Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason){

    if(FFDON){

        new ctcount = 0;
        new trcount = 0;
        for(new i = 1; i <= MaxClients; i++){

            if(IsClientInGame(i) && IsPlayerAlive(i)){

                switch(GetClientTeam(i)){

                    case 2:{

                        trcount++;

                    }case 3:{

                        ctcount++;

                    }

                }

            }

        }
        if(trcount == 0){

            if(countdownTimer != INVALID_HANDLE){

                KillTimer(countdownTimer);
                countdownTimer = INVALID_HANDLE;

            }
            FFDON = false;
            SetConVarInt(friendlyfireConvar, oldValue);
            reason = CSRoundEnd_CTWin;
            return Plugin_Changed;

        }else if(ctcount == 0){

            if(countdownTimer != INVALID_HANDLE){

                KillTimer(countdownTimer);
                countdownTimer = INVALID_HANDLE;

            }
            FFDON = false;
            SetConVarInt(friendlyfireConvar, oldValue);
            reason = CSRoundEnd_TerroristWin;
            return Plugin_Changed;

        }
        return Plugin_Handled;

    }
    return Plugin_Continue;

}

public WeaponsHandler(Handle:menu, MenuAction:action, param1, param2){

    if(action == MenuAction_Select && FFDON){

        decl String:weapon[32];
        GetMenuItem(menu, param2, weapon, 32);
        if(IsPlayerAlive(param1)){

            GivePlayerItem(param1, weapon);

        }

    }

}

public Action:OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast){

    FFDON = false;
    if(countdownTimer != INVALID_HANDLE){

        KillTimer(countdownTimer);
        countdownTimer = INVALID_HANDLE;

    }
    SetConVarInt(friendlyfireConvar, oldValue);

}

public Action:Hook_TextMsg(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
    /* Block team-attack messages from being shown to players. */ 
    decl String:message[256];
    BfReadString(bf, message, sizeof(message));

    if (StrContains(message, "teammate_attack") != -1)
        return Plugin_Handled;

    if (StrContains(message, "Killed_Teammate") != -1)
        return Plugin_Handled;
        
    return Plugin_Continue;
}

public Action:Hook_HintText(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
    /* Block team-attack "tutorial" messages from being shown to players. */ 
    decl String:message[256];
    BfReadString(bf, message, sizeof(message));
    
    if (StrContains(message, "spotted_a_friend") != -1)
        return Plugin_Handled;

    if (StrContains(message, "careful_around_teammates") != -1)
        return Plugin_Handled;
    
    if (StrContains(message, "try_not_to_injure_teammates") != -1)
        return Plugin_Handled;
        
    return Plugin_Continue;
}

public OnClientPutInServer(client){

    SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);

}
What I want to add:
- If possible get +1 score for teamkill instead of -1 score for teamkills during ffd.

- If possible a team system. People can type !ffdteam to select a player from a menu and request that player to team up. That player can accept a request by typing !ffdaccept. Teammates from teams made with !ffdteam can't do damage to eachother during ffd. Max 2 players per team. You can leave a team anytime you want with !ffdleaveteam. The teams should be saved for the whole map. If someone leaves a team that player can only do !ffdteam request during the 30 seconds countdown when ffd is activated. If a player is already in a team and that player does !ffdteam that player should get a message "You are already in a team with <teammate's name>. You can leave this team by typing !ffdleaveteam"

- Server cvar for automatically doing ffd once every map after a variable ammount of rounds (0 to disable, any number of rounds to enable).

- Server cvar for automatically doing ffd once every map at a random round (0 to disable, 1 to enable).

- When ffd is done automatically print an announcement in center of screen during the round before ffd. This announcement should be "Next round will be a Free For all Day. For more info about ffd type !ffdhelp". If it's done automatically in a round it should be activated after 30 seconds of that round. This because CT's have to open the cells first.

- A helpmenu that explains ffd that players can bring up using !ffdhelp. This helpmenu should have subcategories like "1. Free For all Day after countdown" and when you press 1 it will show that categorie and the text in there. Something like this:
"Free For all Day:
1. Information about the 30 seconds between activation and countdown reaching 0
2. Information about the teams system
3. Information about the ffd after the countdown reaches 0
0. Close helpbox"

When pressing 1:
"When the ffd is activated by an admin or automatically you got 30 seconds to team up and find a location. During these 30 seconds you can make teams with the teamsystem. During these 30 seconds the damage is off so you can't kill anyone untill the countdown reaches 0.
9. Back
0. Close"

When pressing 2:
"During the 30 seconds countdown you can request someone to team up with that player. Type !ffdteam to bring up a menu where you can select a player to sent a request. That player has to type !ffdaccept to accept the request. These teams exist of max 2 players. When you team up with someone you can't deal that player any damage. You can leave a team whenever you want by typing !ffdleaveteam. Teams will be saved for the rest of the map untill one of the teammates does !ffdleaveteam. You can only join a team during the 30 seconds countdown. Leaving a team can be done at any moment you want.
9. Back
0. Close"

When pressing 3:
"When the countdown reaches 0 the ffd will start. It's then free for all. You can now kill everybody including your teammates. The teammates that made a team using !ffdteam can't deal damage to eachother untill one of them leaves the team by typing !ffdleaveteam. Your goal during the ffd is ofcourse killing everybody and be the only survivor or survive with your team. After the countdown reached 0 you can't make teams anymore. You can leave a team anytime you want.
9. Back
0. Close"

I thinks this is all for now.
I know it is a lot, but I hope someone or more then 1 person could help me with this.
For more information you can add me in steam (liquidkillsx)

ps. this plugin was made on request by GsiX and Bimbo1.

Greetings,
Tom
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
LambdaLambda
AlliedModders Donor
Join Date: Oct 2010
Location: London
Old 11-22-2013 , 21:37   Re: [Feature Request] Free For all Day update
Reply With Quote #2

It really is alot. Would be better if you would code it yourself, and ask for help in Scripting section. We may help you with it, but noone will do all of this for you for free. However, catch the TK's one (sdkhooks not required):

PHP Code:
new round_no;

public 
OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("round_start"Event_RoundStartEventHookMode_Post);
}

public 
OnMapStart()
{
    
round_no 0// reset round no. on every map start
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
round_no += 1// +1 no. on new round start

    
if (round_no == 10) { FFDON true; } else { if (FFDON) { FFDON false; } } // if it's 10th round, set ffd to true; if it's not, set it to false while it's true
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid")), attacker GetClientOfUserId(GetEventInt(event"attacker"));

    if (
FFDON// if ffd is true
    
{
        if ((
attacker != 0) && (victim != attacker)) // if attacker is not a server and it was not a suicide
        
{
            if (
GetClientTeam(victim) == GetClientTeam(attacker)) // if victim's team is the same as attacker's
            
{
                    
SetEntProp(attackerProp_Data"m_iFrags"GetClientFrags(attacker) + 2); // set attacker +2 frags (TK is still enabled, so simple maths is showing up in here. (-1 + 2 = 1))
            
}
        }
    }


Last edited by LambdaLambda; 11-23-2013 at 09:11.
LambdaLambda is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-24-2013 , 15:41   Re: [Feature Request] Free For all Day update
Reply With Quote #3

Quote:
Originally Posted by LambdaLambda View Post
It really is alot. Would be better if you would code it yourself, and ask for help in Scripting section. We may help you with it, but noone will do all of this for you for free. However, catch the TK's one (sdkhooks not required):

PHP Code:
new round_no;

public 
OnPluginStart()
{
    
HookEvent("player_death"Event_PlayerDeath);
    
HookEvent("round_start"Event_RoundStartEventHookMode_Post);
}

public 
OnMapStart()
{
    
round_no 0// reset round no. on every map start
}

public 
Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
{
    
round_no += 1// +1 no. on new round start

    
if (round_no == 10) { FFDON true; } else { if (FFDON) { FFDON false; } } // if it's 10th round, set ffd to true; if it's not, set it to false while it's true
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim GetClientOfUserId(GetEventInt(event"userid")), attacker GetClientOfUserId(GetEventInt(event"attacker"));

    if (
FFDON// if ffd is true
    
{
        if ((
attacker != 0) && (victim != attacker)) // if attacker is not a server and it was not a suicide
        
{
            if (
GetClientTeam(victim) == GetClientTeam(attacker)) // if victim's team is the same as attacker's
            
{
                    
SetEntProp(attackerProp_Data"m_iFrags"GetClientFrags(attacker) + 2); // set attacker +2 frags (TK is still enabled, so simple maths is showing up in here. (-1 + 2 = 1))
            
}
        }
    }

I'm not able to code it myself and as I already said in first post I hoped that someone or more people could help me
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 11-23-2013 , 19:56   Re: [Feature Request] Free For all Day update
Reply With Quote #4

i would help you editing it if that code wasn't so bad coded. it disgusts and sickens me, urrrgh. the one who did it sucks a lot!
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-24-2013 , 03:01   Re: [Feature Request] Free For all Day update
Reply With Quote #5

Remind me what game is this again?
CSS, CS:GO?

EDIT: I agree with Bimbo1, this plugin badly need rewrite. Otherwise, it will make you unable to sleep at night when come to the part of debugging (readability).

Last edited by GsiX; 11-24-2013 at 03:07.
GsiX is offline
tommie113
AlliedModders Donor
Join Date: Oct 2013
Old 11-24-2013 , 15:42   Re: [Feature Request] Free For all Day update
Reply With Quote #6

Quote:
Originally Posted by GsiX View Post
Remind me what game is this again?
CSS, CS:GO?

EDIT: I agree with Bimbo1, this plugin badly need rewrite. Otherwise, it will make you unable to sleep at night when come to the part of debugging (readability).
CSS
__________________
No longer taking requests due to lack of time and interrest.
Only helping out with minor things through forum.
tommie113 is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 11-24-2013 , 11:07   Re: [Feature Request] Free For all Day update
Reply With Quote #7

ahuah, i was kidding in my post(i was kidding only about not helping you editing that, because the second part is true: i suck!). i tried doing it here, but i'm not sure if it works, i can't test it.
Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#include <sdkhooks>
#include <smlib>

#pragma semicolon 1

#define REFRESH_RATE 0.5

new bool:FFDON = false;
new String:weaponsinfo[][] = {

	"weapon_ak47", "AK47",
	"weapon_m4a1", "M4A1",
	"weapon_awp", "AWP",
	"weapon_scout", "SCOUT",
	"weapon_aug", "AUG",
	"weapon_sg550", "SG550",
	"weapon_famas", "FAMAS",
	"weapon_m3", "M3",
	"weapon_xm1014", "XM1014",
	"weapon_galil", "GALIL",
	"weapon_sg552", "SG552",
	"weapon_g3sg1", "G3SG1",
	"weapon_mac10", "MAC10",
	"weapon_tmp", "TMP",
	"weapon_mp5navy", "MP5",
	"weapon_ump45", "UMP45",
	"weapon_p90", "P90",
	"weapon_m249", "M249"

};
new Handle:Menu;
new Handle:countdownTimer = INVALID_HANDLE;
new Handle:startFFDRoundTimer = INVALID_HANDLE;
new Float:startGameTime;
new Handle:friendlyfireConvar;
new oldValue;
new Handle:autoFFDModeConvar;
new Handle:numberOfRoundsToFFDConvar;
new Handle:numberOfRoundsExpectedConvar;
new roundNumber;
new roundToFFD;
new playerTeam[MAXPLAYERS+1];

public OnMapStart(){

	roundNumber = 0;
	roundToFFD = 0;
	switch(GetConVarInt(autoFFDModeConvar)){

		case 1:{

			roundToFFD = GetConVarInt(numberOfRoundsToFFDConvar);

		}case 2:{

			roundToFFD = GetRandomInt(2, GetConVarInt(numberOfRoundsExpectedConvar));

		}

	}

}

public OnPluginStart(){

	RegAdminCmd("ffd", OnFFD, ADMFLAG_ROOT);
	HookEvent("round_start", OnRoundStart);
	Menu = CreateMenu(WeaponsHandler);
	for(new i = 0; i < sizeof(weaponsinfo); i+= 2){

		AddMenuItem(Menu, weaponsinfo[i], weaponsinfo[i+1]);

	}
	SetMenuTitle(Menu, "Weapon Menu");
	SetMenuExitButton(Menu, true);
	for(new i = 1; i <= MaxClients; i++){

		if(IsClientInGame(i)){

			SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);

		}

	}
	friendlyfireConvar = FindConVar("mp_friendlyfire");
	HookUserMessage(GetUserMessageId("TextMsg"), Hook_TextMsg, true);
	HookUserMessage(GetUserMessageId("HintText"), Hook_HintText, true);
	autoFFDModeConvar = CreateConVar("auto_ffd_mode", "0", "0 = disabled; 1 = ffd at a defined number of rounds; 2 = ffd at a random round");
	numberOfRoundsToFFDConvar = CreateConVar("number_of_rounds_to_ffd", "0", "number of rounds to ffd if auto_ffd_mode is set to 1");
	numberOfRoundsExpectedConvar = CreateConVar("number_of_rounds_expected", "0", "number of rounds expected at a map. if auto_ffd_mode is set to 2, a ffd round will happen in a round before this number, excluding the first round(ffd at the first round doesn't sound like a good idea).");
	RegConsoleCmd("ffdteam", OnFFDTeam);
	RegConsoleCmd("ffdaccept", OnFFDAccept);
	RegConsoleCmd("ffdleaveteam", OnFFDLeaveTeam);
	HookEvent("player_death", OnPlayerDeath);
	RegConsoleCmd("ffdhelp", OnFFDHelp);

}

public Action:OnFFDHelp(client, args){

	OpenFFDHelpMenu(client);

}

OpenFFDHelpMenu(client){

	new Handle:menu = CreateMenu(HelpMenuHandler);
	SetMenuTitle(menu, "Free For all Day");
	AddMenuItem(menu, "30to1", "Information about the 30 seconds between activation and countdown reaching 0");
	AddMenuItem(menu, "teams", "Information about the teams system");
	AddMenuItem(menu, "after0", "Information about the ffd after the countdown reaches 0");
	SetMenuExitButton(menu, true);
	SetMenuExitBackButton(menu, false);
	DisplayMenu(menu, client, MENU_TIME_FOREVER);

}

public HelpMenuHandler(Handle:menu, MenuAction:action, param1, param2){

	if(action == MenuAction_Select){

		decl String:buffer[128];
		GetMenuItem(menu, param2, buffer, 128);
		new Handle:submenu = CreateMenu(HelpSubmenuHandler);
		if(StrEqual(buffer, "30to1", false)){

			SetMenuTitle(submenu, "When the ffd is activated by an admin or\nautomatically you got 30 seconds to team up\nand find a location.\nDuring these 30 seconds you can\nmake teams with the teamsystem.\nDuring these 30 seconds the damage is off\nso you can't kill anyone untill the countdown\nreaches 0.");
			AddMenuItem(submenu, "", "", ITEMDRAW_DISABLED);

		}else if(StrEqual(buffer, "teams", false)){

			SetMenuTitle(submenu, "During the 30 seconds countdown you can\nrequest someone to team up with that\nplayer by typing !ffdteam \"player's name\"\nThat player has to type !ffdaccept\nto accept the request.\nThese teams exist of max 2 players.\nWhen you team up with someone you\ncan't deal that player any damage.\nTeams last for the rest of the map or untill one of\nthe teammates does !ffdleaveteam.\nYou can only join a team during the 30secondscountdown.\nLeaving a team can be done at any moment you want.");
			AddMenuItem(submenu, "", "", ITEMDRAW_DISABLED);

		}else{

			SetMenuTitle(submenu, "When the countdown reaches 0 the ffd will start.\nIt's then free for all. You can now kill everybody\nincluding your teammates. The teammates that made a\nteam using !ffdteam can't deal damage to eachother\nuntill one of them leaves the team by\ntyping !ffdleaveteam. Your goal during the ffd is\nofcourse killing everybody and be the only\nsurvivor or survive with your team. After\nthe countdown reached 0 you can't make teams anymore.\nYou can leave a team anytime you want.");
			AddMenuItem(submenu, "", "", ITEMDRAW_DISABLED);

		}
		SetMenuPagination(submenu, 1);
		SetMenuExitButton(submenu, true);
		SetMenuExitBackButton(submenu, true);
		DisplayMenu(submenu, param1, MENU_TIME_FOREVER);

	}else if(action == MenuAction_End){
		
		CloseHandle(menu);
		
	}

}

public HelpSubmenuHandler(Handle:menu, MenuAction:action, param1, param2){

	if(action == MenuAction_End){

		CloseHandle(menu);

	}else if(action == MenuAction_Cancel && param2 == MenuCancel_ExitBack){

		OpenFFDHelpMenu(param1);

	}

}

public Action:OnFFDAccept(client, args){

	new target = -1;
	for(new i = 1; i <= MaxClients; i++){

		if(playerTeam[i] == client){

			target = i;
			break;

		}

	}
	if(target > 0){

		playerTeam[client] = target;
		PrintToChat(client, "You're now teamed with %N.", target);
		PrintToChat(target, "Your friend %N accepted your request for teaming up.", client);

	}else{

		PrintToChat(client, "Sorry, I couldn't find any person who invited you to a team.");

	}

}

public Action:OnFFDLeaveTeam(client, args){

	purgePlayerTeam(client);
	PrintToChat(client, "You've left your team, if you had one.");

}

public Action:OnFFDTeam(client, arsgs){

	if(!FFDON || GetEngineTime() > startGameTime){

		PrintToChat(client, "Sorry, you can only do !ffdteam request during the 30 seconds countdown when ffd is activated.");
		return Plugin_Handled;

	}
	if(playerTeam[client] > 0 && playerTeam[playerTeam[client]] == client && IsClientInGame(playerTeam[client])){

		PrintToChat(client, "You have to leave your team with %N before trying to make another one(!ffdleaveteam).", playerTeam[client]);
		return Plugin_Handled;

	}
	if(GetCmdArgs() != 1){

		PrintToChat(client, "Usage of the command: !ffdteam \"name of your friend\"");
		return Plugin_Handled;

	}
	decl String:name[MAX_NAME_LENGTH];
	GetCmdArg(1, name, MAX_NAME_LENGTH);
	new target = FindTarget(client, name, true, false);
	if(target > 0){

		if(playerTeam[target] > 0 && playerTeam[playerTeam[target]] == target && IsClientInGame(playerTeam[target])){

			PrintToChat(client, "You can't invite %N to team up with you because he's already joined a team.", target);
			return Plugin_Handled;

		}else{

			PrintToChat(client, "You invited %N to team up with you.", target);
			PrintToChat(target, "You have been invited by %N to team up with him/her.", client);
			playerTeam[client] = target;

		}


	}
	return Plugin_Handled;

}

public OnClientDisconnect(client){

	purgePlayerTeam(client);

}

purgePlayerTeam(client){

	playerTeam[client] = -1;
	for(new i = 1; i <= MAXPLAYERS; i++){

		if(playerTeam[i] == client){

			playerTeam[i] = -1;

		}

	}

}

//thanks to lambdalambda
public Action:OnPlayerDeath(Handle:event, const String:name[], bool:dontBroadcast){

	if(FFDON){

		new victim = GetClientOfUserId(GetEventInt(event, "userid"));
		new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
		if(attacker > 0 && victim != attacker && GetClientTeam(victim) == GetClientTeam(attacker)){

			SetEntProp(attacker, Prop_Data, "m_iFrags", GetClientFrags(attacker) + 2);

		}

	}

}

public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3]){

	if(!FFDON || attacker <= 0 || attacker > MaxClients || victim <= 0 || victim > MaxClients){

		return Plugin_Continue;

	}else if(countdownTimer != INVALID_HANDLE){

		damage = 0.0;
		return Plugin_Changed;

	}else if(playerTeam[victim] == attacker && playerTeam[attacker] == victim){

		new count = 0;
		for(new i = 1; i <= MaxClients; i++){

			if(IsClientInGame(i) && IsPlayerAlive(i)){

				count++;

			}

		}
		if(count > 2){

			damage = 0.0;
			return Plugin_Changed;

		}

	}else if(GetClientTeam(victim) && GetClientTeam(attacker) && inflictor == attacker){

		damage /= 0.35;
		return Plugin_Changed;

	}
	return Plugin_Continue;

}

public Action:OnFFD(client, args){

	if(FFDON){

		PrintToChat(client, "Sorry, it's already free for all day. You can't trigger it again.");
		return Plugin_Continue;

	}
	return Plugin_Continue;

}

turnFFDOn(){

	if(FFDON){

		return;

	}
	for(new i = 1; i <= MaxClients; i++){

		if(IsClientInGame(i) && IsPlayerAlive(i)){

			GivePlayerItem(i, "weapon_deagle");
			DisplayMenu(Menu, i, MENU_TIME_FOREVER);

		}

	}
	FFDON = true;
	oldValue = GetConVarInt(friendlyfireConvar);
	SetConVarInt(friendlyfireConvar, 1);
	countdownTimer = CreateTimer(REFRESH_RATE, refreshCountdown, _, TIMER_REPEAT);
	startGameTime = GetEngineTime() + 30.0;
	PrintCenterTextAll("You got 30 seconds to team up and find a location");

}

public Action:refreshCountdown(Handle:timer, any:data){

	new remainingTime = RoundFloat(startGameTime - GetEngineTime());
	if(remainingTime > 0){

		PrintCenterTextAll("You got %d seconds to team up and find a location", remainingTime);
		return Plugin_Continue;

	}else{

		PrintCenterTextAll("Kill your enemies!");
		countdownTimer = INVALID_HANDLE;
		return Plugin_Stop;

	}

}

public Action:CS_OnTerminateRound(&Float:delay, &CSRoundEndReason:reason){

	if(FFDON){

		new ctcount = 0;
		new trcount = 0;
		for(new i = 1; i <= MaxClients; i++){

			if(IsClientInGame(i) && IsPlayerAlive(i)){

				switch(GetClientTeam(i)){

					case 2:{

						trcount++;

					}case 3:{

						ctcount++;

					}

				}

			}

		}
		if(trcount == 0){

			if(countdownTimer != INVALID_HANDLE){

				KillTimer(countdownTimer);
				countdownTimer = INVALID_HANDLE;

			}
			FFDON = false;
			SetConVarInt(friendlyfireConvar, oldValue);
			reason = CSRoundEnd_CTWin;
			return Plugin_Changed;

		}else if(ctcount == 0){

			if(countdownTimer != INVALID_HANDLE){

				KillTimer(countdownTimer);
				countdownTimer = INVALID_HANDLE;

			}
			FFDON = false;
			SetConVarInt(friendlyfireConvar, oldValue);
			reason = CSRoundEnd_TerroristWin;
			return Plugin_Changed;

		}
		return Plugin_Handled;

	}
	return Plugin_Continue;

}

public WeaponsHandler(Handle:menu, MenuAction:action, param1, param2){

	if(action == MenuAction_Select && FFDON){

		decl String:weapon[32];
		GetMenuItem(menu, param2, weapon, 32);
		if(IsPlayerAlive(param1)){

			GivePlayerItem(param1, weapon);

		}

	}

}

public Action:OnRoundStart(Handle:event, const String:name[], bool:dontBroadcast){

	if(startFFDRoundTimer != INVALID_HANDLE){

		KillTimer(startFFDRoundTimer);
		startFFDRoundTimer = INVALID_HANDLE;

	}
	roundNumber++;
	if(roundNumber == roundToFFD - 1){

		PrintCenterTextAll("Next round will be a Free For all Day. For more info about ffd type !ffdhelp");
		PrintToChatAll("Next round will be a Free For all Day. For more info about ffd type !ffdhelp");

	}else if(roundNumber == roundToFFD){

		PrintCenterTextAll("This round is going to be a Free For all Day, expect for it in 30s");
		PrintToChatAll("This round is going to be a Free For all Day, expect for it in 30s");
		startFFDRoundTimer = CreateTimer(30.0, startFFDRound);

	}
	FFDON = false;
	if(countdownTimer != INVALID_HANDLE){

		KillTimer(countdownTimer);
		countdownTimer = INVALID_HANDLE;

	}
	SetConVarInt(friendlyfireConvar, oldValue);

}

public Action:startFFDRound(Handle:timer, any:data){

	startFFDRoundTimer = INVALID_HANDLE;
	turnFFDOn();

}

public Action:Hook_TextMsg(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
	/* Block team-attack messages from being shown to players. */ 
	decl String:message[256];
	BfReadString(bf, message, sizeof(message));

	if (StrContains(message, "teammate_attack") != -1)
		return Plugin_Handled;

	if (StrContains(message, "Killed_Teammate") != -1)
		return Plugin_Handled;
		
	return Plugin_Continue;
}

public Action:Hook_HintText(UserMsg:msg_id, Handle:bf, const players[], playersNum, bool:reliable, bool:init)
{
	/* Block team-attack "tutorial" messages from being shown to players. */ 
	decl String:message[256];
	BfReadString(bf, message, sizeof(message));
	
	if (StrContains(message, "spotted_a_friend") != -1)
		return Plugin_Handled;

	if (StrContains(message, "careful_around_teammates") != -1)
		return Plugin_Handled;
	
	if (StrContains(message, "try_not_to_injure_teammates") != -1)
		return Plugin_Handled;
		
	return Plugin_Continue;
}

public OnClientPutInServer(client){

	SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
	purgePlayerTeam(client);

}
and, thanks, lambdalambda, i made use of that.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 11-24-2013 , 11:10   Re: [Feature Request] Free For all Day update
Reply With Quote #8

oh, and the cvars are:
"auto_ffd_mode" "0 = disabled; 1 = ffd at a defined number of rounds; 2 = ffd at a random round"
"number_of_rounds_to_ffd" "number of rounds to ffd if auto_ffd_mode is set to 1"
"number_of_rounds_expected" "number of rounds expected at a map. if auto_ffd_mode is set to 2, a ffd round will happen in a round before this number, excluding the first round(ffd at the first round doesn't sound like a good idea)." for example, if number_of_rounds_expected is 10 and auto_ffd_mode is 2, a ffd round will happen for sure at a random round between the second and the tenth.
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
GsiX
gee, six eggs
Join Date: Aug 2012
Location: Land Below The Wind
Old 11-24-2013 , 11:55   Re: [Feature Request] Free For all Day update
Reply With Quote #9

PHP Code:
PrintToChat(client"You've left your team, if you had one."); 
PHP Code:
PrintToChat(client"Sorry, I couldn't find any person who invited you to a team."); 
PHP Code:
PrintToChatAll("This round is going to be a Free For all Day, expect for it in 30s"); 
Nicely said..

Last edited by GsiX; 11-24-2013 at 12:00.
GsiX is offline
Bimbo1
Senior Member
Join Date: Jan 2010
Location: brazil
Old 11-24-2013 , 12:29   Re: [Feature Request] Free For all Day update
Reply With Quote #10

xp, ty
__________________
sie sind das essen und wir sind die jäger!
Bimbo1 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:00.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode