ABOUT:
This plugin is a "!challenge" plugin made to work ONLY inside of the Multi-1v1 Plugin made by Splewis. If you are not running this mod, this plugin WILL NOT WORK. This plugin allows players to type !challenge to challenge their buddies which places them into a private arena where they can then fight each other. Once the challenge duel is over, the players get put back into their old arena locations.
gcv_iCooldownAmmount = AutoExecConfig_CreateConVar("hl_challenge_cooldown", "2", "Cooldown Ammount? \n Set 0 to disable");
gcv_bBlockRatingChanges = AutoExecConfig_CreateConVar("hl_challenge_rating", "0", "Allow rating changes during challenges? \n 0 to block rating changes");
gcv_iRoundDelay = AutoExecConfig_CreateConVar("hl_challenge_delay", "1", "Ammount of rounds to keep someone in challenge queue?\n This is the delay after a challenge has been accepted.");
RegConsoleCmd("sm_challenge", Command_Challenge, "Allows users to challenge their friends!"); RegConsoleCmd("sm_chal", Command_Challenge, "Allows users to challenge their friends!");
public void OnClientDisconnect(int client) { if (ga_bIsInChallengeQueue[client]) { RemoveFromChallengeQueue(client); }
if (ga_bIsInChallenge[client]) { PrintToChatAll("[\x05Multi1v1\x01] \x03%N\x01 has lost their challange against \x03%N\x01!", client, GetClientOfUserId(ga_iChallengePartner[client])); ga_bIsInChallenge[GetClientOfUserId(ga_iChallengePartner[client])] = false; ga_iChallengePartner[GetClientOfUserId(ga_iChallengePartner[client])] = 0; }
public Action Event_PlayerDeath(Handle hEvent, const char[] sName, bool bDontBroadcast) { int client = GetClientOfUserId(GetEventInt(hEvent, "userid")); int attacker = GetClientOfUserId(GetEventInt(hEvent, "attacker"));
if(ga_bIsInChallenge[client]) { PrintToChatAll("[\x05Multi1v1\x01] \x03%N\x01 has lost their challange against \x03%N\x01!", client, attacker); ga_bIsInChallenge[client] = false; ga_bIsInChallenge[attacker] = false;
public Action Command_Challenge(int client, int args) { if (!gcv_bPluginEnabled.BoolValue) { ReplyToCommand(client, "[SM] This plugin is disabled!"); return Plugin_Handled; } if (!IsValidClient(client)) { ReplyToCommand(client, "[SM] You must be in-game to use this command!"); return Plugin_Handled; } if (ga_bIsInChallenge[client]) { ReplyToCommand(client, "[SM] You are already in a challenge!"); return Plugin_Handled; } if (ga_bIsInChallengeQueue[client]) { ReplyToCommand(client, "[SM] You are already in a queue for a challenge!"); return Plugin_Handled; } if (!g_bAllowChallenge) { ReplyToCommand(client, "[SM] There needs to be more than 4 people to use this command!"); return Plugin_Handled; } if (ga_iCooldown[client] > g_iRound) { ReplyToCommand(client, "[SM] You must wait %i round(s) before you challenge again!", ga_iCooldown[client] - g_iRound); return Plugin_Handled; } if (args == 1) { char sArg1[MAX_TARGET_LENGTH]; GetCmdArg(1, sArg1, sizeof(sArg1)); int target = FindTarget(client, sArg1, true, false); if (IsValidClient(target)) { if (target != client) { OpenRequestMenu(target, client); } else { ReplyToCommand(client, "[SM] You cannot target yourself!"); } } } else if (args == 0) { OpenChallengeMenu(client); } else { ReplyToCommand(client, "[SM] Usage : sm_challenge"); return Plugin_Handled; } return Plugin_Handled; }
public void OpenChallengeMenu(int client) { char sDisplayBuffer[128], sInfoBuffer[16], sTitle[64]; Format(sTitle, sizeof(sTitle), "Select a Player :"); Menu MainMenu = new Menu(MainMenu_CallBack, MenuAction_Select | MenuAction_End); MainMenu.SetTitle(sTitle); for (int i = 1; i <= MaxClients; i++) { if (IsValidClient(i) && i != client) { Format(sDisplayBuffer, sizeof(sDisplayBuffer), "%N", i); Format(sInfoBuffer, sizeof(sInfoBuffer), "%i", GetClientUserId(i)); MainMenu.AddItem(sInfoBuffer, sDisplayBuffer); } } DisplayMenu(MainMenu, client, MENU_TIME_FOREVER); }
public int MainMenu_CallBack(Menu MainMenu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_Select: { char sInfo[128]; GetMenuItem(MainMenu, param2, sInfo, sizeof(sInfo)); int iTarget = GetClientOfUserId(StringToInt(sInfo)); if (ga_bIsInChallenge[iTarget]) { ReplyToCommand(param1, "[SM] They are already in a challenge!"); return; } if (ga_bIsInChallengeQueue[iTarget]) { ReplyToCommand(param1, "[SM] They are already in a queue for a challenge!"); return; } if (ga_bIsInChallenge[param1]) { ReplyToCommand(param1, "[SM] You are already in a challenge!"); return; } if (ga_bIsInChallengeQueue[param1]) { ReplyToCommand(param1, "[SM] You are already in a queue for a challenge!"); return; } OpenRequestMenu(iTarget, param1); PrintToChatAll("[\x05Multi1v1\x01] \x03%N\x01 has challenged \x03%N\x01!", param1, iTarget); } case MenuAction_End: { CloseHandle(MainMenu); } } }
public void OpenRequestMenu(int reciever, int sender) { char sInfoBuffer[128], sTitle[128]; Format(sTitle, sizeof(sTitle), "%N Has Challenged You!", sender); Menu MainMenu = new Menu(RequestMenu_CallBack, MenuAction_Select | MenuAction_End); MainMenu.SetTitle(sTitle);
MainMenu.AddItem("", "By Accepting this challenge, you agree that you will ", ITEMDRAW_DISABLED); MainMenu.AddItem("", "be placed into a private arena to face your challenger.", ITEMDRAW_DISABLED); MainMenu.AddItem("", "", ITEMDRAW_DISABLED);
public int RequestMenu_CallBack(Menu MainMenu, MenuAction action, int param1, int param2) { switch (action) { case MenuAction_Select: { char sInfo[128], sTempArray[2][128]; GetMenuItem(MainMenu, param2, sInfo, sizeof(sInfo)); ExplodeString(sInfo, ";", sTempArray, 2, sizeof(sTempArray[])); int iSender = StringToInt(sTempArray[1]); if (StrEqual(sTempArray[0], "yes")) { if (ga_bIsInChallenge[iSender]) { ReplyToCommand(param1, "[SM] They are already in a challenge!"); return; } if (ga_bIsInChallengeQueue[iSender]) { ReplyToCommand(param1, "[SM] They are already in a queue for a challenge!"); return; } if (ga_bIsInChallenge[param1]) { ReplyToCommand(param1, "[SM] You are already in a challenge!"); return; } if (ga_bIsInChallengeQueue[param1]) { ReplyToCommand(param1, "[SM] You are already in a queue for a challenge!"); return; } PutInChallengeQueue(StringToInt(sTempArray[1]), param1); PrintToChatAll( "[\x05Multi1v1\x01] \x03%N\x01 has accepted \x03%N\x01's challenge!", param1, iSender); PrintToChat(param1, "[\x05Multi1v1\x01] \x04You\x01 will be placed into a challenge next round!"); PrintToChat(iSender, "[\x05Multi1v1\x01] \x04You\x01 will be placed into a challenge next round!");
PrintToChat(player1, "[\x05Multi1v1\x01] \x04You\x01 are now in a challenge against \x03%N", player2); PrintToChat(player2, "[\x05Multi1v1\x01] \x04You\x01 are now in a challenge against \x03%N", player1);
stock int GetPlayerCount() { int iAmmount = 0; for (int i = 1; i <= MaxClients; i++) { if (IsValidClient(i)) { iAmmount++; } } return iAmmount; } /* Change Log 1.0 - Initial Release 1.1 - Added CVARS - Created a shorter command "sm_chal" 1.2 - Fixed issue where players could target themselves 1.2.3 - Fixed issue where leaving players would glitch out the queue 1.2.4 - Cleaned up the code a little bit and hopefully fixed a few errors */
INSTALLATION:
Make sure you are running SourceMod Verson 1.7 or higher
Install hl_challenge.smx into the /plugins/ folder inside of sourcemod on your game server
Load the plugin manually, or change maps
Edit cfg/sourcemod/hl_challenge.cfg to your liking
Enjoy!
BUGS:
If you have any issues or bugs then you should report them either on this thread or on our GitHub!
BACKSTORY:
When I first started creating CS:GO servers, I created a Multi-1v1 Server. That server taught me a lot about SourceMod and was my first introduction into SourceMod Plugins/Scripting. This plugin right here, is the first plugin I have ever wanted to make. All of my SourceMod scripting is based around wanting to make this plugin right here! Shout out to Splewis for making this Multi-1v1 mod and a HUGE thanks to the developers of AlliedMods. I love you guys.
Spoiler
DONATE:
If you feel that I have done a good job, please consider supporting me.
Can you edit sm-command from !challenge, to !cn or !cg, etc?
Cuz this to large.
Imagine combinations that could be used for multiple things, that would possibly cause conflicts.
E.g. !rs which is common for "Reset Score", but it could also be used for "Roulette Spin" in gaming-related plugins, and thereby conflict or run at once, etc.
Therefore I would say such short things should be made by each individual server operator (in this case you), and not included in the original plugin.
The better alternative for you would be with a push on one of your buttons, for example "C" for "challenge":
Code:
bind C "sm_challenge"
__________________
Mostly known as "DarkDeviL".
Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
Some maps like am_ramps, it will hold someone as a challenger for the whole map, endless rounds inside that map. So pretty much the challenger will be floating in other peoples arena, interfering/trolling.