├── addons └── sourcemod │ ├── scripting │ ├── 1v1dm │ │ ├── 1v1_Stats.sp │ │ ├── 1v1_HideRadar.sp │ │ ├── 1v1_KillSound.sp │ │ ├── 1v1_ShowDamage.sp │ │ ├── 1v1_FlashbangDuel.sp │ │ ├── 1v1_HideBlood.sp │ │ ├── 1v1_Cvars.sp │ │ ├── 1v1_AWPDuel.sp │ │ ├── 1v1_KillFeed.sp │ │ ├── 1v1_AntiCheat.sp │ │ ├── 1v1_Tags.sp │ │ ├── 1v1_AFK.sp │ │ ├── 1v1_Cookies.sp │ │ ├── 1v1_PlayerFirstJoin.sp │ │ ├── 1v1_Globals.sp │ │ ├── 1v1_Configs.sp │ │ ├── 1v1_Functions.sp │ │ ├── 1v1_Challenge.sp │ │ ├── 1v1_Spawns.sp │ │ ├── 1v1_Players.sp │ │ ├── 1v1_WeaponMenu.sp │ │ └── 1v1_Players2.sp │ └── 1v1DM.sp │ ├── plugins │ └── 1v1DM.smx │ ├── configs │ └── 1v1DM │ │ └── weapons.cfg │ └── translations │ ├── chi │ └── 1v1DM.phrases.txt │ └── 1v1DM.phrases.txt ├── cfg └── sourcemod │ └── 1v1DM │ ├── game_cvars.cfg │ └── 1v1DM.cfg └── README.md /addons/sourcemod/scripting/1v1dm/1v1_Stats.sp: -------------------------------------------------------------------------------- 1 | //test -------------------------------------------------------------------------------- /addons/sourcemod/plugins/1v1DM.smx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boomix/csgo-duels/HEAD/addons/sourcemod/plugins/1v1DM.smx -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_HideRadar.sp: -------------------------------------------------------------------------------- 1 | void HideRadar_OnPlayerSpawn(int client) 2 | { 3 | CreateTimer(0.0, RemoveRadar, client); 4 | } 5 | 6 | public Action RemoveRadar(Handle timer, any client) 7 | { 8 | if(client > 0) 9 | if(IsClientInGame(client) && !IsFakeClient(client)) 10 | SetEntProp(client, Prop_Send, "m_iHideHUD", GetEntProp(client, Prop_Send, "m_iHideHUD") | 1<<12); 11 | 12 | return Plugin_Handled; 13 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_KillSound.sp: -------------------------------------------------------------------------------- 1 | void KillSound_OnPlayerDeath(int killer) 2 | { 3 | if(killer > 0) 4 | if(IsClientInGame(killer) && !IsFakeClient(killer) && IsPlayerAlive(killer) && b_ClientSoundEnabled[killer]) 5 | ClientCommand(killer, "play */buttons/bell1.wav"); 6 | } 7 | 8 | void ChangeClientSound(int client){ 9 | 10 | if(b_ClientSoundEnabled[client]) 11 | { 12 | b_ClientSoundEnabled[client] = false; 13 | SetClientCookie(client, g_SoundEnabled, "0"); 14 | } else { 15 | b_ClientSoundEnabled[client] = true; 16 | SetClientCookie(client, g_SoundEnabled, "1"); 17 | } 18 | 19 | ShowMainMenu(client); 20 | } 21 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_ShowDamage.sp: -------------------------------------------------------------------------------- 1 | void ShowDamage_OnClientPutInServer(int client) 2 | { 3 | i_DamageGiven[client] = 0; 4 | } 5 | 6 | void ShowDamage_OnPlayerDeath(int client, int attacker) 7 | { 8 | if(g_DamageGivenCvar.IntValue == 1) 9 | PrintToChat(client, "%s %N killed you with %i hp left", PREFIX, attacker, 100 - i_DamageGiven[client]); 10 | 11 | //if(g_DamageReceivedCvar.IntValue == 1) 12 | // PrintToChat(attacker, "%sDamage received from \x4%N\x1: %i", PREFIX, client, i_DamageGiven[client]); 13 | } 14 | 15 | void ShowDamage_PlayerHurt(int attacker, int damage) 16 | { 17 | i_DamageGiven[attacker] += damage; 18 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_FlashbangDuel.sp: -------------------------------------------------------------------------------- 1 | void ChangeFlashbangDuel(int client) 2 | { 3 | if(b_FlashbangDuelEnabled[client]) 4 | { 5 | b_FlashbangDuelEnabled[client] = false; 6 | SetClientCookie(client, g_FlashbangDuel, "0"); 7 | } else { 8 | b_FlashbangDuelEnabled[client] = true; 9 | SetClientCookie(client, g_FlashbangDuel, "1"); 10 | } 11 | 12 | ShowMainMenu(client); 13 | } 14 | 15 | void GiveFlashbangs(int client) 16 | { 17 | RemoveGrenade(client); 18 | GivePlayerItem(client, "weapon_flashbang"); 19 | } 20 | 21 | void RemoveGrenade(int client) 22 | { 23 | int weapon = GetPlayerWeaponSlot(client, CS_SLOT_GRENADE); 24 | if(weapon > 0 && IsValidEntity(weapon)) { 25 | RemovePlayerItem(client, weapon); 26 | AcceptEntityInput(weapon, "Kill"); 27 | } 28 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_HideBlood.sp: -------------------------------------------------------------------------------- 1 | public Action TE_OnWorldDecal(const char[] te_name, const Players[], int numClients, float delay) 2 | { 3 | float vecOrigin[3]; 4 | int nIndex = TE_ReadNum("m_nIndex"); 5 | char sDecalName[64]; 6 | 7 | TE_ReadVector("m_vecOrigin", vecOrigin); 8 | GetDecalName(nIndex, sDecalName, sizeof(sDecalName)); 9 | 10 | if(StrContains(sDecalName, "decals/blood") == 0 && StrContains(sDecalName, "_subrect") != -1) 11 | { 12 | return Plugin_Handled; 13 | } 14 | 15 | return Plugin_Continue; 16 | } 17 | 18 | 19 | stock int GetDecalName(int index, char[] sDecalName, int maxlen) 20 | { 21 | int table = INVALID_STRING_TABLE; 22 | 23 | if (table == INVALID_STRING_TABLE) 24 | table = FindStringTable("decalprecache"); 25 | 26 | return ReadStringTable(table, index, sDecalName, maxlen); 27 | } 28 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Cvars.sp: -------------------------------------------------------------------------------- 1 | 2 | void Cvars_OnConfigsExecuted() 3 | { 4 | //Execute all game cvars 5 | ExecuteAndSaveCvars("sourcemod/1v1DM/game_cvars.cfg"); 6 | } 7 | 8 | void SetCvar(char[] scvar, char[] svalue) 9 | { 10 | Handle cvar = FindConVar(scvar); 11 | SetConVarString(cvar, svalue, true, false); 12 | } 13 | 14 | //****** 15 | //FUNCTIONS FROM MULTI 1V1 ARENA (thanks splewis) 16 | //****** 17 | 18 | stock Handle ExecuteAndSaveCvars(const char[] cfgFile) 19 | { 20 | char filePath[PLATFORM_MAX_PATH]; 21 | Format(filePath, sizeof(filePath), "cfg/%s", cfgFile); 22 | 23 | File file = OpenFile(filePath, "r"); 24 | if (file != null) { 25 | ServerCommand("exec %s", cfgFile); 26 | delete file; 27 | } else { 28 | LogError("Failed to open file for reading: %s", filePath); 29 | } 30 | 31 | //Set round time as timelimit 32 | g_Timelimit = FindCvarAndLogError("mp_timelimit"); 33 | GameRules_SetProp("m_iRoundTime", g_Timelimit.IntValue * 60, 4, 0, true); 34 | 35 | } -------------------------------------------------------------------------------- /addons/sourcemod/configs/1v1DM/weapons.cfg: -------------------------------------------------------------------------------- 1 | "Weapons" 2 | { 3 | "Rifles" 4 | { 5 | "weapon_ak47" 6 | { 7 | "name" "AK47" 8 | } 9 | "weapon_m4a1" 10 | { 11 | "name" "M4A4" 12 | } 13 | "weapon_m4a1_silencer" 14 | { 15 | "name" "M4A1-S" 16 | } 17 | "weapon_famas" 18 | { 19 | "name" "Famas" 20 | } 21 | "weapon_galilar" 22 | { 23 | "name" "Galil" 24 | } 25 | "weapon_aug" 26 | { 27 | "name" "AUG" 28 | } 29 | "weapon_sg556" 30 | { 31 | "name" "SG553" 32 | } 33 | } 34 | 35 | "Pistols" 36 | { 37 | "weapon_usp_silencer" 38 | { 39 | "name" "USP" 40 | } 41 | "weapon_glock" 42 | { 43 | "name" "Glock" 44 | } 45 | "weapon_p250" 46 | { 47 | "name" "P250" 48 | } 49 | "weapon_fiveseven" 50 | { 51 | "name" "Five-Seven" 52 | } 53 | "weapon_cz75a" 54 | { 55 | "name" "CZ75" 56 | } 57 | "weapon_tec9" 58 | { 59 | "name" "Tec-9" 60 | } 61 | "weapon_elite" 62 | { 63 | "name" "Dual Berettas" 64 | } 65 | "weapon_deagle" 66 | { 67 | "name" "Deagle" 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_AWPDuel.sp: -------------------------------------------------------------------------------- 1 | void ChangeAWPDuel(int client) 2 | { 3 | if(b_AwpDuelEnabled[client]) 4 | { 5 | b_AwpDuelEnabled[client] = false; 6 | SetClientCookie(client, g_AWPDuel, "0"); 7 | } else { 8 | b_AwpDuelEnabled[client] = true; 9 | SetClientCookie(client, g_AWPDuel, "1"); 10 | } 11 | 12 | ShowMainMenu(client); 13 | } 14 | 15 | void GiveAWPDuelWeapons(int client) 16 | { 17 | RemoveGrenade(client); 18 | 19 | int weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY); 20 | if(weapon > 0 && IsValidEntity(weapon)) { 21 | RemovePlayerItem(client, weapon); 22 | RemoveEdict(weapon); 23 | } 24 | GivePlayerItem(client, "weapon_awp"); 25 | 26 | int weapon2 = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY); 27 | if(weapon2 > 0 && IsValidEntity(weapon2)) { 28 | RemovePlayerItem(client, weapon2); 29 | RemoveEdict(weapon2); 30 | } 31 | 32 | int weapon3 = GetPlayerWeaponSlot(client, CS_SLOT_KNIFE); 33 | if(weapon3 > 0 && IsValidEntity(weapon3)) { 34 | RemovePlayerItem(client, weapon3); 35 | RemoveEdict(weapon3); 36 | } 37 | GivePlayerItem(client, "weapon_knife"); 38 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_KillFeed.sp: -------------------------------------------------------------------------------- 1 | void KillFeed_PlayerDeath(int victim, int attacker, char sWeapon[128], bool headshot = false, int penetrated) 2 | { 3 | if(g_ShowKillFeedCvar.IntValue == 0) 4 | { 5 | bool IsValidV = IsValidClient(victim); 6 | bool IsValidK = IsValidClient(attacker); 7 | 8 | int mVictim = IsValidV ? GetClientUserId(victim) : 0; 9 | int mKiller = IsValidK ? GetClientUserId(attacker) : 0; 10 | 11 | Event event = CreateEvent("player_death"); 12 | 13 | event.SetInt("userid", mVictim); 14 | event.SetInt("attacker", mKiller); 15 | event.SetString("weapon", sWeapon); 16 | event.SetBool("headshot", headshot); 17 | event.SetInt("penetrated", penetrated); 18 | 19 | if ( IsValidV ) 20 | event.FireToClient(victim); 21 | if(IsValidK && victim != attacker) 22 | event.FireToClient(attacker); 23 | 24 | event.Cancel(); 25 | 26 | } 27 | } 28 | 29 | bool IsValidClient(int client) 30 | { 31 | if(client <= 0 || client > MaxClients) 32 | return false; 33 | 34 | if(!IsClientInGame(client) || !IsClientConnected(client) || IsFakeClient(client)) 35 | return false; 36 | 37 | return true; 38 | } 39 | -------------------------------------------------------------------------------- /cfg/sourcemod/1v1DM/game_cvars.cfg: -------------------------------------------------------------------------------- 1 | mp_warmuptime 5 2 | mp_do_warmup_period 0 3 | bot_quota 0 4 | mp_timelimit 12 5 | mp_roundtime 12 6 | mp_roundtime_defuse 12 7 | mp_roundtime_hostage 12 8 | mp_freezetime 0 9 | mp_buytime 0 10 | mp_maxmoney 0 11 | sv_allow_votes 0 12 | sv_deadtalk 0 13 | sv_full_alltalk 1 14 | mp_round_restart_delay 1 15 | mp_roundtime_deployment 0 16 | mp_join_grace_time 0 17 | mp_autoteambalance 1 18 | mp_free_armor 1 19 | mp_halftime 0 20 | mp_match_can_clinch 0 21 | mp_autokick 0 22 | mp_playercashawards 0 23 | mp_teamcashawards 0 24 | sv_competitive_official_5v5 0 25 | sv_ignoregrenaderadio 1 26 | mp_maxrounds 0 27 | mp_ignore_round_win_conditions 1 28 | mp_limitteams 0 29 | mp_death_drop_gun 0 30 | mp_death_drop_c4 0 31 | mp_death_drop_defuser 0 32 | mp_death_drop_grenade 0 33 | mp_friendlyfire 0 34 | sv_infinite_ammo 0 35 | mp_endmatch_votenextmap_keepcurrent 0 36 | mp_endmatch_votenextmap 0 37 | mp_match_end_changelevel 1 38 | mp_t_default_primary "" 39 | mp_ct_default_primary "" 40 | mp_ct_default_secondary "" 41 | mp_t_default_secondary "" -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_AntiCheat.sp: -------------------------------------------------------------------------------- 1 | // Anti-Cheat compatibility. 2 | 3 | // Defines from Little Anti-Cheat. 4 | #define LILAC_CHEAT_AIMBOT 5 5 | #define LILAC_CHEAT_AIMLOCK 6 6 | 7 | // How long ago a teleport must be to block it, this is a little overkill, but should do. 8 | #define LILAC_TELEPORT_BLOCK_TIME 3.0 9 | 10 | // Keep track of when a player was teleported. 11 | static float fl_teleport_time[MAXPLAYERS + 1]; 12 | 13 | void AntiCheat_OnClientPutInServer(int client) 14 | { 15 | fl_teleport_time[client] = 0.0; 16 | } 17 | 18 | // Teleports an entity/player and handles Anti-Cheat exceptions. 19 | void TeleportEntitySafe(int entity, const float origin[3], const float angles[3], const float velocity[3]) 20 | { 21 | TeleportEntity(entity, origin, angles, velocity); 22 | 23 | // If this entity is a player, store the timestamp of when the player teleported. 24 | if (entity >= 1 && entity <= MaxClients && IsClientConnected(entity) && IsClientInGame(entity)) 25 | { 26 | fl_teleport_time[entity] = GetGameTime(); 27 | } 28 | } 29 | 30 | public Action lilac_allow_cheat_detection(int client, int cheat) 31 | { 32 | // This player teleported recently, block Aimbot & Aimlock detections. 33 | if (GetGameTime() - fl_teleport_time[client] < LILAC_TELEPORT_BLOCK_TIME && (cheat == LILAC_CHEAT_AIMLOCK || cheat == LILAC_CHEAT_AIMBOT)) 34 | return Plugin_Stop; 35 | 36 | // Don't block the detection. 37 | return Plugin_Continue; 38 | } 39 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Tags.sp: -------------------------------------------------------------------------------- 1 | void Tags_OnClientPutInServer(int client) 2 | { 3 | wins[client] = 0; 4 | UpdateTag(client); 5 | } 6 | 7 | void Tags_OnPlayerDeath(int victim, int killer) 8 | { 9 | wins[killer] += 1; 10 | wins[victim] = ((wins[victim] - 1 < 0) ? 0 : wins[victim] - 1); 11 | //CS_SetClientContributionScore(victim, wins[victim]); 12 | //CS_SetClientContributionScore(killer, wins[killer]); 13 | UpdateTag(victim); 14 | UpdateTag(killer); 15 | } 16 | 17 | 18 | void Tags_OnPlayerSpawn(int client) 19 | { 20 | UpdateTag(client); 21 | } 22 | 23 | void UpdateTag(int client) 24 | { 25 | int i; 26 | int list_players[MAXPLAYERS+1]; 27 | int player_count; 28 | 29 | for(i = 1; i <= MaxClients; i++) 30 | { 31 | if(IsClientInGame(i) && !IsClientSourceTV(i)) 32 | { 33 | list_players[player_count] = i; 34 | player_count++; 35 | } 36 | } 37 | 38 | SortCustom1D(list_players, player_count, sortfunc); 39 | 40 | int place = 0; 41 | for(i = 0; i < player_count; i++) 42 | { 43 | if(list_players[i] == client) 44 | place = i + 1; 45 | } 46 | 47 | 48 | //Set client tag 49 | char tag[50]; 50 | Format(tag, sizeof(tag), "[%i - %i wins]", place, wins[client]); 51 | CS_SetClientClanTag(client, tag); 52 | } 53 | 54 | public int sortfunc(int elem1, int elem2, const int[] array, Handle hndl) 55 | { 56 | if(wins[elem1] > wins[elem2]) { 57 | return -1; 58 | } 59 | else if(wins[elem1] < wins[elem2]) { 60 | return 1; 61 | } 62 | return 0; 63 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CS:GO DUELS 2 | Gamemode for CS:GO what mix deathmatch + 1v1 gamemode 3 | *** 4 | ## About duels 5 | 6 | The concept behind Duels is to create realistic 1v1 situations that can occur on maps played in tournaments like Dust2, Mirage, Cache, Overpass, Train etc. It’s a brand new(ish) tool for practice and is primarily focused on positioning, peaking, and map knowledge. Knowing how to peak someone, how to clear angles with quick peaks etc. 7 | You can of course say that Deathmatch is just that but let me remind you that Deathmatch has its faults. Who hasn’t been enraged just because you immediately die after you spawned or when you are shot in the back over and over again? Often, you shoot players from behind and think you are the king of CS, but really, what does that do for you in terms of improving? Duels have none or very limited of that. You can say that Duels is a mix between Arena 1on1 and Deathmatch with instant spawns. Best of two worlds. 8 | 9 | ## Video explanation 10 | 11 | [![Video](http://i.imgur.com/qsJO52L.png)](https://www.youtube.com/watch?v=a0Ti_AGVlnM) 12 | 13 | ## Servers 14 | ![](http://cache.gametracker.com/server_info/duels1.brutalcs.nu:27015/b_350_20_692108_381007_FFFFFF_000000.png) 15 | ![](http://cache.gametracker.com/server_info/duels9.brutalcs.nu:27015/b_350_20_692108_381007_FFFFFF_000000.png) 16 | http://www.gametracker.com/search/?search_by=map&query=duels_&sort=3&order=DESC&searchipp=50#search 17 | 18 | ## Installation 19 | 20 | * Download all the files 21 | * Download ['modified_spawntools.7z'](https://forums.alliedmods.net/attachment.php?attachmentid=162658&d=1494187104) 22 | * Extract all the files inside right paths. 23 | * Host workshop maps - https://steamcommunity.com/sharedfiles/filedetails/?id=810773843 24 | * Set max slot limit to 16 25 | * Your done 26 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_AFK.sp: -------------------------------------------------------------------------------- 1 | void AFK_OnClientPutInServer(int client) 2 | { 3 | b_isAFK[client] = true; 4 | } 5 | 6 | void AFK_MatchStarted(int client, int opponent) 7 | { 8 | b_isAFK[client] = true; 9 | b_isAFK[opponent] = true; 10 | } 11 | 12 | //On some kind of action, set that the player is not afk anymore 13 | public Action OnPlayerRunCmd(int client, int &iButtons, int &iImpulse, float fVelocity[3], float fAngles[3], int &iWeapon) 14 | { 15 | if(b_isAFK[client]) { 16 | if(iButtons > 0) { 17 | 18 | //player has pressed some kind of button (w, s, d, a, r, mouse1, mouse2) 19 | b_isAFK[client] = false; 20 | PrintHintText(client, ""); 21 | } else { 22 | 23 | float ang[3]; 24 | GetClientEyeAngles(client, ang); 25 | 26 | //if first time setting 27 | int one = RoundFloat(fLastPos[client][0]); 28 | int two = RoundFloat(fLastPos[client][1]); 29 | int tree = RoundFloat(fLastPos[client][2]); 30 | 31 | //If not default coords 32 | if(one != 0 || two != 0 && tree != 0) { 33 | 34 | //player has moved mouse around 35 | if( fLastPos[client][0] != ang[0] || fLastPos[client][1] != ang[1] || fLastPos[client][2] != ang[2] ) 36 | { 37 | b_isAFK[client] = false; 38 | PrintHintText(client, ""); 39 | fLastPos[client] = ang; 40 | } 41 | 42 | } else { 43 | fLastPos[client] = ang; 44 | } 45 | 46 | 47 | } 48 | 49 | //Show message that the player is afk 50 | if(b_isAFK[client] && i_PlayerArena[client] == LOBBY) 51 | PrintHintText(client, "Your'e AFK, not searcing for enemies"); 52 | 53 | } 54 | 55 | //Message that its searching for enemies 56 | if(!b_isAFK[client] && i_PlayerArena[client] == LOBBY) 57 | PrintHintText(client, "Searching for enemies.."); 58 | else if(!b_isAFK[client]) 59 | PrintHintText(client, ""); 60 | 61 | } 62 | 63 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Cookies.sp: -------------------------------------------------------------------------------- 1 | void Cookies_OnPluginStart() 2 | { 3 | g_SoundEnabled = RegClientCookie("1v1dm_soundEnabled", "1v1DM if kill sound is enabled", CookieAccess_Protected); 4 | g_Rifle = RegClientCookie("1v1dm_rifle", "1v1DM primary weapon (rifle)", CookieAccess_Protected); 5 | g_Pistol = RegClientCookie("1v1dm_pistol", "1v1DM secondary weapon (pistol)", CookieAccess_Protected); 6 | g_AWPDuel = RegClientCookie("1v1dm_awpDuel", "1v1DM if awp duel enabled", CookieAccess_Protected); 7 | g_FlashbangDuel = RegClientCookie("1v1dm_flashbangDuel","1v1DM if flashbang duel enabled", CookieAccess_Protected); 8 | } 9 | 10 | void Cookies_OnClientPutInServer(int client) 11 | { 12 | b_ClientSoundEnabled[client] = true; 13 | b_AwpDuelEnabled[client] = false; 14 | b_FlashbangDuelEnabled[client] = false; 15 | } 16 | 17 | void Cookies_OnPlayerTeam(int client) 18 | { 19 | //Load all cookies 20 | if(AreClientCookiesCached(client)) 21 | { 22 | char sCookieVal[50]; 23 | 24 | //Kill sound cookie 25 | GetClientCookie(client, g_SoundEnabled, sCookieVal, sizeof(sCookieVal)); 26 | int cookieVal= StringToInt(sCookieVal); 27 | b_ClientSoundEnabled[client] = (cookieVal == 0) ? false : true; 28 | 29 | //Rifle cookie 30 | GetClientCookie(client, g_Rifle, sCookieVal, sizeof(sCookieVal)); 31 | if(!StrEqual(sCookieVal, "")) 32 | g_PrimaryWeapon[client] = sCookieVal; 33 | 34 | //Pistol cookie 35 | GetClientCookie(client, g_Pistol, sCookieVal, sizeof(sCookieVal)); 36 | if(!StrEqual(sCookieVal, "")) 37 | g_SecondaryWeapon[client] = sCookieVal; 38 | 39 | //AWP duel cookie 40 | GetClientCookie(client, g_AWPDuel, sCookieVal, sizeof(sCookieVal)); 41 | cookieVal = StringToInt(sCookieVal); 42 | b_AwpDuelEnabled[client] = (cookieVal == 1) ? true : false; 43 | 44 | //Flashbang duel cookie 45 | GetClientCookie(client, g_FlashbangDuel, sCookieVal, sizeof(sCookieVal)); 46 | cookieVal = StringToInt(sCookieVal); 47 | b_FlashbangDuelEnabled[client] = (cookieVal == 1) ? true : false; 48 | } 49 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_PlayerFirstJoin.sp: -------------------------------------------------------------------------------- 1 | void PlayerFirstJoin_OnClientPutInServer(int client) 2 | { 3 | b_FirstTeamJoin[client] = true; 4 | } 5 | 6 | void PlayersFirstJoin_OnPlayerTeam(int client, int team) 7 | { 8 | if(team != CS_TEAM_SPECTATOR) 9 | { 10 | if(b_FirstTeamJoin[client]) 11 | { 12 | //Spawntools are weird, we want to force player to be in lobby 13 | float org[3], ang[3]; 14 | GetArenaSpawn(LOBBY, GetClientTeam(client), org, ang); 15 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 16 | CreateTimer(0.1, Telepors, client, TIMER_FLAG_NO_MAPCHANGE); 17 | 18 | CreateTimer(0.5, FirstJoin, client, TIMER_FLAG_NO_MAPCHANGE); 19 | b_FirstTeamJoin[client] = false; 20 | } 21 | } 22 | } 23 | 24 | public Action Telepors(Handle tmr, any client) 25 | { 26 | if(IsClientInGame(client) && IsInRightTeam(client)) 27 | { 28 | float org[3], ang[3]; 29 | GetArenaSpawn(LOBBY, GetClientTeam(client), org, ang); 30 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 31 | } 32 | 33 | return Plugin_Handled; 34 | } 35 | 36 | public Action FirstJoin(Handle tmr, any client) 37 | { 38 | if(client > 0) 39 | { 40 | if(IsClientInGame(client) && IsInRightTeam(client)) 41 | { 42 | 43 | //LogMessage("%N first joined team", client); 44 | 45 | //Respawn player if he is dead 46 | if(!IsPlayerAlive(client)) 47 | CS_RespawnPlayer(client); 48 | 49 | //Teleport to lobby 50 | TeleportToLobby(client, false); 51 | 52 | //Show weapon menu 53 | if(StrContains(g_PrimaryWeapon[client], "weapon_") == -1) 54 | { 55 | ShowPrimaryWeaponMenu(client); 56 | 57 | } else { 58 | 59 | b_FirstWeaponSelect[client] = false; 60 | 61 | //If server wants to show menu when client joins the game 62 | if(g_WeaponMenuJoinCvar.IntValue == 1) 63 | ShowMainMenu(client); 64 | 65 | //Finished picking weapons 66 | b_WaitingForEnemy[client] = true; 67 | 68 | //Check if there is free enemy 69 | KillSearchTimer(client); 70 | SearchTmr[client] = CreateTimer(0.1, PlayerKilled, client, TIMER_FLAG_NO_MAPCHANGE); 71 | 72 | //LogMessage("%N started search timer from the join", client); 73 | } 74 | } 75 | } 76 | 77 | return Plugin_Handled; 78 | } 79 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/chi/1v1DM.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | "Rifle:" 4 | { 5 | "#format" "{1:s}" 6 | "chi" "主武器: {1}" 7 | } 8 | 9 | "Pistol:" 10 | { 11 | "#format" "{1:s}" 12 | "chi" "手枪: {1}" 13 | } 14 | 15 | "Kill sound: On" 16 | { 17 | "chi" "击杀音效: 开启" 18 | } 19 | 20 | "Kill sound: Off" 21 | { 22 | "chi" "击杀音效: 关闭" 23 | } 24 | 25 | "AWP Duels: On" 26 | { 27 | "chi" "AWP决斗: 开启" 28 | } 29 | 30 | "AWP Duels: Off" 31 | { 32 | "chi" "AWP 决斗: 关闭" 33 | } 34 | 35 | "Flashbang Duels: On" 36 | { 37 | "chi" "闪光弹 决斗: 开启" 38 | } 39 | 40 | "Flashbang Duels: Off" 41 | { 42 | "chi" "闪光弹 决斗: 关闭" 43 | } 44 | 45 | "Primary weapon" 46 | { 47 | "chi" "主武器菜单" 48 | } 49 | 50 | "Secondary Weapon" 51 | { 52 | "chi" "副武器菜单" 53 | } 54 | 55 | "Weapon preferences" 56 | { 57 | "chi" "武器偏好设置" 58 | } 59 | 60 | 61 | "Not enogh players to start challenge" 62 | { 63 | "#format" "{1:i}" 64 | "chi" "至少需要 {1} 个玩家 才能开始挑战!" 65 | } 66 | 67 | "Your already in challenge" 68 | { 69 | "chi" "你已经在挑战, 输入 !stop 停止挑战玩家" 70 | } 71 | 72 | "Player not found" 73 | { 74 | "chi" "没有找到玩家!" 75 | } 76 | 77 | "There are several players with this name" 78 | { 79 | "chi" "对不起,有太多的玩家同名!!" 80 | } 81 | 82 | "You cant select yourself as enemy" 83 | { 84 | "chi" "你不能选择自己为挑战对象!" 85 | } 86 | 87 | "Select opponent" 88 | { 89 | "chi" "选择对手" 90 | } 91 | 92 | "Opponent left the game" 93 | { 94 | "chi" "对不起,你的对手离开了比赛" 95 | } 96 | 97 | "Opponent in challenge" 98 | { 99 | "chi" "对不起,你慢了,他已经在挑战其他玩家中了!" 100 | } 101 | 102 | "Challenge is sent" 103 | { 104 | "#format" "{1:s}" 105 | "chi" "挑战请求发送到 {1}" 106 | } 107 | 108 | "Player invited you to challenge" 109 | { 110 | "#format" "{1:s}" 111 | "chi" "{1} 邀请你单挑 输入!accept 以接受." 112 | } 113 | 114 | "Invite expired" 115 | { 116 | "chi" "对不起, 邀请单挑已过期!" 117 | } 118 | 119 | "No invites" 120 | { 121 | "chi" "对不起,你没有任何单挑邀请!" 122 | } 123 | 124 | "You left challenge" 125 | { 126 | "chi" "你离开了挑战!" 127 | } 128 | 129 | "Opponent left the challenge" 130 | { 131 | "#format" "{1:s}" 132 | "chi" "你的对手 {1} 开了挑战!" 133 | } 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /addons/sourcemod/translations/1v1DM.phrases.txt: -------------------------------------------------------------------------------- 1 | "Phrases" 2 | { 3 | "Rifle:" 4 | { 5 | "#format" "{1:s}" 6 | "en" "Rifle: {1}" 7 | } 8 | 9 | "Pistol:" 10 | { 11 | "#format" "{1:s}" 12 | "en" "Pistol: {1}" 13 | } 14 | 15 | "Kill sound: On" 16 | { 17 | "en" "Kill sound: On" 18 | } 19 | 20 | "Kill sound: Off" 21 | { 22 | "en" "Kill sound: Off" 23 | } 24 | 25 | "AWP Duels: On" 26 | { 27 | "en" "AWP Duels: On" 28 | } 29 | 30 | "AWP Duels: Off" 31 | { 32 | "en" "AWP Duels: Off" 33 | } 34 | 35 | "Flashbang Duels: On" 36 | { 37 | "en" "Flashbang Duels: On" 38 | } 39 | 40 | "Flashbang Duels: Off" 41 | { 42 | "en" "Flashbang Duels: Off" 43 | } 44 | 45 | "Primary weapon" 46 | { 47 | "en" "Primary weapon" 48 | } 49 | 50 | "Secondary Weapon" 51 | { 52 | "en" "Secondary Weapon" 53 | } 54 | 55 | "Weapon preferences" 56 | { 57 | "en" "Weapon preferences" 58 | } 59 | 60 | 61 | "Not enogh players to start challenge" 62 | { 63 | "#format" "{1:i}" 64 | "en" "There are required {1} players to be able to play challenge!" 65 | } 66 | 67 | "Your already in challenge" 68 | { 69 | "en" "Your already in challenge, write !stop to stop the challenge" 70 | } 71 | 72 | "Player not found" 73 | { 74 | "en" "Player not found!" 75 | } 76 | 77 | "There are several players with this name" 78 | { 79 | "en" "Sorry, there are more players with this username!" 80 | } 81 | 82 | "You cant select yourself as enemy" 83 | { 84 | "en" "You cant select yourself as enemy!" 85 | } 86 | 87 | "Select opponent" 88 | { 89 | "en" "Select opponent" 90 | } 91 | 92 | "Opponent left the game" 93 | { 94 | "en" "Sorry, your opponent left the game" 95 | } 96 | 97 | "Opponent in challenge" 98 | { 99 | "en" "Sorry, it`s too late, he is already in challenge" 100 | } 101 | 102 | "Challenge is sent" 103 | { 104 | "#format" "{1:s}" 105 | "en" "Challenge is sent to {1}" 106 | } 107 | 108 | "Player invited you to challenge" 109 | { 110 | "#format" "{1:s}" 111 | "en" "{1} invited you to challenge, write !accept to accept his challenge." 112 | } 113 | 114 | "Invite expired" 115 | { 116 | "en" "Sorry, invite expired!" 117 | } 118 | 119 | "No invites" 120 | { 121 | "en" "Sorry, you dont have any invites!" 122 | } 123 | 124 | "You left challenge" 125 | { 126 | "en" "You left the challenge!" 127 | } 128 | 129 | "Opponent left the challenge" 130 | { 131 | "#format" "{1:s}" 132 | "en" "Your opponent {1} left the challenge!" 133 | } 134 | 135 | } 136 | 137 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Globals.sp: -------------------------------------------------------------------------------- 1 | 2 | #define LoopAllPlayers(%1) for(int %1=1;%1<=MaxClients;++%1)\ 3 | if(IsClientInGame(%1) && !IsFakeClient(%1) && GetClientTeam(i) == CS_TEAM_CT || IsClientInGame(%1) && !IsFakeClient(%1) && GetClientTeam(i) == CS_TEAM_T) 4 | //#define LOBBY 2 5 | #define CVAR_NAME_MAX_LENGTH 255 6 | #define CVAR_VALUE_MAX_LENGTH 255 7 | 8 | 9 | char PREFIX[150] = ""; 10 | 11 | //Weapons 12 | ArrayList g_Rifles = null; 13 | ArrayList g_Pistols = null; 14 | char g_PrimaryWeapon[MAXPLAYERS + 1][50]; 15 | char g_SecondaryWeapon[MAXPLAYERS + 1][50]; 16 | char g_CustomRoundName[MAXPLAYERS + 1][50]; 17 | bool b_FirstWeaponSelect[MAXPLAYERS + 1]; 18 | 19 | //Spawns 20 | ArrayList g_TSpawnsList; 21 | ArrayList g_TAnglesList; 22 | ArrayList g_CTSpawnsList; 23 | ArrayList g_CTAnglesList; 24 | 25 | ConVar g_RoundRestartDelayCvar; 26 | 27 | //Arenas 28 | int g_maxArenas = 0; 29 | bool b_ArenaFree[32] = true; 30 | 31 | //Players 32 | bool b_WaitingForEnemy[MAXPLAYERS + 1] = false; 33 | int i_PlayerArena[MAXPLAYERS + 1] = -1; 34 | bool b_FirstTeamJoin[MAXPLAYERS + 1] = true; 35 | int i_PrevArena[MAXPLAYERS + 1]; 36 | int i_PlayerEnemy[MAXPLAYERS + 1]; 37 | int i_PrevEnemy[MAXPLAYERS + 1]; 38 | int g_offsCollisionGroup; 39 | 40 | int g_roundStartedTime = -1; 41 | bool b_NullOnce; 42 | 43 | int LOBBY = 1; 44 | 45 | Handle ArenaDamageTmr[64]; 46 | Handle SearchTmr[MAXPLAYERS + 1] = {null, ...}; 47 | 48 | //Cookies 49 | Handle g_SoundEnabled; 50 | bool b_ClientSoundEnabled[MAXPLAYERS + 1]; 51 | 52 | Handle g_Rifle; 53 | Handle g_Pistol; 54 | 55 | Handle g_AWPDuel; 56 | Handle g_FlashbangDuel; 57 | bool b_AwpDuelEnabled[MAXPLAYERS + 1]; 58 | bool b_FlashbangDuelEnabled[MAXPLAYERS + 1]; 59 | bool b_HideMainWeaponMenu[MAXPLAYERS + 1]; 60 | 61 | int i_DamageGiven[MAXPLAYERS + 1]; 62 | 63 | int iTextEntity[MAXPLAYERS + 1]; 64 | 65 | //Convars 66 | ConVar g_DamageGivenCvar; 67 | //ConVar g_DamageReceivedCvar; 68 | ConVar g_ShowUsernameCvar; 69 | ConVar g_PrefixCvar; 70 | ConVar g_EnableRiflesCvar; 71 | ConVar g_EnablePistolsCvar; 72 | //ConVar g_HeadshotOnlyCvar; 73 | ConVar g_GiveArmorCvar; 74 | ConVar g_GiveHelmetCvar; 75 | ConVar g_WeaponMenuJoinCvar; 76 | ConVar g_AWPDuelsCvar; 77 | ConVar g_FlashbangDuelsCvar; 78 | ConVar g_DuelDelayCvar; 79 | ConVar g_NoDamageCvar; 80 | ConVar g_ShowKillFeedCvar; 81 | ConVar g_CustomDuelChanceCvar; 82 | ConVar g_ChallengeMinPlayerCvar; 83 | ConVar g_ChallengeEnabled; 84 | 85 | ConVar g_Timelimit; 86 | 87 | int iChallengeEnemy[MAXPLAYERS + 1]; 88 | int iChallengeInvite[MAXPLAYERS + 1]; 89 | Handle ChallengeTmrInvite[MAXPLAYERS + 1]; 90 | 91 | bool b_isAFK[MAXPLAYERS + 1]; 92 | float fLastPos[MAXPLAYERS + 1][3]; 93 | 94 | int wins[MAXPLAYERS + 1]; -------------------------------------------------------------------------------- /cfg/sourcemod/1v1DM/1v1DM.cfg: -------------------------------------------------------------------------------- 1 | // This file was auto-generated by SourceMod (v1.8.0.5985) 2 | // ConVars for plugin "1v1DM.smx" 3 | 4 | 5 | // 0 will show ony killfeed in top right corner of your own kills, 1 will show all kills 6 | // - 7 | // Default: "0" 8 | // Minimum: "0.000000" 9 | // Maximum: "1.000000" 10 | sm_all_player_killfeed "0" 11 | 12 | // How many player minumum are necessary to be able to use !challenge or !duel 13 | // - 14 | // Default: "4" 15 | // Minimum: "0.000000" 16 | // Maximum: "32.000000" 17 | sm_challenge_min_players "4" 18 | 19 | // Percentage of possibility to get a custom duel 20 | // - 21 | // Default: "50" 22 | // Minimum: "0.000000" 23 | // Maximum: "100.000000" 24 | sm_custom_duel_chance "50" 25 | 26 | // How long it will wait to find a new enemy (longer time means winner will stay longer in arena after duel win, but there will be bigger possibility to get different opponent) 27 | // - 28 | // Default: "1.4" 29 | // Minimum: "0.300000" 30 | // Maximum: "5.000000" 31 | sm_duel_delay "1.4" 32 | 33 | // Enable AWP duels option 34 | // - 35 | // Default: "1" 36 | // Minimum: "0.000000" 37 | // Maximum: "1.000000" 38 | sm_enable_awp_duels "1" 39 | 40 | // Allow to pick pistols from guns menu (for rifles only servers set 0) 41 | // - 42 | // Default: "1" 43 | // Minimum: "0.000000" 44 | // Maximum: "1.000000" 45 | sm_enable_pistols "1" 46 | 47 | // Allow to pick rifles from guns menu (for pistols only servers set 0) 48 | // - 49 | // Default: "1" 50 | // Minimum: "0.000000" 51 | // Maximum: "1.000000" 52 | sm_enable_rifles "1" 53 | 54 | // Enable flashbang duel 55 | // - 56 | // Default: "1" 57 | // Minimum: "0.000000" 58 | // Maximum: "1.000000" 59 | sm_flashbangduel_enabled "1" 60 | 61 | // Give armor to player when new duel starts 62 | // - 63 | // Default: "1" 64 | // Minimum: "0.000000" 65 | // Maximum: "1.000000" 66 | sm_give_armor "1" 67 | 68 | // Give helmet to player when new duel starts 69 | // - 70 | // Default: "1" 71 | // Minimum: "0.000000" 72 | // Maximum: "1.000000" 73 | sm_give_helmet "1" 74 | 75 | // How long it will take when there is no damage in duel, to find a new duel for both enemies 76 | // - 77 | // Default: "25.0" 78 | // Minimum: "0.000000" 79 | // Maximum: "60.000000" 80 | sm_nodamage_new_enemy "25.0" 81 | 82 | // Prefix for the chat 83 | // - 84 | // Default: "{GREEN}[DUELS]{WHITE} " 85 | sm_prefix "{GREEN}[DUELS]{WHITE} " 86 | 87 | // Print in chat how much damage is given to enemy 88 | // - 89 | // Default: "1" 90 | // Minimum: "0.000000" 91 | // Maximum: "1.000000" 92 | sm_print_damage_given "1" 93 | 94 | // Show username in left top corner 95 | // - 96 | // Default: "1" 97 | // Minimum: "0.000000" 98 | // Maximum: "1.000000" 99 | sm_show_username "1" 100 | 101 | // Open weapon menu (default menu) when player joins the server 102 | // - 103 | // Default: "0" 104 | // Minimum: "0.000000" 105 | // Maximum: "1.000000" 106 | sm_weapon_menu_on_join "0" 107 | 108 | 109 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Configs.sp: -------------------------------------------------------------------------------- 1 | void Configs_OnPluginStartFunc() 2 | { 3 | g_DamageGivenCvar = CreateConVar("sm_print_damage_given", "1", "Print in chat how much damage is given to enemy", 0, true, 0.0, true, 1.0); 4 | g_ShowUsernameCvar = CreateConVar("sm_show_username", "1", "Show username in left top corner", 0, true, 0.0, true, 1.0); 5 | g_PrefixCvar = CreateConVar("sm_prefix", "{GREEN}[DUELS]{WHITE} ", "Prefix for the chat"); 6 | g_EnableRiflesCvar = CreateConVar("sm_enable_rifles", "1", "Allow to pick rifles from guns menu (for pistols only servers set 0)", 0, true, 0.0, true, 1.0); 7 | g_EnablePistolsCvar = CreateConVar("sm_enable_pistols", "1", "Allow to pick pistols from guns menu (for rifles only servers set 0)", 0, true, 0.0, true, 1.0); 8 | g_GiveArmorCvar = CreateConVar("sm_give_armor", "1", "Give armor to player when new duel starts", 0, true, 0.0, true, 1.0); 9 | g_GiveHelmetCvar = CreateConVar("sm_give_helmet", "1", "Give helmet to player when new duel starts", 0, true, 0.0, true, 1.0); 10 | g_WeaponMenuJoinCvar = CreateConVar("sm_weapon_menu_on_join", "0", "Open weapon menu (default menu) when player joins the server", 0, true, 0.0, true, 1.0); 11 | g_AWPDuelsCvar = CreateConVar("sm_enable_awp_duels", "1", "Enable AWP duels option", 0, true, 0.0, true, 1.0); 12 | g_DuelDelayCvar = CreateConVar("sm_duel_delay", "1.4", "How long it will wait to find a new enemy (longer time means winner will stay longer in arena after duel win, but there will be bigger possibility to get different opponent)", 0, true, 0.3, true, 5.0); 13 | g_NoDamageCvar = CreateConVar("sm_nodamage_new_enemy", "25.0", "How long it will take when there is no damage in duel, to find a new duel for both enemies", 0, true, 0.0, true, 60.0); 14 | g_ShowKillFeedCvar = CreateConVar("sm_all_player_killfeed", "0", "0 will show ony killfeed in top right corner of your own kills, 1 will show all kills", 0, true, 0.0, true, 1.0); 15 | g_FlashbangDuelsCvar = CreateConVar("sm_flashbangduel_enabled", "1", "Enable flashbang duel", 0, true, 0.0, true, 1.0); 16 | g_CustomDuelChanceCvar = CreateConVar("sm_custom_duel_chance", "50", "Percentage of possibility to get a custom duel", 0, true, 0.0, true, 100.0); 17 | g_ChallengeMinPlayerCvar= CreateConVar("sm_challenge_min_players", "4", "How many player minumum are necessary to be able to use !challenge or !duel", 0, true, 0.0, true, 32.0); 18 | g_ChallengeEnabled = CreateConVar("sm_challenge_enabled", "1", "Do you want to enabled !challenge feature", 0, true, 0.0, true, 1.0); 19 | 20 | //killfeed 21 | 22 | AutoExecConfig(true, "1v1DM", "sourcemod/1v1DM"); 23 | 24 | HookConVarChange(g_PrefixCvar, PrefixChanged); 25 | HookConVarChange(g_ChallengeEnabled, ChallengeChanged); 26 | 27 | FixPrefix(); 28 | } 29 | 30 | public int PrefixChanged(Handle cvar, const char[] oldValue, const char[] newValue) { 31 | FixPrefix(); 32 | } 33 | 34 | public void FixPrefix() 35 | { 36 | 37 | g_PrefixCvar.GetString(PREFIX, sizeof(PREFIX)); 38 | 39 | char ColorPre[150] = "\x1 "; 40 | ReplaceString(PREFIX, sizeof(PREFIX), "{WHITE}", "\x01"); 41 | ReplaceString(PREFIX, sizeof(PREFIX), "{RED}", "\x02"); 42 | ReplaceString(PREFIX, sizeof(PREFIX), "{TEAM}", "\x03"); 43 | ReplaceString(PREFIX, sizeof(PREFIX), "{GREEN}", "\x04"); 44 | ReplaceString(PREFIX, sizeof(PREFIX), "{LIME}", "\x05"); 45 | ReplaceString(PREFIX, sizeof(PREFIX), "{LIGHTGREEN}", "\x06"); 46 | ReplaceString(PREFIX, sizeof(PREFIX), "{LIGHTRED}", "\x07"); 47 | ReplaceString(PREFIX, sizeof(PREFIX), "{GRAY}", "\x08"); 48 | ReplaceString(PREFIX, sizeof(PREFIX), "{LIGHTOLIVE}", "\x09"); 49 | ReplaceString(PREFIX, sizeof(PREFIX), "{OLIVE}", "\x10"); 50 | ReplaceString(PREFIX, sizeof(PREFIX), "{PURPLE}", "\x0E"); 51 | ReplaceString(PREFIX, sizeof(PREFIX), "{LIGHTBLUE}", "\x0B"); 52 | ReplaceString(PREFIX, sizeof(PREFIX), "{BLUE}", "\x0C"); 53 | 54 | StrCat(ColorPre, sizeof(ColorPre), PREFIX); 55 | 56 | PREFIX = ColorPre; 57 | } -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Functions.sp: -------------------------------------------------------------------------------- 1 | //All the fuctions :] 2 | 3 | public void OnPluginStartFunc() 4 | { 5 | //WeaponMenu_PluginStart(); 6 | Cookies_OnPluginStart(); 7 | Configs_OnPluginStartFunc(); 8 | } 9 | 10 | public void OnMapStart() 11 | { 12 | 13 | //To hide team select 14 | GameRules_SetProp("m_bIsQueuedMatchmaking", 1); // remove team menu 15 | g_RoundRestartDelayCvar = FindCvarAndLogError("mp_round_restart_delay"); 16 | WeaponMenu_MapStart(); 17 | Spawns_MapStart(); 18 | Cvars_OnConfigsExecuted(); 19 | } 20 | 21 | //Auto put player in team 22 | public void Event_PlayerConnect(Event event, const char[] name, bool dontBroadcast) 23 | { 24 | int client = GetClientOfUserId(event.GetInt("userid")); 25 | int T = 0, CT = 0; 26 | for (int i = 1; i < MaxClients; i++) { 27 | if(IsClientInGame(i)) { 28 | if(GetClientTeam(i) == CS_TEAM_CT) 29 | CT++; 30 | else if(GetClientTeam(i) == CS_TEAM_T) 31 | T++; 32 | } 33 | } 34 | ChangeClientTeam(client, ((T > CT) ? CS_TEAM_CT : CS_TEAM_T)); 35 | } 36 | 37 | public void OnConfigsExecuted() 38 | { 39 | Cvars_OnConfigsExecuted(); 40 | } 41 | 42 | public Action Event_RoundStart(Handle event, const char[] name, bool dontBroadcast) 43 | { 44 | g_roundStartedTime = GetTime(); 45 | b_NullOnce = true; 46 | 47 | return Plugin_Continue; 48 | } 49 | 50 | public Action Event_OnRoundPostStart(Event event, const char[] name, bool dontBroadcast) 51 | { 52 | g_Timelimit = FindCvarAndLogError("mp_timelimit"); 53 | GameRules_SetProp("m_iRoundTime", g_Timelimit.IntValue * 60, 4, 0, true); 54 | 55 | return Plugin_Continue; 56 | } 57 | 58 | public void OnClientPutInServer(int client) 59 | { 60 | //Kick bots 61 | if(IsFakeClient(client) && !IsClientSourceTV(client)) 62 | ServerCommand("bot_kick"); 63 | 64 | if(!IsFakeClient(client) && !IsClientSourceTV(client) && client > 0) { 65 | WeaponMenu_OnClientPutInServer(client); 66 | Players_OnClientPutInServer(client); 67 | PlayerFirstJoin_OnClientPutInServer(client); 68 | SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); 69 | Cookies_OnClientPutInServer(client); 70 | ShowDamage_OnClientPutInServer(client); 71 | Challenge_OnClientPutInServer(client); 72 | AFK_OnClientPutInServer(client); 73 | Tags_OnClientPutInServer(client); 74 | AntiCheat_OnClientPutInServer(client); 75 | } 76 | } 77 | 78 | 79 | public void OnClientDisconnect(int client) 80 | { 81 | if(!IsClientSourceTV(client)) { 82 | Players_OnClientDisconnect(client); 83 | Challenge_OnClientDisconnect(client); 84 | SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage); 85 | } 86 | } 87 | 88 | public Action Event_OnPlayerSpawn(Event event, const char[] name, bool dontBroadcast) 89 | { 90 | int client = GetClientOfUserId(event.GetInt("userid")); 91 | HideRadar_OnPlayerSpawn(client); 92 | Tags_OnPlayerSpawn(client); 93 | //Players2_OnPlayerSpawn(client); 94 | 95 | return Plugin_Continue; 96 | } 97 | 98 | public Action Event_OnPlayerTeam(Event event, const char[] name, bool dontBroadcast) 99 | { 100 | int client = GetClientOfUserId(event.GetInt("userid")); 101 | int team = event.GetInt("team"); 102 | if(!IsFakeClient(client) && !IsClientSourceTV(client)) 103 | { 104 | //Players_OnPlayerTeam(client); 105 | Cookies_OnPlayerTeam(client); 106 | PlayersFirstJoin_OnPlayerTeam(client, team); 107 | SetEventBroadcast(event, true); 108 | 109 | //Possibly bug fix? 110 | if(i_PlayerEnemy[client] > 0 && IsClientInGame(i_PlayerEnemy[client]) && i_PlayerEnemy[i_PlayerEnemy[client]] == client) 111 | { 112 | TeleportToLobby(i_PlayerEnemy[client], true, true); 113 | TeleportToLobby(client, true); 114 | } 115 | } 116 | 117 | return Plugin_Continue; 118 | } 119 | 120 | public Action Event_PlayerHurt(Event event, const char[] name, bool dontBroadcast) 121 | { 122 | //int client = GetClientOfUserId(event.GetInt("userid")); 123 | int attacker = GetClientOfUserId(event.GetInt("attacker")); 124 | int damage = event.GetInt("dmg_health"); 125 | 126 | ShowDamage_PlayerHurt(attacker, damage); 127 | 128 | return Plugin_Continue; 129 | } 130 | 131 | public Action Event_OnPlayerDeath(Event event, const char[] name, bool dontBroadcast) 132 | { 133 | int client = GetClientOfUserId(event.GetInt("userid")); 134 | int attacker = GetClientOfUserId(event.GetInt("attacker")); 135 | Players_OnPlayerDeath(client, attacker); 136 | KillSound_OnPlayerDeath(attacker); 137 | ShowDamage_OnPlayerDeath(client, attacker); 138 | Tags_OnPlayerDeath(client, attacker); 139 | 140 | //Hide killfeed 141 | bool headshot = GetEventBool(event, "headshot", false); 142 | char sWeapon[128]; 143 | GetEventString(event, "weapon", sWeapon, 128); 144 | int penetrated = event.GetInt("penetrated"); 145 | 146 | KillFeed_PlayerDeath(client, attacker, sWeapon, headshot, penetrated); 147 | 148 | if(g_ShowKillFeedCvar.IntValue == 0) 149 | SetEventBroadcast(event, true); 150 | 151 | return Plugin_Continue; 152 | } 153 | 154 | public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype, int &weapon, float damageForce[3], float damagePosition[3], int damagecustom) 155 | { 156 | //Stop timer in that arena (afk timer?) 157 | if(IsClientInGame(victim) && attacker > 0) 158 | KillDamageTimer(i_PlayerArena[victim]); 159 | 160 | //Stop damage in lobby 161 | if(i_PlayerArena[victim] == LOBBY || i_PlayerArena[attacker] == LOBBY) 162 | return Plugin_Handled; 163 | 164 | //Stop damage if your not damaging your enemy 165 | if(i_PlayerEnemy[victim] != attacker && attacker > 0 || i_PlayerEnemy[attacker] != victim && attacker > 0) 166 | return Plugin_Handled; 167 | 168 | return Plugin_Continue; 169 | } 170 | 171 | 172 | public void OnGameFrame() 173 | { 174 | //Disable warmup completley 175 | if(GameRules_GetProp("m_bWarmupPeriod") == 1) 176 | GameRules_SetProp("m_bWarmupPeriod", 0); 177 | 178 | if(b_NullOnce) 179 | { 180 | if(GetTotalRoundTime() == GetCurrentRoundTime()) 181 | { 182 | b_NullOnce = false; 183 | SetCvar("mp_ignore_round_win_conditions", "0"); 184 | CreateTimer(1.0, EndRound, _, TIMER_FLAG_NO_MAPCHANGE); 185 | } 186 | } 187 | } 188 | 189 | public Action EndRound(Handle tmr, any client) 190 | { 191 | float delay = g_RoundRestartDelayCvar.FloatValue; 192 | CS_TerminateRound(delay, CSRoundEnd_TerroristWin); 193 | 194 | 195 | 196 | return Plugin_Continue; 197 | } 198 | 199 | public int GetTotalRoundTime() 200 | { 201 | return GameRules_GetProp("m_iRoundTime"); 202 | } 203 | 204 | public int GetCurrentRoundTime() 205 | { 206 | static Handle h_freezeTime = null; 207 | 208 | if(h_freezeTime == null) 209 | h_freezeTime = FindConVar("mp_freezetime"); 210 | 211 | int freezeTime = GetConVarInt(h_freezeTime); 212 | return (GetTime() - g_roundStartedTime) - freezeTime; 213 | } 214 | 215 | stock ConVar FindCvarAndLogError(const char[] name) { 216 | ConVar c = FindConVar(name); 217 | if (c == null) { 218 | LogError("ConVar \"%s\" could not be found"); 219 | } 220 | return c; 221 | } 222 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Challenge.sp: -------------------------------------------------------------------------------- 1 | void Challenge_OnClientPutInServer(int client) 2 | { 3 | iChallengeEnemy[client] = -1; 4 | iChallengeInvite[client] = -1; 5 | } 6 | 7 | void Challenge_OnClientDisconnect(int client) 8 | { 9 | 10 | int opponent = iChallengeEnemy[client]; 11 | if(opponent > 0) 12 | if(IsClientInGame(opponent)) 13 | if(iChallengeEnemy[opponent] == client) 14 | iChallengeEnemy[opponent] = -1; 15 | 16 | 17 | iChallengeEnemy[client] = -1; 18 | iChallengeInvite[client] = -1; 19 | 20 | 21 | //Split up duels if there are not enogh players 22 | int count = 0; 23 | LoopAllPlayers(i) 24 | count++; 25 | 26 | if(count < g_ChallengeMinPlayerCvar.IntValue) 27 | { 28 | LoopAllPlayers(i) 29 | { 30 | if(iChallengeEnemy[i] > 0) 31 | { 32 | PrintToChat(i, "%s%T", PREFIX, "Not enogh players to start challenge", i, g_ChallengeMinPlayerCvar.IntValue); 33 | CMD_Deny(i, 0); 34 | } 35 | } 36 | } 37 | 38 | } 39 | 40 | //Challenge turned off 41 | public int ChallengeChanged(Handle cvar, const char[] oldValue, const char[] newValue) { 42 | 43 | if(StringToInt(newValue) == 0) 44 | LoopAllPlayers(i) 45 | if(iChallengeEnemy[i] > 0) 46 | CMD_Deny(i, 0); 47 | 48 | } 49 | 50 | public Action CMD_Challenge(int client, int args) 51 | { 52 | 53 | if(g_ChallengeEnabled.IntValue == 0) 54 | return Plugin_Handled; 55 | 56 | int count = 0; 57 | LoopAllPlayers(i) 58 | count++; 59 | 60 | if(count < g_ChallengeMinPlayerCvar.IntValue) 61 | { 62 | PrintToChat(client, "%s%T", PREFIX, "Not enogh players to start challenge", client, g_ChallengeMinPlayerCvar.IntValue); 63 | return Plugin_Handled; 64 | } 65 | 66 | 67 | //Here will be checks if player is allowed to type that 68 | if(iChallengeEnemy[client] > 0) 69 | { 70 | PrintToChat(client, "%s%T", PREFIX, "Your already in challenge", client); 71 | return Plugin_Handled; 72 | } 73 | 74 | //Player entered wrong command 75 | if(args > 1) 76 | { 77 | 78 | PrintToChat(client, "%s!challenge [username]", PREFIX); 79 | return Plugin_Handled; 80 | 81 | 82 | //Player entered direct username 83 | } else if(args == 1) { 84 | 85 | char user[MAX_NAME_LENGTH], target_name[MAX_TARGET_LENGTH]; 86 | GetCmdArg(1, user, sizeof(user)); 87 | int target_list[MAXPLAYERS], target_count; 88 | bool tn_is_ml; 89 | if ((target_count = ProcessTargetString(user, client, target_list, MAXPLAYERS, COMMAND_FILTER_CONNECTED, target_name, sizeof(target_name), tn_is_ml)) <= 0) 90 | { 91 | PrintToChat(client, "%s%T", PREFIX, "Player not found", client); 92 | return Plugin_Handled; 93 | } 94 | 95 | if(target_count > 1) 96 | { 97 | PrintToChat(client, "%s%T", PREFIX, "There are several players with this name", client); 98 | return Plugin_Handled; 99 | } else if(target_count == 1) { 100 | 101 | if(client == target_list[0]) 102 | { 103 | PrintToChat(client, "%s%T", PREFIX, client, "You cant select yourself as enemy", client); 104 | return Plugin_Handled; 105 | } 106 | 107 | ChallengePlayer(client, target_list[0]); 108 | return Plugin_Handled; 109 | } 110 | 111 | 112 | //Player didn't enter username, lets show him menu with all users 113 | } else { 114 | 115 | SetGlobalTransTarget(client); 116 | Menu menu = new Menu(MenuHandlers_Challenge); 117 | char cMenuTitle[64]; 118 | Format(cMenuTitle, sizeof(cMenuTitle), "%T", "Select opponent", client); 119 | menu.SetTitle(cMenuTitle); 120 | 121 | LoopAllPlayers(i) 122 | { 123 | if(iChallengeEnemy[i] == -1 && i != client) 124 | { 125 | char username[128], userID[10]; 126 | GetClientName(i, username, sizeof(username)); 127 | IntToString(GetClientUserId(i), userID, sizeof(userID)); 128 | menu.AddItem(userID, username); 129 | } 130 | } 131 | 132 | //Display 133 | menu.ExitButton = true; 134 | menu.Display(client, 20); 135 | 136 | } 137 | 138 | 139 | return Plugin_Handled; 140 | } 141 | 142 | public int MenuHandlers_Challenge(Menu menu, MenuAction action, int client, int item) 143 | { 144 | switch(action) 145 | { 146 | case MenuAction_Select: 147 | { 148 | 149 | char ctarget[5]; 150 | GetMenuItem(menu, item, ctarget, sizeof(ctarget)); 151 | int target = GetClientOfUserId(StringToInt(ctarget)); 152 | 153 | if(target > 0) 154 | if(IsClientInGame(target)) 155 | ChallengePlayer(client, target); 156 | 157 | } 158 | 159 | case MenuAction_End: 160 | delete menu; 161 | } 162 | } 163 | 164 | 165 | 166 | void ChallengePlayer(int client, int target) 167 | { 168 | if(g_ChallengeEnabled.IntValue == 0) 169 | return; 170 | 171 | iChallengeEnemy[client] = -1; 172 | 173 | if(!IsClientInGame(target)) 174 | { 175 | PrintToChat(client, "%s%T", PREFIX, "Enemy left the game", client); 176 | return; 177 | } 178 | 179 | if(iChallengeEnemy[target] != -1) 180 | { 181 | PrintToChat(client, "%s%T", PREFIX, "Opponent in challenge", client); 182 | return; 183 | } 184 | 185 | iChallengeInvite[client] = target; 186 | iChallengeInvite[target] = client; 187 | KillInviteTimer(client); 188 | ChallengeTmrInvite[client] = CreateTimer(20.0, RemoveInvite, GetClientUserId(client)); 189 | 190 | char username[MAX_NAME_LENGTH], username2[MAX_NAME_LENGTH]; 191 | GetClientName(client, username, sizeof(username)); 192 | GetClientName(target, username2, sizeof(username2)); 193 | PrintToChat(client, "%s%T", PREFIX, "Challenge is sent", client, username2); 194 | PrintToChat(target, " "); 195 | PrintToChat(target, "%s%T", PREFIX, "Player invited you to challenge", target, username); 196 | PrintToChat(target, " "); 197 | 198 | } 199 | 200 | void KillInviteTimer(int client) 201 | { 202 | if (ChallengeTmrInvite[client] != null) 203 | { 204 | KillTimer(ChallengeTmrInvite[client]); 205 | ChallengeTmrInvite[client] = null; 206 | } 207 | } 208 | 209 | public Action RemoveInvite(Handle tmr, any userID) 210 | { 211 | int client = GetClientOfUserId(userID); 212 | if(client > 0) 213 | { 214 | ChallengeTmrInvite[client] = null; 215 | if(IsClientInGame(client)) 216 | { 217 | int opponent = iChallengeInvite[client]; 218 | if(opponent > 0 && opponent < MaxClients && IsClientInGame(opponent)) { 219 | PrintToChat(opponent, "%s%T", PREFIX, "Invite expired", opponent); 220 | 221 | if(iChallengeEnemy[opponent] != client) 222 | { 223 | iChallengeInvite[client] = -1; 224 | PrintToChat(client, "%s%T", PREFIX, "Invite expired", client); 225 | } 226 | 227 | } 228 | } 229 | } 230 | 231 | } 232 | 233 | 234 | 235 | public Action CMD_Accept(int client, int args) 236 | { 237 | if(iChallengeInvite[client] == -1) 238 | { 239 | PrintToChat(client, "%s%T", PREFIX, "No invites", client); 240 | return Plugin_Handled; 241 | } 242 | 243 | int opponent = iChallengeInvite[client]; 244 | 245 | if(iChallengeInvite[opponent] != client) 246 | { 247 | PrintToChat(client, "%s%T", PREFIX, "Invite expired", client); 248 | return Plugin_Handled; 249 | } 250 | 251 | KillInviteTimer(opponent); 252 | iChallengeInvite[client] = -1; 253 | iChallengeInvite[opponent] = -1; 254 | iChallengeEnemy[opponent] = client; 255 | iChallengeEnemy[client] = opponent; 256 | 257 | PrintToChat(client, "%sYou accepted invite!", PREFIX, client); 258 | PrintToChat(opponent, "%sYour invite is accepted!", PREFIX, opponent); 259 | 260 | return Plugin_Handled; 261 | } 262 | 263 | public Action CMD_Deny(int client, int args) 264 | { 265 | 266 | if(iChallengeEnemy[client] != -1) 267 | { 268 | int opponent = iChallengeEnemy[client]; 269 | PrintToChat(client, "%s%T", PREFIX, "You left challenge", client); 270 | 271 | if(opponent > 0) 272 | { 273 | if(IsClientInGame(opponent)) 274 | { 275 | char username[MAX_NAME_LENGTH]; 276 | GetClientName(client, username, sizeof(username)); 277 | PrintToChat(opponent, "%s%T", PREFIX, "Opponent left the challenge", opponent, username); 278 | iChallengeEnemy[opponent] = -1; 279 | iChallengeInvite[opponent] = -1; 280 | } 281 | } 282 | 283 | iChallengeEnemy[client] = -1; 284 | iChallengeInvite[client] = -1; 285 | } 286 | 287 | return Plugin_Handled; 288 | } 289 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Spawns.sp: -------------------------------------------------------------------------------- 1 | #define CHECK_ARENA(%1) if (%1 <= 0 || %1 > g_maxArenas) PrintToServer("Arena %d is not valid", %1) 2 | 3 | void Spawns_MapStart() 4 | { 5 | CreateTimer(1.0, IfCustomSpawnsAreAdded, _, TIMER_FLAG_NO_MAPCHANGE); 6 | //There is 'spawntools7', what creates the spawns bit later 7 | 8 | } 9 | 10 | 11 | public Action IfCustomSpawnsAreAdded(Handle tmr, any client) 12 | { 13 | CloseNestedList(g_TSpawnsList); 14 | CloseNestedList(g_TAnglesList); 15 | CloseNestedList(g_CTSpawnsList); 16 | CloseNestedList(g_CTAnglesList); 17 | 18 | g_TSpawnsList = new ArrayList(); 19 | g_TAnglesList = new ArrayList(); 20 | g_CTSpawnsList = new ArrayList(); 21 | g_CTAnglesList = new ArrayList(); 22 | 23 | AddTeamSpawns("info_player_terrorist", g_TSpawnsList, g_TAnglesList); 24 | AddTeamSpawns("info_player_counterterrorist", g_CTSpawnsList, g_CTAnglesList); 25 | 26 | int ct = GetArraySize(g_CTSpawnsList); 27 | int t = GetArraySize(g_TSpawnsList); 28 | g_maxArenas = (ct < t) ? ct : t; 29 | 30 | int lobbyID = -1; 31 | for (int i = 1; i <= g_maxArenas; i++) 32 | { 33 | b_ArenaFree[i] = true; 34 | 35 | //Get lobby arena (the one that is nearest to y0 and x0) 36 | float org[3], ang[3], org2[3], ang2[3]; 37 | float mid[3]; 38 | mid[0] = 0.0; 39 | mid[1] = 0.0; 40 | mid[2] = 0.0; 41 | 42 | if(lobbyID == -1){ 43 | lobbyID = i; 44 | } else { 45 | 46 | //Get both spawnpoint coors 47 | GetArenaSpawn(lobbyID, CS_TEAM_CT, org, ang); 48 | GetArenaSpawn(i, CS_TEAM_CT, org2, ang2); 49 | 50 | float distanceLobby = GetVectorDistance(mid, org, true); 51 | float distanceNew = GetVectorDistance(mid, org2, true); 52 | 53 | if(distanceNew < distanceLobby) 54 | lobbyID = i; 55 | 56 | } 57 | } 58 | 59 | PrintToServer("ARENAS: %i", g_maxArenas); 60 | 61 | LOBBY = lobbyID; 62 | 63 | return Plugin_Handled; 64 | } 65 | 66 | void CloseNestedList(ArrayList list) { 67 | if(list == null) 68 | return; 69 | 70 | int n = list.Length; 71 | if(list.Length > 0) 72 | { 73 | for (int i = 0; i < n; i++) { 74 | ArrayList list2 = view_as(list.Get(i)); 75 | if(list2 != null) 76 | delete list2; 77 | } 78 | } 79 | delete list; 80 | list = null; 81 | } 82 | 83 | int GetFreeArena(int prevOne = -1) 84 | { 85 | ArrayList AllArenas = new ArrayList(g_maxArenas); 86 | 87 | for (int i = 1; i <= g_maxArenas; i++){ 88 | if(b_ArenaFree[i] && i != LOBBY && i != prevOne){ 89 | char arenaID[3]; 90 | IntToString(i, arenaID, sizeof(arenaID)); 91 | PushArrayString(AllArenas, arenaID); 92 | } 93 | } 94 | 95 | if(AllArenas.Length <= 0) 96 | { 97 | for (int i = 1; i <= g_maxArenas; i++){ 98 | if(b_ArenaFree[i] && i != LOBBY){ 99 | char arenaID[3]; 100 | IntToString(i, arenaID, sizeof(arenaID)); 101 | PushArrayString(AllArenas, arenaID); 102 | } 103 | } 104 | } 105 | 106 | if(AllArenas.Length > 0) 107 | { 108 | int random = GetRandomInt(0, AllArenas.Length - 1); 109 | 110 | char arenaID2[3]; 111 | AllArenas.GetString(random, arenaID2, sizeof(arenaID2)); 112 | 113 | int retArena = StringToInt(arenaID2); 114 | if(retArena > 0 && retArena < g_maxArenas + 1) 115 | { 116 | delete AllArenas; 117 | return retArena; 118 | } 119 | } 120 | 121 | delete AllArenas; 122 | 123 | return -1; 124 | 125 | } 126 | 127 | //Function from multi1v1 128 | static void AddTeamSpawns(const char[] className, ArrayList spawnList, ArrayList angleList) { 129 | 130 | float spawn[3]; 131 | float angle[3]; 132 | 133 | int ent = -1; 134 | while ((ent = FindEntityByClassname(ent, className)) != -1) { 135 | 136 | GetEntPropVector(ent, Prop_Data, "m_vecOrigin", spawn); 137 | GetEntPropVector(ent, Prop_Data, "m_angRotation", angle); 138 | 139 | char spawnName[100]; 140 | GetEntPropString(ent, Prop_Data, "m_iName", spawnName, sizeof(spawnName)); 141 | if(StrContains(spawnName, "arena") != -1 || StrContains(spawnName, "spawnroom") != -1 ){ 142 | 143 | int currentArenaID; 144 | 145 | if(StrContains(spawnName, "spawnroom") != -1) 146 | { 147 | 148 | currentArenaID = 0; 149 | 150 | } else { 151 | 152 | char brake[4][40]; 153 | ExplodeString(spawnName, ".", brake, sizeof(brake), sizeof(brake[])); 154 | currentArenaID = StringToInt(brake[1]); 155 | 156 | } 157 | 158 | AddSpawn2(currentArenaID, spawn, angle, spawnList, angleList); 159 | 160 | } else { 161 | AddSpawn(spawn, angle, spawnList, angleList); 162 | } 163 | } 164 | 165 | } 166 | 167 | static void AddSpawn2(int arena, float spawn[3], float angle[3], ArrayList spawnList, ArrayList angleList) 168 | { 169 | if(arena < GetArraySize(spawnList)) 170 | { 171 | ArrayList spawns = view_as(spawnList.Get(arena)); 172 | ArrayList angles = view_as(angleList.Get(arena)); 173 | spawns.PushArray(spawn); 174 | angles.PushArray(angle); 175 | 176 | } else { 177 | 178 | ArrayList spawns = new ArrayList(3); 179 | ArrayList angles = new ArrayList(3); 180 | PushArrayCell(spawnList, spawns); 181 | PushArrayCell(angleList, angles); 182 | AddSpawn2(arena, spawn, angle, spawnList, angleList); 183 | 184 | } 185 | } 186 | 187 | 188 | static void AddSpawn(float spawn[3], float angle[3], ArrayList spawnList, ArrayList angleList) { 189 | // First scan for a nearby arena to place this spawn into. 190 | // If one is found - these spawn is pushed onto that arena's list. 191 | for (int i = 0; i < GetArraySize(spawnList); i++) { 192 | ArrayList spawns = view_as(spawnList.Get(i)); 193 | ArrayList angles = view_as(angleList.Get(i)); 194 | 195 | //Find closest arena in distance 196 | int closestIndex = NearestNeighborIndex(spawn, spawns); 197 | 198 | if (closestIndex >= 0) { 199 | float closestSpawn[3]; 200 | spawns.GetArray(closestIndex, closestSpawn); 201 | float dist = GetVectorDistance(spawn, closestSpawn); 202 | 203 | if (dist < 1600.0) { 204 | spawns.PushArray(spawn); 205 | angles.PushArray(angle); 206 | return; 207 | } 208 | } 209 | } 210 | 211 | // If no nearby arena was found - create a new list for this newly found arena and push it. 212 | ArrayList spawns = new ArrayList(3); 213 | ArrayList angles = new ArrayList(3); 214 | spawns.PushArray(spawn); 215 | angles.PushArray(angle); 216 | PushArrayCell(spawnList, spawns); 217 | PushArrayCell(angleList, angles); 218 | } 219 | 220 | /** 221 | * Given an array of vectors, returns the index of the index 222 | * that minimizes the euclidean distance between the vectors. 223 | */ 224 | stock int NearestNeighborIndex(const float vec[3], ArrayList others) { 225 | int closestIndex = -1; 226 | float closestDistance = 0.0; 227 | for (int i = 0; i < others.Length; i++) { 228 | float tmp[3]; 229 | others.GetArray(i, tmp); 230 | float dist = GetVectorDistance(vec, tmp); 231 | if (closestIndex < 0 || dist < closestDistance) { 232 | closestDistance = dist; 233 | closestIndex = i; 234 | } 235 | } 236 | 237 | return closestIndex; 238 | } 239 | 240 | void GetArenaSpawn(int arena, int team, float origin[3], float angle[3]) { 241 | 242 | CHECK_ARENA(arena); 243 | 244 | if (team == CS_TEAM_T || team == CS_TEAM_CT) 245 | { 246 | ArrayList spawns; 247 | ArrayList angles; 248 | if (team == CS_TEAM_CT) { 249 | spawns = view_as(GetArrayCell(g_CTSpawnsList, arena - 1)); 250 | angles = view_as(GetArrayCell(g_CTAnglesList, arena - 1)); 251 | } else { 252 | spawns = view_as(GetArrayCell(g_TSpawnsList, arena - 1)); 253 | angles = view_as(GetArrayCell(g_TAnglesList, arena - 1)); 254 | } 255 | 256 | int count = GetArraySize(spawns); 257 | int index = GetRandomInt(0, count - 1); 258 | GetArrayArray(spawns, index, origin); 259 | GetArrayArray(angles, index, angle); 260 | } 261 | } 262 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1DM.sp: -------------------------------------------------------------------------------- 1 | #pragma semicolon 1 2 | 3 | #define DEBUG 4 | 5 | #define PLUGIN_AUTHOR "boomix" 6 | #define PLUGIN_VERSION "1.31" 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | //File includes 17 | #include "1v1dm/1v1_AntiCheat.sp" 18 | #include "1v1dm/1v1_Globals.sp" 19 | #include "1v1dm/1v1_Functions.sp" 20 | #include "1v1dm/1v1_Configs.sp" 21 | #include "1v1dm/1v1_Cvars.sp" 22 | #include "1v1dm/1v1_Cookies.sp" 23 | #include "1v1dm/1v1_WeaponMenu.sp" 24 | #include "1v1dm/1v1_HideRadar.sp" 25 | #include "1v1dm/1v1_Spawns.sp" 26 | #include "1v1dm/1v1_Players2.sp" 27 | #include "1v1dm/1v1_PlayerFirstJoin.sp" 28 | #include "1v1dm/1v1_HideBlood.sp" 29 | #include "1v1dm/1v1_KillSound.sp" 30 | #include "1v1dm/1v1_AWPDuel.sp" 31 | #include "1v1dm/1v1_KillFeed.sp" 32 | #include "1v1dm/1v1_ShowDamage.sp" 33 | #include "1v1dm/1v1_FlashbangDuel.sp" 34 | #include "1v1dm/1v1_Challenge.sp" 35 | #include "1v1dm/1v1_AFK.sp" 36 | #include "1v1dm/1v1_Tags.sp" 37 | 38 | #pragma newdecls required 39 | 40 | EngineVersion g_Game; 41 | 42 | public Plugin myinfo = 43 | { 44 | name = "1v1 deathmatch (duels)", 45 | author = PLUGIN_AUTHOR, 46 | description = "1v1 deathmatch for CS:GO (duels)", 47 | version = PLUGIN_VERSION, 48 | url = "http://identy.lv" 49 | }; 50 | 51 | 52 | 53 | public void OnPluginStart() 54 | { 55 | g_Game = GetEngineVersion(); 56 | if(g_Game != Engine_CSGO) 57 | SetFailState("This plugin is for CS:GO only."); 58 | 59 | 60 | //** COMMANDS **// 61 | RegConsoleCmd("sm_guns", CMD_Weapons, "Opens up menu with avalible weapons"); 62 | RegConsoleCmd("sm_weapons", CMD_Weapons, "Opens up menu with avalible weapons 2"); 63 | RegConsoleCmd("sm_menu", CMD_Weapons, "Opens up menu with avalible weapons 3"); 64 | RegConsoleCmd("sm_weapon", CMD_Weapons, "Opens up menu with avalible weapons 4"); 65 | RegConsoleCmd("sm_lobby", CMD_Lobby, "Teleports player to lobby"); 66 | 67 | //** CHALLANGE **// 68 | RegConsoleCmd("sm_challenge", CMD_Challenge, "Challenge other player/friend"); 69 | RegConsoleCmd("sm_challange", CMD_Challenge, "Challenge other player/friend"); 70 | RegConsoleCmd("sm_chal", CMD_Challenge, "Challenge other player/friend 2"); 71 | RegConsoleCmd("sm_c", CMD_Challenge, "Challenge other player/friend 3"); 72 | RegConsoleCmd("sm_duel", CMD_Challenge, "Challenge other player/friend 4"); 73 | RegConsoleCmd("sm_duels", CMD_Challenge, "Challenge other player/friend 4"); 74 | RegConsoleCmd("sm_accept", CMD_Accept, "Accept challange command"); 75 | RegConsoleCmd("sm_deny", CMD_Deny, "Deny challange command"); 76 | RegConsoleCmd("sm_stop", CMD_Deny, "Stop challange that your inside now"); 77 | RegConsoleCmd("sm_end", CMD_Deny, "Stop challange that your inside now 2"); 78 | RegConsoleCmd("sm_howmanyfuckingarenasareinthismap", CMD_Arenas, "Arena count"); 79 | 80 | //Dev 81 | RegConsoleCmd("sm_status", CMD_Status); 82 | 83 | //Command without ! and / 84 | AddCommandListener(CMD_Say, "say"); 85 | AddCommandListener(CMD_Say, "say_team"); 86 | 87 | RegAdminCmd("sm_spawn", CMD_Spawn, ADMFLAG_BAN); 88 | 89 | OnPluginStartFunc(); 90 | 91 | HookEvent("round_start", Event_RoundStart); 92 | HookEvent("round_poststart", Event_OnRoundPostStart); 93 | HookEvent("player_spawn", Event_OnPlayerSpawn); 94 | HookEvent("player_team", Event_OnPlayerTeam); 95 | HookEvent("player_death", Event_OnPlayerDeath, EventHookMode_Pre); 96 | HookEvent("player_team", Event_OnPlayerTeam2, EventHookMode_Pre); 97 | HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre); 98 | HookEvent("player_connect_full",Event_PlayerConnect); 99 | 100 | //Command listners 101 | AddCommandListener(BlockKill, "kill"); 102 | AddCommandListener(BlockKill, "explode"); 103 | AddCommandListener(Event_JoinTeam, "jointeam"); 104 | 105 | //Blood thing 106 | AddTempEntHook("World Decal", TE_OnWorldDecal); 107 | 108 | 109 | g_offsCollisionGroup = FindSendPropInfo("CBaseEntity", "m_CollisionGroup"); 110 | LoadTranslations("1v1DM.phrases"); 111 | 112 | } 113 | 114 | public Action CMD_Arenas(int client, int args) 115 | { 116 | ReplyToCommand(client, "[FastArena1337] There are %i fucking arenas ejziponken!", g_maxArenas); 117 | return Plugin_Handled; 118 | } 119 | 120 | public Action CMD_Lobby(int client, int args) 121 | { 122 | if(i_PlayerArena[client] != LOBBY) 123 | { 124 | if(!IsInRightTeam(client)) 125 | ChangeClientTeam(client, CS_TEAM_CT); 126 | 127 | if(!IsPlayerAlive(client)) 128 | CS_RespawnPlayer(client); 129 | 130 | if(i_PlayerArena[client] != LOBBY && i_PlayerArena[client] != -1) 131 | KillDamageTimer(i_PlayerArena[client]); 132 | 133 | 134 | int opponent = i_PlayerEnemy[client]; 135 | if(opponent > 0) 136 | { 137 | if(IsClientInGame(opponent) && IsInRightTeam(opponent)) 138 | { 139 | i_PrevEnemy[opponent] = -1; 140 | b_ArenaFree[i_PlayerArena[opponent]] = true; 141 | TeleportToLobby(opponent, true, true); 142 | } 143 | } 144 | 145 | 146 | TeleportToLobby(client, false); 147 | 148 | CMD_Deny(client, 0); 149 | 150 | g_PrimaryWeapon[client] = ""; 151 | g_SecondaryWeapon[client] = ""; 152 | b_FirstWeaponSelect[client] = true; 153 | b_HideMainWeaponMenu[client] = true; 154 | 155 | KillSearchTimer(client); 156 | 157 | ShowPrimaryWeaponMenu(client); 158 | } 159 | 160 | return Plugin_Handled; 161 | } 162 | 163 | public Action CMD_Status(int client, int args) 164 | { 165 | if(IsClientInGame(client)) 166 | { 167 | char waiting[10]; 168 | if(b_WaitingForEnemy[client]) 169 | waiting = "true"; 170 | else 171 | waiting = "false"; 172 | 173 | char search[10]; 174 | if(SearchTmr[client] == null) 175 | search = "off"; 176 | else 177 | search = "on"; 178 | 179 | int showPlayer = 0; 180 | if(i_PlayerEnemy[client] > 0) 181 | showPlayer = i_PlayerEnemy[client]; 182 | 183 | ReplyToCommand(client, "%sSTATUS: Waiting for enemy: %s | Enemy right now: %N | Arena: %i (LOBBY: %i) | Search tmr: %s", PREFIX, waiting, showPlayer, i_PlayerArena[client], LOBBY, search); 184 | 185 | } 186 | return Plugin_Handled; 187 | } 188 | 189 | 190 | public Action CMD_Say(int client, const char[] command, int argc) 191 | { 192 | if(client > 0) 193 | { 194 | char message[128]; 195 | GetCmdArgString(message, sizeof(message)); 196 | ReplaceString(message, sizeof(message), "\"", ""); 197 | 198 | //Guns 199 | if(StrEqual(message, "guns") || StrEqual(message, ".guns") ) 200 | { 201 | CMD_Weapons(client, 1); 202 | return Plugin_Handled; 203 | } 204 | 205 | //Lobby 206 | if(StrEqual(message, "lobby") || StrEqual(message, ".lobby") ) 207 | { 208 | CMD_Lobby(client, 1); 209 | return Plugin_Handled; 210 | } 211 | } 212 | 213 | return Plugin_Continue; 214 | } 215 | 216 | public Action CMD_Spawn(int client, int args) 217 | { 218 | 219 | char arena[10]; 220 | float org[3], ang[3]; 221 | GetCmdArg(1, arena, sizeof(arena)); 222 | //hud_message(client, arena); 223 | 224 | 225 | GetArenaSpawn(StringToInt(arena), GetClientTeam(client), org, ang); 226 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 227 | } 228 | 229 | public Action Event_OnPlayerTeam2(Handle event, const char[] name, bool dontBroadcast) 230 | { 231 | return (Plugin_Handled); 232 | } 233 | 234 | void hud_message(int client, char message[500]) 235 | { 236 | Format(message, sizeof(message), "%s\n%s", message, g_CustomRoundName[client]); 237 | 238 | int ent = !IsValidEntity(iTextEntity[client]) ? CreateEntityByName("game_text") : iTextEntity[client]; 239 | 240 | iTextEntity[client] = ent; 241 | 242 | DispatchKeyValue(ent, "channel", "1"); 243 | DispatchKeyValue(ent, "color", "255 255 255"); 244 | DispatchKeyValue(ent, "color2", "0 0 0"); 245 | DispatchKeyValue(ent, "effect", "0"); 246 | DispatchKeyValue(ent, "fxtime", "0.25"); 247 | DispatchKeyValue(ent, "holdtime", "3.0"); 248 | DispatchKeyValue(ent, "message", message); 249 | DispatchKeyValue(ent, "x", "0.10"); 250 | DispatchKeyValue(ent, "y", "0.155"); 251 | DispatchSpawn(ent); 252 | SetVariantString("!activator"); 253 | AcceptEntityInput(ent, "display", client); 254 | 255 | //CreateTimer(2.0, KillEntity, ent); 256 | } 257 | 258 | public Action BlockKill(int client, const char[] command, int args) 259 | { 260 | return Plugin_Handled; 261 | } 262 | 263 | public Action Event_JoinTeam(int client, const char[] command, int arg) 264 | { 265 | if(IsPlayerAlive(client)) 266 | return Plugin_Handled; 267 | else 268 | return Plugin_Continue; 269 | } 270 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Players.sp: -------------------------------------------------------------------------------- 1 | //DEBUGGER 2 | public Action OnPlayerRunCmd(int client, int &iButtons, int &iImpulse, float fVelocity[3], float fAngles[3], int &iWeapon) 3 | { 4 | char we[10]; 5 | if(b_WaitingForEnemy[client]) 6 | we = "true"; 7 | else 8 | we = "false"; 9 | 10 | int client2 = 0; 11 | if(i_PlayerEnemy[client] != -1) 12 | client2 = i_PlayerEnemy[client]; 13 | 14 | PrintHintText(client, "waiting: %s|arena: %i\n enemy: %N", we, i_PlayerArena[client], client2); 15 | 16 | return Plugin_Continue; 17 | } 18 | 19 | void Players_OnClientPutInServer(int client) 20 | { 21 | b_WaitingForEnemy[client] = false; 22 | b_FirstTeamJoin[client] = true; 23 | i_PrevArena[client] = -1; 24 | i_PlayerArena[client] = LOBBY; 25 | i_PlayerEnemy[client] = -1; 26 | } 27 | 28 | void Players_OnPlayerTeam(int client) 29 | { 30 | if(b_FirstTeamJoin[client]) 31 | { 32 | CreateTimer(0.2, FirstJoin, client); 33 | b_FirstTeamJoin[client] = false; 34 | } 35 | } 36 | 37 | void Players_OnClientDisconnect(int client) 38 | { 39 | //If the player is with someone in arena 40 | if(client > 0) 41 | { 42 | if(!b_WaitingForEnemy[client] && i_PlayerArena[client] != LOBBY && !IsFakeClient(client)) 43 | { 44 | 45 | int client2 = OnePlayerLeftEvent(client); 46 | if(client2 > 0){ 47 | if(IsClientInGame(client2)){ 48 | PrintToChat(client2, "%sYour enemy left the game! Finding new enemy", PREFIX); 49 | //PrintToConsole(client2, "ENEMY DISCONNECTED: %i(%N)", client, client); 50 | } 51 | } 52 | } 53 | } 54 | } 55 | 56 | int OnePlayerLeftEvent(int client) 57 | { 58 | if(client > 0) 59 | { 60 | //Find player with who he was in arena 61 | int client2 = i_PlayerEnemy[client]; 62 | 63 | if(client2 == -1) 64 | return -1; 65 | 66 | //Teleport the player to lobby 67 | TeleportToLobby(client2); 68 | b_WaitingForEnemy[client2] = true; 69 | 70 | //Set arena free 71 | b_ArenaFree[i_PlayerArena[client]] = true; 72 | 73 | return client2; 74 | } 75 | 76 | return -1; 77 | } 78 | 79 | public Action FirstJoin(Handle tmr, any client) 80 | { 81 | if(IsClientInGame(client)) 82 | { 83 | //Respawn player if he is dead 84 | if(!IsPlayerAlive(client)) 85 | CS_RespawnPlayer(client); 86 | 87 | //Teleport to lobby 88 | float org[3], ang[3]; 89 | GetArenaSpawn(LOBBY, GetClientTeam(client), org, ang); 90 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 91 | 92 | //Show weapon menu 93 | ShowPrimaryWeaponMenu(client); 94 | } 95 | 96 | return Plugin_Handled; 97 | } 98 | 99 | void Players_OnPlayerDeath(int client, int attacker) 100 | { 101 | if(IsClientInGame(client)) 102 | { 103 | //Teleport loser to lobby 104 | //CreateTimer(0.9, RespawnPlayer, client); 105 | CreateTimer(1.0, LobbyTeleport, client); 106 | } 107 | 108 | if(IsClientInGame(attacker)) 109 | { 110 | //Create timer to get new enemy for the winner 111 | CreateTimer(2.5, PlayerDeathNewEnemy, attacker); 112 | } 113 | 114 | } 115 | 116 | void TeleportToLobby(int client) 117 | { 118 | if(client > 0 && IsClientInGame(client)) 119 | { 120 | float org[3], ang[3]; 121 | GetArenaSpawn(LOBBY, GetClientTeam(client), org, ang); 122 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 123 | i_PlayerArena[client] = LOBBY; 124 | } 125 | } 126 | 127 | public Action RespawnPlayer(Handle tmr, any client) 128 | { 129 | if(IsClientInGame(client)) 130 | CS_RespawnPlayer(client); 131 | 132 | return Plugin_Handled; 133 | } 134 | 135 | public Action LobbyTeleport(Handle tmr, any client) 136 | { 137 | if(IsClientInGame(client)) 138 | { 139 | if(!IsPlayerAlive(client)) 140 | CS_RespawnPlayer(client); 141 | 142 | TeleportToLobby(client); 143 | b_WaitingForEnemy[client] = true; 144 | i_PlayerEnemy[client] = -1; 145 | } 146 | 147 | return Plugin_Handled; 148 | } 149 | 150 | public Action PlayerDeathNewEnemy(Handle tmr, any client) 151 | { 152 | if(IsClientInGame(client)) 153 | { 154 | //Remove him from his old arena (set arena free) 155 | b_ArenaFree[i_PlayerArena[client]] = true; 156 | i_PlayerEnemy[client] = -1; 157 | 158 | //Try to create their match 159 | int enemy = FindEnemy(client); 160 | PrintToConsole(client, "/PlayerDeathNewEnemy/ FOUND ENEMY: %i(%N)", enemy, enemy); 161 | if(enemy > 0 && !b_WaitingForEnemy[enemy] && i_PlayerArena[enemy] == LOBBY && !b_FirstWeaponSelect[enemy] && i_PlayerEnemy[client] == -1){ 162 | if(IsClientInGame(enemy)) 163 | { 164 | SetupMatch(client, enemy); 165 | PrintToConsole(client, "/PlayerDeathNewEnemy/ SETUPMATCH: %i(%N) | %i(%N)", client, client, enemy, enemy); 166 | } 167 | } else { 168 | b_WaitingForEnemy[client] = true; 169 | TeleportToLobby(client); 170 | } 171 | } 172 | 173 | return Plugin_Handled; 174 | } 175 | 176 | int FindEnemy(int player) 177 | { 178 | PrintToConsole(player, "--------------------------"); 179 | int clients[MAXPLAYERS + 1]; 180 | int clientCount; 181 | LoopAllPlayers(i) 182 | if (b_WaitingForEnemy[i] && i != player && i_PlayerArena[i] == LOBBY && i > 0 && !b_FirstWeaponSelect[i] && i_PlayerEnemy[i] == -1) 183 | clients[clientCount++] = i; 184 | 185 | int newclient = (clientCount == 0) ? -1 : clients[GetRandomInt(0, clientCount - 1)]; 186 | 187 | if(!b_WaitingForEnemy[newclient]) 188 | newclient = FindEnemy(player); 189 | 190 | b_WaitingForEnemy[newclient] = false; 191 | return newclient; 192 | } 193 | 194 | void SetupMatch(int client, int enemy, int arena = -1) 195 | { 196 | //If there is no arena, generate one 197 | if(arena == -1) 198 | arena = GetFreeArena(i_PrevArena[client]); 199 | 200 | PrintToConsole(client, "/SetupMatch/ FOUND ARENA %i", arena); 201 | 202 | if(arena > 0) 203 | { 204 | i_PlayerEnemy[client] = enemy; 205 | i_PlayerEnemy[enemy] = client; 206 | 207 | //Check if player is still avalible 208 | //if(b_WaitingForEnemy[enemy] && i_PlayerArena[enemy] == LOBBY) 209 | //{ 210 | 211 | //Set arena as not free (dont spawn others there) 212 | b_ArenaFree[arena] = false; 213 | i_PlayerArena[client] = arena; 214 | i_PlayerArena[enemy] = arena; 215 | 216 | i_PrevArena[client] = arena; 217 | i_PrevArena[enemy] = arena; 218 | 219 | b_WaitingForEnemy[client] = false; 220 | b_WaitingForEnemy[enemy] = false; 221 | 222 | //Setting up players 223 | SetupPlayer(client, enemy, arena, CS_TEAM_T); 224 | SetupPlayer(enemy, client, arena, CS_TEAM_CT); 225 | 226 | //Create backup timer to check for damage (if no damage, create new duel) 227 | ArenaDamageTmr[arena] = CreateTimer(25.0, CheckForDamage, arena); 228 | 229 | //} else { 230 | // 231 | // PrintToConsole(client, "/SetupMatch/ SORRY, PLAYER IS NOT AVALIBLE ANYMORE! :("); 232 | // 233 | //} 234 | 235 | } else { 236 | 237 | PrintToChat(client, "Sorry, there was error, arena was not found!"); 238 | PrintToConsole(client, "/SetupMatch/ Failed to find a free arena!"); 239 | } 240 | } 241 | 242 | public Action CheckForDamage(Handle timer, any arena) 243 | { 244 | LoopAllPlayers(i){ 245 | if(i_PlayerArena[i] == arena){ 246 | TeleportToLobby(i); 247 | b_WaitingForEnemy[i] = true; 248 | CreateTimer(0.5, SearchForNewEnemy, i); 249 | } 250 | } 251 | 252 | b_ArenaFree[arena] = true; 253 | 254 | return Plugin_Handled; 255 | } 256 | 257 | public Action SearchForNewEnemy(Handle tmr, any client) 258 | { 259 | //Create their match 260 | if(b_WaitingForEnemy[client] && i_PlayerArena[client] == LOBBY) 261 | { 262 | int enemy = FindEnemy(client); 263 | if(enemy > 0 && !b_WaitingForEnemy[enemy] && i_PlayerArena[enemy] == LOBBY && !b_FirstWeaponSelect[enemy] && i_PlayerEnemy[client] == -1) 264 | if(IsClientInGame(enemy)) 265 | SetupMatch(client, enemy); 266 | } 267 | 268 | return Plugin_Handled; 269 | } 270 | 271 | void SetupPlayer(int client, int client2, int arena, int team) 272 | { 273 | PrintToConsole(client, "/SetupPlayer/ PLAYER SETUP changeteams"); 274 | 275 | //Set clients team 276 | CS_SwitchTeam(client, team); 277 | 278 | PrintToConsole(client, "/SetupPlayer/ TELEPORT TO ARENA"); 279 | 280 | //Teleport to arena 281 | float org[3], ang[3]; 282 | GetArenaSpawn(arena, team, org, ang); 283 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 284 | 285 | //Give player his own weapons 286 | int weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY); 287 | if(weapon > 0) { 288 | RemovePlayerItem(client, weapon); 289 | RemoveEdict(weapon); 290 | } 291 | GivePlayerItem(client, g_PrimaryWeapon[client]); 292 | int weapon2 = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY); 293 | if(weapon2 > 0) { 294 | RemovePlayerItem(client, weapon2); 295 | RemoveEdict(weapon2); 296 | } 297 | GivePlayerItem(client, g_SecondaryWeapon[client]); 298 | 299 | //For safety set health and armor to 100 300 | SetEntityHealth(client, 100); 301 | SetEntProp(client, Prop_Send, "m_ArmorValue", 100, 10); 302 | 303 | PrintToConsole(client, "/SetupPlayer/ CREATE SHOW USERNAME SHIT"); 304 | //Print in chat, vs who is he playing 305 | DataPack pack; 306 | CreateDataTimer(0.1, ShowUsername, pack); 307 | pack.WriteCell(client); 308 | pack.WriteCell(client2); 309 | //CreateTimer(0.1, ShowUsername, client); 310 | //PrintToChat(client, "%sTu esi arēnā ar %N (ARĒNA: %i)", PREFIX, client2, arena); 311 | } 312 | 313 | public Action ShowUsername(Handle timer, Handle pack) 314 | { 315 | ResetPack(pack); 316 | int client = ReadPackCell(pack); 317 | int client2 = ReadPackCell(pack); 318 | char username[128]; 319 | GetClientName(client2, username, sizeof(username)); 320 | hud_message(client, username); 321 | 322 | return Plugin_Handled; 323 | } 324 | 325 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_WeaponMenu.sp: -------------------------------------------------------------------------------- 1 | void WeaponMenu_OnClientPutInServer(int client){ 2 | b_FirstWeaponSelect[client] = true; 3 | g_PrimaryWeapon[client] = ""; 4 | g_SecondaryWeapon[client] = ""; 5 | b_HideMainWeaponMenu[client] = false; 6 | } 7 | 8 | void WeaponMenu_MapStart() 9 | { 10 | if(g_Rifles == null) 11 | { 12 | g_Rifles = new ArrayList(40); 13 | g_Pistols = new ArrayList(40); 14 | } 15 | else 16 | { 17 | g_Rifles.Clear(); 18 | g_Pistols.Clear(); 19 | } 20 | 21 | //g_numPistols = 0; 22 | //g_numRifles = 0; 23 | 24 | char configFile[PLATFORM_MAX_PATH]; 25 | BuildPath(Path_SM, configFile, sizeof(configFile), "configs/1v1DM/weapons.cfg"); 26 | 27 | 28 | //Check if file exists 29 | if (!FileExists(configFile)) { 30 | LogError("The weapon config file does not exist: %s", configFile); 31 | return; 32 | } 33 | 34 | //Go thru file 35 | KeyValues kv = new KeyValues("Weapons"); 36 | kv.ImportFromFile(configFile); 37 | 38 | // Parse the rifles section 39 | if (!KvJumpToKey(kv, "Rifles")) { 40 | LogError("The weapon config file did not contain a \"Rifles\" section: %s", configFile); 41 | delete kv; 42 | return; 43 | } 44 | if (!kv.GotoFirstSubKey()) { 45 | LogError("No rifles were found."); 46 | } 47 | do { 48 | char weapon[50], name[50]; 49 | kv.GetSectionName(weapon, sizeof(weapon)); 50 | kv.GetString("name", name, sizeof(name)); 51 | g_Rifles.PushString(weapon); 52 | g_Rifles.PushString(name); 53 | //PrintToServer("%s", name); 54 | } while (kv.GotoNextKey()); 55 | kv.Rewind(); 56 | 57 | 58 | // Parse the pistols section 59 | if (!KvJumpToKey(kv, "Pistols")) { 60 | LogError("The weapon config file did not contain a \"Pistols\" section: %s", configFile); 61 | delete kv; 62 | return; 63 | } 64 | 65 | if (!kv.GotoFirstSubKey()) { 66 | LogError("No pistols were found."); 67 | } 68 | do { 69 | char weapon[50], name[50]; 70 | kv.GetSectionName(weapon, sizeof(weapon)); 71 | kv.GetString("name", name, sizeof(name)); 72 | PushArrayString(g_Pistols, weapon); 73 | PushArrayString(g_Pistols, name); 74 | } while (kv.GotoNextKey()); 75 | 76 | delete kv; 77 | 78 | //PrintToServer("RIFLES: %i | PISTOLS: %i", g_Rifles.Length, g_Pistols.Length); 79 | } 80 | 81 | public Action CMD_Weapons(int client, int args) 82 | { 83 | if(StrContains(g_PrimaryWeapon[client], "weapon_") == -1) 84 | ShowPrimaryWeaponMenu(client); 85 | else 86 | ShowMainMenu(client); 87 | 88 | return Plugin_Handled; 89 | } 90 | 91 | void ShowMainMenu(int client) 92 | { 93 | SetGlobalTransTarget(client); 94 | Menu menu = new Menu(MenuHandlers_MainMenu); 95 | char Weapon_preferences[64]; 96 | Format(Weapon_preferences,sizeof(Weapon_preferences),"%T","Weapon preferences",client); 97 | menu.SetTitle(Weapon_preferences); 98 | 99 | //Primary weapon 100 | char AddItemChar[50], WeaponName[50]; 101 | 102 | if(g_EnableRiflesCvar.IntValue == 1) 103 | { 104 | int rifleID = g_Rifles.FindString(g_PrimaryWeapon[client]); 105 | g_Rifles.GetString(rifleID + 1, WeaponName, sizeof(WeaponName)); 106 | Format(AddItemChar, 50, "%T","Rifle:",client,WeaponName); 107 | menu.AddItem("OpenRifleMenu", AddItemChar); 108 | } 109 | 110 | if(g_EnablePistolsCvar.IntValue == 1) 111 | { 112 | //Secondary weapon 113 | int pistolID = g_Pistols.FindString(g_SecondaryWeapon[client]); 114 | g_Pistols.GetString(pistolID + 1, WeaponName, sizeof(WeaponName)); 115 | Format(AddItemChar, 50, "%T","Pistol:",client,WeaponName); 116 | menu.AddItem("OpenPistolMenu", AddItemChar); 117 | } 118 | 119 | //Kill sound 120 | if(b_ClientSoundEnabled[client]) 121 | Format(AddItemChar, 50, "%T","Kill sound: On",client); 122 | else 123 | Format(AddItemChar, 50, "%T","Kill sound: Off",client); 124 | menu.AddItem("ChangeSound", AddItemChar); 125 | 126 | 127 | //Here will go natives?! 128 | //But for now manual AWP DUEL added 129 | //because Im too lazy to create natives 130 | 131 | if(g_AWPDuelsCvar.IntValue == 1) 132 | { 133 | if(b_AwpDuelEnabled[client]) 134 | Format(AddItemChar, 50, "%T","AWP Duels: On",client); 135 | else 136 | Format(AddItemChar, 50, "%T","AWP Duels: Off",client); 137 | menu.AddItem("AWPDuel", AddItemChar); 138 | } 139 | 140 | if(g_FlashbangDuelsCvar.IntValue == 1) 141 | { 142 | if(b_FlashbangDuelEnabled[client]) 143 | Format(AddItemChar, 50, "%T","Flashbang Duels: On",client); 144 | else 145 | Format(AddItemChar, 50, "%T","Flashbang Duels: Off",client); 146 | menu.AddItem("FlashbangDuel", AddItemChar); 147 | } 148 | 149 | //Display 150 | menu.ExitButton = true; 151 | menu.Display(client, 0); 152 | 153 | } 154 | 155 | public int MenuHandlers_MainMenu(Menu menu, MenuAction action, int client, int item) 156 | { 157 | switch(action) 158 | { 159 | case MenuAction_Select: 160 | { 161 | if(IsClientInGame(client) && IsPlayerAlive(client)) 162 | { 163 | 164 | char info[32]; 165 | GetMenuItem(menu, item, info, sizeof(info)); 166 | 167 | if(StrEqual(info, "OpenRifleMenu")) 168 | ShowPrimaryWeaponMenu(client); 169 | 170 | else if(StrEqual(info, "OpenPistolMenu")) 171 | ShowSecondaryWeaponMenu(client); 172 | 173 | else if(StrEqual(info, "ChangeSound")) 174 | ChangeClientSound(client); 175 | 176 | else if(StrEqual(info, "AWPDuel")) 177 | ChangeAWPDuel(client); 178 | 179 | else if(StrEqual(info, "FlashbangDuel")) 180 | ChangeFlashbangDuel(client); 181 | } 182 | } 183 | case MenuAction_End: 184 | delete menu; 185 | } 186 | } 187 | 188 | void ShowPrimaryWeaponMenu(int client) 189 | { 190 | if(g_EnableRiflesCvar.IntValue == 1) 191 | { 192 | SetGlobalTransTarget(client); 193 | Menu menu = new Menu(MenuHandlers_PrimaryWeapon); 194 | char Primary_weapon[64]; 195 | Format(Primary_weapon,sizeof(Primary_weapon),"%T","Primary weapon",client); 196 | menu.SetTitle(Primary_weapon); 197 | 198 | for (int i = 0; i < g_Rifles.Length; i+=2) 199 | { 200 | char weapon[60], weaponName[60]; 201 | g_Rifles.GetString(i, weapon, sizeof(weapon)); 202 | g_Rifles.GetString(i + 1, weaponName, sizeof(weaponName)); 203 | menu.AddItem(weapon, weaponName); 204 | } 205 | 206 | if(b_FirstWeaponSelect[client]) 207 | menu.ExitButton = false; 208 | else 209 | menu.ExitButton = true; 210 | menu.Display(client, 0); 211 | } else { 212 | ShowSecondaryWeaponMenu(client); 213 | } 214 | } 215 | 216 | void ShowSecondaryWeaponMenu(int client) 217 | { 218 | if(g_EnablePistolsCvar.IntValue == 1) 219 | { 220 | SetGlobalTransTarget(client); 221 | Menu menu = new Menu(MenuHandlers_SecondaryWeapon); 222 | char Secondary_Weapon[64]; 223 | Format(Secondary_Weapon,sizeof(Secondary_Weapon),"%T","Secondary Weapon",client); 224 | menu.SetTitle(Secondary_Weapon); 225 | 226 | for (int i = 0; i < g_Pistols.Length; i+=2) 227 | { 228 | char weapon[60], weaponName[60]; 229 | g_Pistols.GetString(i, weapon, sizeof(weapon)); 230 | g_Pistols.GetString(i + 1, weaponName, sizeof(weaponName)); 231 | menu.AddItem(weapon, weaponName); 232 | } 233 | 234 | if(b_FirstWeaponSelect[client]) 235 | menu.ExitButton = false; 236 | else 237 | menu.ExitButton = true; 238 | 239 | menu.Display(client, 0); 240 | } 241 | } 242 | 243 | public int MenuHandlers_PrimaryWeapon(Menu menu, MenuAction action, int client, int item) 244 | { 245 | switch(action) 246 | { 247 | case MenuAction_Select: 248 | { 249 | if(IsClientInGame(client) && IsPlayerAlive(client)) 250 | { 251 | 252 | char info[32]; 253 | GetMenuItem(menu, item, info, sizeof(info)); 254 | 255 | if(i_PlayerArena[client] == LOBBY) 256 | { 257 | int weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY); 258 | if(weapon > 0 && IsValidEntity(weapon)) { 259 | RemovePlayerItem(client, weapon); 260 | RemoveEdict(weapon); 261 | } 262 | 263 | GivePlayerItem(client, info); 264 | } 265 | 266 | 267 | //Save clients weapon choice 268 | g_PrimaryWeapon[client] = info; 269 | SetClientCookie(client, g_Rifle, info); 270 | 271 | if(StrContains(g_SecondaryWeapon[client], "weapon_") == -1) 272 | ShowSecondaryWeaponMenu(client); 273 | else 274 | ShowMainMenu(client); 275 | 276 | } 277 | } 278 | case MenuAction_End: 279 | delete menu; 280 | } 281 | } 282 | 283 | public int MenuHandlers_SecondaryWeapon(Menu menu, MenuAction action, int client, int item) 284 | { 285 | switch(action) 286 | { 287 | case MenuAction_Select: 288 | { 289 | if(IsClientInGame(client) && IsPlayerAlive(client)) 290 | { 291 | 292 | char info[32]; 293 | GetMenuItem(menu, item, info, sizeof(info)); 294 | 295 | if(i_PlayerArena[client] == LOBBY) 296 | { 297 | int weapon = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY); 298 | if(weapon > 0 && IsValidEntity(weapon)) { 299 | RemovePlayerItem(client, weapon); 300 | RemoveEdict(weapon); 301 | } 302 | 303 | GivePlayerItem(client, info); 304 | } 305 | 306 | //Save clients weapon choice 307 | g_SecondaryWeapon[client] = info; 308 | SetClientCookie(client, g_Pistol, info); 309 | 310 | if(b_FirstWeaponSelect[client]) 311 | { 312 | b_FirstWeaponSelect[client] = false; 313 | 314 | //Finished picking weapons 315 | b_WaitingForEnemy[client] = true; 316 | 317 | //Check if there is free enemy 318 | KillSearchTimer(client); 319 | SearchTmr[client] = CreateTimer(0.1, PlayerKilled, client, TIMER_FLAG_NO_MAPCHANGE); 320 | 321 | } 322 | 323 | if(!b_HideMainWeaponMenu[client]) 324 | ShowMainMenu(client); 325 | } 326 | } 327 | case MenuAction_End: 328 | delete menu; 329 | } 330 | } 331 | 332 | void GivePlayerHisWeapons(int client) 333 | { 334 | 335 | int weapon = GetPlayerWeaponSlot(client, CS_SLOT_PRIMARY); 336 | if(weapon > 0 && IsValidEntity(weapon)) { 337 | RemovePlayerItem(client, weapon); 338 | RemoveEdict(weapon); 339 | } 340 | if(!StrEqual(g_PrimaryWeapon[client], "") && g_EnableRiflesCvar.IntValue == 1) 341 | GivePlayerItem(client, g_PrimaryWeapon[client]); 342 | 343 | int weapon2 = GetPlayerWeaponSlot(client, CS_SLOT_SECONDARY); 344 | if(weapon2 > 0 && IsValidEntity(weapon2)) { 345 | RemovePlayerItem(client, weapon2); 346 | RemoveEdict(weapon2); 347 | } 348 | if(!StrEqual(g_SecondaryWeapon[client], "") && g_EnablePistolsCvar.IntValue == 1) 349 | GivePlayerItem(client, g_SecondaryWeapon[client]); 350 | 351 | 352 | int weapon3 = GetPlayerWeaponSlot(client, CS_SLOT_KNIFE); 353 | if(weapon3 > 0 && IsValidEntity(weapon3)) { 354 | RemovePlayerItem(client, weapon3); 355 | RemoveEdict(weapon3); 356 | } 357 | GivePlayerItem(client, "weapon_knife"); 358 | } 359 | -------------------------------------------------------------------------------- /addons/sourcemod/scripting/1v1dm/1v1_Players2.sp: -------------------------------------------------------------------------------- 1 | void Players_OnClientPutInServer(int client) 2 | { 3 | //Player default settings 4 | b_WaitingForEnemy[client] = false; 5 | i_PlayerArena[client] = LOBBY; 6 | i_PlayerEnemy[client] = -1; 7 | 8 | //Timers 9 | KillSearchTimer(client); 10 | 11 | //Arena thing settings 12 | i_PrevArena[client] = -1; 13 | iTextEntity[client] = -1; 14 | 15 | //LogMessage("%N is connecting to server", client); 16 | 17 | } 18 | 19 | //**####################** 20 | //~~~ PLAYER DISCONNECT ~~ 21 | //**####################** 22 | void Players_OnClientDisconnect(int client) 23 | { 24 | KillSearchTimer(client); 25 | 26 | //Check if player is playing and disconnects 27 | if(i_PlayerArena[client] != LOBBY) 28 | { 29 | //Kill damage timer, because already ingame 30 | KillDamageTimer(i_PlayerArena[client]); 31 | } 32 | 33 | // 34 | if(iTextEntity[client] && IsValidEntity(iTextEntity[client]) && iTextEntity[client] > 0) 35 | AcceptEntityInput(iTextEntity[client], "Kill"); 36 | 37 | //Print chat message 38 | int opponent = i_PlayerEnemy[client]; 39 | if(opponent > 0) 40 | { 41 | if(IsClientInGame(opponent) && IsInRightTeam(opponent) && i_PlayerEnemy[opponent] == client) 42 | { 43 | 44 | i_PrevEnemy[opponent] = -1; 45 | 46 | b_ArenaFree[i_PlayerArena[opponent]] = true; 47 | 48 | //Teleport to lobby, because enemy left 49 | TeleportToLobby(opponent, true, true); 50 | } 51 | } 52 | } 53 | 54 | //**####################** 55 | //~~~ PLAYER DEATH ~~ 56 | //**####################** 57 | void Players_OnPlayerDeath(int client, int attacker) 58 | { 59 | 60 | //Someone dies from world?! 61 | if(attacker == 0) { 62 | int opponent = i_PlayerEnemy[client]; 63 | if(opponent > 0) 64 | if(IsClientInGame(opponent) && IsInRightTeam(opponent)) 65 | { 66 | KillSearchTimer(opponent); 67 | SearchTmr[opponent] = CreateTimer(g_DuelDelayCvar.FloatValue, PlayerKilled, opponent, TIMER_FLAG_NO_MAPCHANGE); 68 | } 69 | } 70 | 71 | //Keep them arena for small amount of time, so they know they killed someone :D 72 | 73 | if(IsClientInGame(client)) 74 | CreateTimer(0.6, PlayerGotKilled, client); 75 | 76 | if(attacker > 0) 77 | if(IsClientInGame(attacker) && IsInRightTeam(attacker)) 78 | { 79 | KillSearchTimer(attacker); 80 | SearchTmr[attacker] = CreateTimer(g_DuelDelayCvar.FloatValue, PlayerKilled, attacker, TIMER_FLAG_NO_MAPCHANGE); 81 | } 82 | } 83 | 84 | //---------------------------- 85 | //Player who got killed timer 86 | //---------------------------- 87 | public Action PlayerGotKilled(Handle tmr, any client) 88 | { 89 | 90 | if(IsClientInGame(client) && IsInRightTeam(client) && iChallengeEnemy[client] != -1) 91 | TeleportToLobby(client, true, true); 92 | 93 | else if(IsClientInGame(client) && IsInRightTeam(client) && iChallengeEnemy[client] == -1) 94 | TeleportToLobby(client, true); 95 | 96 | return Plugin_Handled; 97 | } 98 | 99 | //------------------------------ 100 | //Player who killed other player 101 | //------------------------------ 102 | public Action PlayerKilled(Handle tmr, any client) 103 | { 104 | KillSearchTimer(client); 105 | 106 | if(IsClientInGame(client) && IsInRightTeam(client)) 107 | { 108 | 109 | //Set his arena free 110 | if(i_PlayerArena[client] != LOBBY) 111 | b_ArenaFree[i_PlayerArena[client]] = true; 112 | 113 | //He wants to find opponent (someone from lobby) 114 | int opponent = FindOpponent(client); 115 | if(opponent > -1){ 116 | 117 | //Setup match 118 | SetupMatch(client, opponent); 119 | 120 | } else { 121 | //No opponent found 122 | if(i_PlayerArena[client] != LOBBY) 123 | TeleportToLobby(client, true); 124 | 125 | //Make him search for enemy, if he can find one 126 | SearchTmr[client] = CreateTimer(1.0, PlayerKilled, client, TIMER_FLAG_NO_MAPCHANGE); 127 | } 128 | } 129 | 130 | return Plugin_Handled; 131 | } 132 | 133 | //**####################** 134 | //~~~ STOCK FUNCTIONS ~~ 135 | //**####################** 136 | 137 | void TeleportToLobby(int client, bool searchEnable, bool ImSearching = false) 138 | { 139 | if(client > 0) 140 | { 141 | if(IsClientInGame(client) && IsInRightTeam(client)) 142 | { 143 | 144 | //Set that enemys opponent to -1, because we went to lobby 145 | int opponent = i_PlayerEnemy[client]; 146 | if(opponent > 0) 147 | if(IsClientInGame(opponent) && IsInRightTeam(opponent) && i_PlayerEnemy[opponent] == client) 148 | i_PlayerEnemy[opponent] = -1; 149 | 150 | 151 | //Check if player is dead, respawn 152 | if(!IsPlayerAlive(client)) 153 | CS_RespawnPlayer(client); 154 | 155 | float org[3], ang[3]; 156 | GetArenaSpawn(LOBBY, GetClientTeam(client), org, ang); 157 | TeleportEntitySafe(client, org, ang, NULL_VECTOR); 158 | i_PlayerArena[client] = LOBBY; 159 | i_PlayerEnemy[client] = -1; 160 | 161 | //Make 162 | SetEntData(client, g_offsCollisionGroup, 2, 4, true); 163 | 164 | if(searchEnable) 165 | b_WaitingForEnemy[client] = true; 166 | else 167 | b_WaitingForEnemy[client] = false; 168 | 169 | if(ImSearching && SearchTmr[client] == null) 170 | { 171 | KillSearchTimer(client); 172 | SearchTmr[client] = CreateTimer(0.1, PlayerKilled, client, TIMER_FLAG_NO_MAPCHANGE); 173 | } 174 | 175 | //Set entity as ghost if in lobby 176 | SetEntProp(client, Prop_Send, "m_bNightVisionOn", 1); 177 | 178 | } 179 | } 180 | } 181 | 182 | int FindOpponent(int client) 183 | { 184 | 185 | int enemy = iChallengeEnemy[client]; 186 | if(enemy > 0) 187 | { 188 | if(i_PlayerArena[enemy] == LOBBY && !b_FirstWeaponSelect[enemy] && i_PlayerEnemy[enemy] == -1 && b_WaitingForEnemy[enemy]) 189 | { 190 | b_WaitingForEnemy[client] = false; 191 | b_WaitingForEnemy[enemy] = false; 192 | i_PlayerEnemy[enemy] = client; 193 | i_PlayerEnemy[client] = enemy; 194 | return enemy; 195 | } 196 | else 197 | return -1; 198 | } 199 | 200 | int opponent = -1; 201 | 202 | //Check if there is any opponent avalibe without last one 203 | int AllPlayers2[MAXPLAYERS + 1], count2; 204 | LoopAllPlayers(i) 205 | { 206 | //If the player fits requirements (Is in lobby, has selected weapons, has no opponent, and is waiting for one) 207 | if(i != client && i_PlayerArena[i] == LOBBY && !b_isAFK[i] && !b_FirstWeaponSelect[i] && i_PlayerEnemy[i] == -1 && b_WaitingForEnemy[i] && i_PrevEnemy[client] != i && iChallengeEnemy[i] == -1) 208 | AllPlayers2[count2++] = i; 209 | } 210 | int opponent2 = (count2 == 0) ? -1 : AllPlayers2[GetRandomInt(0, count2 - 1)]; 211 | 212 | if(opponent2 == -1) 213 | { 214 | 215 | //If there is no one avalible, try to generate with last enemy also 216 | int AllPlayers[MAXPLAYERS + 1], count; 217 | LoopAllPlayers(i) 218 | { 219 | //If the player fits requirements (Is in lobby, has selected weapons, has no opponent, and is waiting for one and is not afk) 220 | if(i != client && i_PlayerArena[i] == LOBBY && !b_isAFK[i] && !b_FirstWeaponSelect[i] && i_PlayerEnemy[i] == -1 && b_WaitingForEnemy[i] && iChallengeEnemy[i] == -1) 221 | AllPlayers[count++] = i; 222 | } 223 | 224 | 225 | //Get one random player from 'AllPlayers' 226 | opponent = (count == 0) ? -1 : AllPlayers[GetRandomInt(0, count - 1)]; 227 | 228 | } else { 229 | 230 | opponent = opponent2; 231 | } 232 | 233 | //Lets check if that player is still avalible 234 | if(opponent > 0) 235 | { 236 | if(b_WaitingForEnemy[opponent] && i_PlayerEnemy[opponent] == -1 && i_PlayerArena[opponent] == LOBBY && iChallengeEnemy[opponent] == -1 && !b_isAFK[opponent]){ 237 | 238 | //Set the player not avalible anymore 239 | b_WaitingForEnemy[client] = false; 240 | b_WaitingForEnemy[opponent] = false; 241 | i_PlayerEnemy[opponent] = client; 242 | i_PlayerEnemy[client] = opponent; 243 | 244 | return opponent; 245 | } 246 | } 247 | 248 | return -1; 249 | } 250 | 251 | void SetupMatch(int client, int enemy) 252 | { 253 | //Check if both players are still ingame (because of timer bellow) 254 | if(IsClientInGame(client) && IsClientInGame(enemy) && IsInRightTeam(client) && IsInRightTeam(enemy)) 255 | { 256 | 257 | //Generate free arena, if it didn't find any free arena, try again every 0.1 second 258 | int arena = GetFreeArena(i_PrevArena[client]); 259 | 260 | if(arena == -1) 261 | { 262 | DataPack pack; 263 | CreateDataTimer(0.1, TrySetupMatchAgain, pack); 264 | pack.WriteCell(client); 265 | pack.WriteCell(enemy); 266 | 267 | //debug 268 | int count = 0; 269 | for (int i = 1; i <= g_maxArenas; i++){ 270 | if(b_ArenaFree[i] && i != LOBBY){ 271 | count++; 272 | } 273 | } 274 | 275 | } else if(arena > 0) { 276 | 277 | //Stop search timers if one of them has one 278 | KillSearchTimer(client); 279 | KillSearchTimer(enemy); 280 | 281 | //Make the arena not free and set variables 282 | b_ArenaFree[arena] = false; 283 | i_PlayerArena[client] = arena; 284 | i_PlayerArena[enemy] = arena; 285 | i_PrevArena[client] = arena; 286 | i_PrevArena[enemy] = arena; 287 | i_PrevEnemy[client] = enemy; 288 | i_PrevEnemy[enemy] = client; 289 | i_DamageGiven[client] = 0; 290 | i_DamageGiven[enemy] = 0; 291 | g_CustomRoundName[client] = ""; 292 | g_CustomRoundName[enemy] = ""; 293 | 294 | //Count how many custom duels are enabled 295 | int customDuels = 0; 296 | ArrayList customDuelsArray = new ArrayList(); 297 | if(b_AwpDuelEnabled[client] && b_AwpDuelEnabled[enemy] && g_AWPDuelsCvar.IntValue == 1){ 298 | customDuels++; 299 | customDuelsArray.PushString("awpDuel"); 300 | } 301 | if(b_FlashbangDuelEnabled[client] && b_FlashbangDuelEnabled[enemy] && g_FlashbangDuelsCvar.IntValue == 1){ 302 | customDuels++; 303 | customDuelsArray.PushString("FlashbangDuel"); 304 | } 305 | 306 | //Make 50/50 to have custom round if both of them have enabled any 307 | if(customDuels != 0 && GetRandomInt(1, 100) <= g_CustomDuelChanceCvar.IntValue) 308 | { 309 | //Generate one of enabled duels 310 | int randomDuel = GetRandomInt(0, customDuelsArray.Length - 1); 311 | char randomNames[50]; 312 | customDuelsArray.GetString(randomDuel, randomNames, sizeof(randomNames)); 313 | //AWP duel setup 314 | if(StrEqual(randomNames, "awp")){ 315 | g_CustomRoundName[client] = "AWP Duel"; 316 | g_CustomRoundName[enemy] = "AWP Duel"; 317 | SetupPlayer(client, enemy, arena, CS_TEAM_T, false); 318 | SetupPlayer(enemy, client, arena, CS_TEAM_CT, false); 319 | GiveAWPDuelWeapons(client); 320 | GiveAWPDuelWeapons(enemy); 321 | } 322 | //Flashbang duel setup 323 | else if(StrEqual(randomNames, "Fla")) 324 | { 325 | g_CustomRoundName[client] = "Flashbang Duel"; 326 | g_CustomRoundName[enemy] = "Flashbang Duel"; 327 | SetupPlayer(client, enemy, arena, CS_TEAM_T); 328 | SetupPlayer(enemy, client, arena, CS_TEAM_CT); 329 | GiveFlashbangs(client); 330 | GiveFlashbangs(enemy); 331 | } 332 | 333 | 334 | } else { 335 | 336 | //Setting up players 337 | SetupPlayer(client, enemy, arena, CS_TEAM_T); 338 | SetupPlayer(enemy, client, arena, CS_TEAM_CT); 339 | 340 | } 341 | 342 | delete customDuelsArray; 343 | 344 | //Create new duel if there is no damage in 25 seconds 345 | ArenaDamageTmr[arena] = CreateTimer(g_NoDamageCvar.FloatValue, ArenaDamageTimer, arena, TIMER_FLAG_NO_MAPCHANGE); 346 | } 347 | } 348 | } 349 | 350 | public Action TrySetupMatchAgain(Handle timer, Handle pack) 351 | { 352 | ResetPack(pack); 353 | int client = ReadPackCell(pack); 354 | int enemy = ReadPackCell(pack); 355 | SetupMatch(client, enemy); 356 | 357 | return Plugin_Handled; 358 | } 359 | 360 | void KillSearchTimer(int client) 361 | { 362 | if (SearchTmr[client] != null) 363 | { 364 | KillTimer(SearchTmr[client]); 365 | SearchTmr[client] = null; 366 | } 367 | } 368 | 369 | void KillDamageTimer(int arena) 370 | { 371 | if (ArenaDamageTmr[arena] != null) 372 | { 373 | KillTimer(ArenaDamageTmr[arena]); 374 | ArenaDamageTmr[arena] = null; 375 | } 376 | } 377 | 378 | void SetupPlayer(int client, int opponent, int arena, int team, int giveWeapons = true) 379 | { 380 | 381 | //Teleport to arena 382 | TeleportToArena(client, team, arena); 383 | 384 | //Remove his flash 385 | SetEntPropFloat(client, Prop_Send, "m_flFlashMaxAlpha", 0.0); 386 | 387 | //Give right weapons 388 | if(giveWeapons){ 389 | GivePlayerHisWeapons(client); 390 | RemoveGrenade(client); 391 | } 392 | 393 | //For safety reset health 394 | SetEntityHealth(client, 100); 395 | 396 | //Armor 397 | if(g_GiveArmorCvar.IntValue == 1) 398 | SetEntProp(client, Prop_Send, "m_ArmorValue", 100, 10); 399 | else 400 | SetEntProp(client, Prop_Send, "m_ArmorValue", 0, 10); 401 | 402 | //Helmet 403 | if(g_GiveHelmetCvar.IntValue == 1) 404 | SetEntProp(client, Prop_Send, "m_bHasHelmet", 1); 405 | else 406 | SetEntProp(client, Prop_Send, "m_bHasHelmet", 0); 407 | 408 | 409 | if(g_ShowUsernameCvar.IntValue == 1) 410 | { 411 | char username[500]; 412 | GetClientName(opponent, username, sizeof(username)); 413 | hud_message(client, username); 414 | } 415 | 416 | //AFK manager, to check if anyone is afk 417 | AFK_MatchStarted(client, opponent); 418 | } 419 | 420 | 421 | void TeleportToArena(int client, int team, int arena) 422 | { 423 | float org[3], ang[3], vec[3]; 424 | GetArenaSpawn(arena, team, org, ang); 425 | TeleportEntitySafe(client, org, ang, vec); 426 | SetEntData(client, g_offsCollisionGroup, 5, 4, true); 427 | 428 | //Remove lobby effect 429 | SetEntProp(client, Prop_Send, "m_bNightVisionOn", 0); 430 | } 431 | 432 | public Action ArenaDamageTimer(Handle timer, any arena) 433 | { 434 | 435 | //Set timer to null 436 | ArenaDamageTmr[arena] = null; 437 | 438 | //Get both players who are playing in that arena 439 | int player = -1, player2 = -1; 440 | LoopAllPlayers(i) 441 | { 442 | if(i_PlayerArena[i] == arena) 443 | { 444 | if(player == -1) 445 | player = i; 446 | else 447 | player2 = i; 448 | } 449 | } 450 | 451 | //One player teleport to lobby, one player searches for new enemy 452 | int random = GetRandomInt(1, 2); 453 | 454 | if(random == 1) 455 | { 456 | TeleportToLobby(player2, true); 457 | if(player > 0) 458 | { 459 | KillSearchTimer(player); 460 | SearchTmr[player] = CreateTimer(0.1, PlayerKilled, player, TIMER_FLAG_NO_MAPCHANGE); 461 | } 462 | } else { 463 | TeleportToLobby(player, true); 464 | if(player2 > 0) 465 | { 466 | KillSearchTimer(player); 467 | SearchTmr[player2] = CreateTimer(0.1, PlayerKilled, player2, TIMER_FLAG_NO_MAPCHANGE); 468 | } 469 | } 470 | 471 | return Plugin_Handled; 472 | } 473 | 474 | bool IsInRightTeam(int client) 475 | { 476 | if(GetClientTeam(client) == CS_TEAM_CT || GetClientTeam(client) == CS_TEAM_T) 477 | return true; 478 | else 479 | return false; 480 | } 481 | --------------------------------------------------------------------------------