never mind it was warmup period which caused respawn issue and thats why i m unable to switch team to spec any idea how to do disable warmup respawns
whenever i m trying to switch team to spectator it just respawns me i think this plugin might be blocking it if anyone can help me find out which line is actually causing it
public void YK_InitPlugin () { PrintToServer("Initializing plugin: %s", PLUGIN_NAME); // ANY FUNCTIONS THAT SHOULD BE IN OnPluginStart LoadTranslations("yk_dangerzone.phrases"); YK_DatabaseInit(); YK_WelcomeMessage(); YK_InitConvars(); YK_InitCommands(); Cvars_LoadConfigs(); ServerCommand("mp_restartgame 1"); // for debug only // ANY FUNCTIONS THAT SHOULD BE IN OnPluginStart PrintToServer("Initialized plugin: %s", PLUGIN_NAME); }
////////////////////////////// // FUNCTIONS // ////////////////////////////// public void YK_InitConvars () { g_hPluginEnable = CreateConVar("yk_dzEnable", "1", "You can set it 0 to disable the plugin.", _, true, 0.0, true, 1.0); g_hBroadcastInterval = CreateConVar("yk_dzInterval", "60", "Min value is 30 and max value is 3600.", _, true, 30.0, true, 3600.0); g_hMaxTeamCount = CreateConVar("yk_dzTeamCount", "1", "Min value is 1 and max value is 3.", _, true, 1.0, true, 3.0); g_hSpawnHealth = CreateConVar("yk_dzSpawnHealth", "185", "Min value is 1 and max value is 1000.", _, true, 1.0, true, 1000.0); g_hMaxHealth = CreateConVar("yk_dzMaxHealth", "320", "Min value is 1 and max value is 1000.", _, true, 1.0, true, 1000.0); g_hReadyToStartPlayersCount = CreateConVar("yk_dzReadyToStartPlayersCount", "6", "Min value is 2 and max value is 18.", _, true, 2.0, true, 18.0); HookConVarChange(g_hPluginEnable, ConVarChanged); HookConVarChange(g_hBroadcastInterval, ConVarChanged); HookConVarChange(g_hMaxTeamCount, ConVarChanged); HookConVarChange(g_hSpawnHealth, ConVarChanged); HookConVarChange(g_hMaxHealth, ConVarChanged); HookConVarChange(g_hReadyToStartPlayersCount, ConVarChanged); HookEventEx("round_freeze_end", Event_RoundStarted, EventHookMode_Post); HookEventEx("round_end", Event_RoundEnd, EventHookMode_Post); HookEventEx("player_hurt", Event_PlayerHurt, EventHookMode_Post); HookEventEx("player_blind", Event_PlayerBlind, EventHookMode_Post); HookEventEx("player_death", Event_PlayerDeath, EventHookMode_Post); // HookEventEx("dz_item_interaction", Event_DzInteraction, EventHookMode_Post); AutoExecConfig(); }
public Action Timer_AnnounceTimer (Handle timer) { if (g_iGameStartedStatus == 0) { YK_BroadcastDangerZoneServerInfoToAll(); } return Plugin_Continue; }
////////////////////////////// // MENUS // ////////////////////////////// public int Menu_DzAdminMenu (Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Select) { char info[32]; bool found = menu.GetItem(param2, info, sizeof(info)); if (found) { if (!strcmp(info, "setting")) { g_mSettingMenu = BuildSettingMenu(0); g_mSettingMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "respawn")) { g_mRespawnMenu = BuildRespawnMenu(); if (g_mRespawnMenu == null) { tPrintToChat(param1, " %t %t", "prefix", "respawn player not found"); } g_mRespawnMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "give")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(0); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "start")) { if (g_iGameStartedStatus == 0) { g_iGameStartedStatus = 2; } } else if (!strcmp(info, "end")) { if (g_iGameStartedStatus == 1) { g_iGameStartedStatus = 0; tPrintToChatAll(" %t %t", "prefix", "admin end match", g_iMaxTeamCount); YK_EndGame(); } } else if (!strcmp(info, "fend")) { g_iGameStartedStatus = 0; tPrintToChatAll(" %t %t", "prefix", "admin end match", g_iMaxTeamCount); YK_EndGame(); } } } }
public int Menu_SettingMenu (Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Select) { char info[32]; bool found = menu.GetItem(param2, info, sizeof(info)); if (found) { if (!strcmp(info, "teamcount")) { g_mSettingMenu = BuildSettingMenu(1); g_mSettingMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "broadcast")) { g_mSettingMenu = BuildSettingMenu(2); g_mSettingMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "spawnhealth")) { g_mSettingMenu = BuildSettingMenu(3); g_mSettingMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "maxhealth")) { g_mSettingMenu = BuildSettingMenu(4); g_mSettingMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "readyplayers")) { g_mSettingMenu = BuildSettingMenu(5); g_mSettingMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "savecfg")) { ConVarSaving(); tPrintToChat(param1, " %t %t", "prefix", "cfg saved"); } else if (!strcmp(info, "teamcount_one")) { ServerCommand("yk_dzTeamCount 1"); } else if (!strcmp(info, "teamcount_two")) { ServerCommand("yk_dzTeamCount 2"); } else if (!strcmp(info, "teamcount_three")) { ServerCommand("yk_dzTeamCount 3"); } else if (!strcmp(info, "broadcast_30")) { ServerCommand("yk_dzInterval 30"); } else if (!strcmp(info, "broadcast_60")) { ServerCommand("yk_dzInterval 60"); } else if (!strcmp(info, "broadcast_90")) { ServerCommand("yk_dzInterval 90"); } else if (!strcmp(info, "broadcast_180")) { ServerCommand("yk_dzInterval 180"); } else if (!strcmp(info, "broadcast_1800")) { ServerCommand("yk_dzInterval 1800"); } else if (!strcmp(info, "spawnhealth_1")) { ServerCommand("yk_dzSpawnHealth 1"); } else if (!strcmp(info, "spawnhealth_65")) { ServerCommand("yk_dzSpawnHealth 65"); } else if (!strcmp(info, "spawnhealth_100")) { ServerCommand("yk_dzSpawnHealth 100"); } else if (!strcmp(info, "spawnhealth_185")) { ServerCommand("yk_dzSpawnHealth 185"); } else if (!strcmp(info, "spawnhealth_320")) { ServerCommand("yk_dzSpawnHealth 320"); } else if (!strcmp(info, "spawnhealth_1000")) { ServerCommand("yk_dzSpawnHealth 1000"); } else if (!strcmp(info, "maxhealth_1")) { ServerCommand("yk_dzMaxHealth 1"); } else if (!strcmp(info, "maxhealth_65")) { ServerCommand("yk_dzMaxHealth 65"); } else if (!strcmp(info, "maxhealth_100")) { ServerCommand("yk_dzMaxHealth 100"); } else if (!strcmp(info, "maxhealth_185")) { ServerCommand("yk_dzMaxHealth 185"); } else if (!strcmp(info, "maxhealth_320")) { ServerCommand("yk_dzMaxHealth 320"); } else if (!strcmp(info, "maxhealth_1000")) { ServerCommand("yk_dzMaxHealth 1000"); } else if (!strcmp(info, "readyplayers_2")) { ServerCommand("yk_dzReadyToStartPlayersCount 2"); } else if (!strcmp(info, "readyplayers_6")) { ServerCommand("yk_dzReadyToStartPlayersCount 6"); } else if (!strcmp(info, "readyplayers_10")) { ServerCommand("yk_dzReadyToStartPlayersCount 10"); } else if (!strcmp(info, "readyplayers_14")) { ServerCommand("yk_dzReadyToStartPlayersCount 14"); } else if (!strcmp(info, "readyplayers_18")) { ServerCommand("yk_dzReadyToStartPlayersCount 18"); } } } }
public int Menu_RespawnMenu (Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Select) { char info[32]; bool found = menu.GetItem(param2, info, sizeof(info)); if (found) { ChangeClientTeam(StringToInt(info), 3); CS_RespawnPlayer(StringToInt(info)); } } }
public int Menu_GiveWeaponMenu (Menu menu, MenuAction action, int param1, int param2) { if (action == MenuAction_Select) { char info[32]; bool found = menu.GetItem(param2, info, sizeof(info)); if (found) { if (!strcmp(info, "pistols")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(1); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "heavy")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(2); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "smgs")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(3); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "rifles")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(4); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "gear")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(5); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else if (!strcmp(info, "grenades")) { g_mGiveWeaponMenu = BuildGiveWeaponMenu(6); g_mGiveWeaponMenu.Display(param1, MENU_TIME_FOREVER); } else { GivePlayerItem(param1, info); } } } }
//Team Player Count file.WriteLine("// 设置小队人数上限"); file.WriteLine("// Set team players count"); file.WriteLine("yk_dzTeamCount 1"); file.WriteLine("");
//Spawn Health file.WriteLine("// 设置初始血量"); file.WriteLine("// Set spawn health"); file.WriteLine("yk_dzSpawnHealth 185"); file.WriteLine("");
//Max Health file.WriteLine("// 设置最大血量"); file.WriteLine("// Set max health"); file.WriteLine("yk_dzMaxHealth 320"); file.WriteLine("");
//Start Need Players file.WriteLine("// 设置开始游戏需要准备玩家数"); file.WriteLine("// Set game start needs players count"); file.WriteLine("yk_dzReadyToStartPlayersCount 6"); file.WriteLine("");
delete file; }
static void GenerateNewConfigs (char[] path, int a, int b, int c, int d, int e, int f) { File file = OpenFile(path, "w+");
if (file == null) { LogError("Failed to create [%s]", path); return; }
file.WriteLine("// This file was auto-generated by yk_dangerzone.smx");
//Team Player Count file.WriteLine("// 设置小队人数上限"); file.WriteLine("// Set team players count"); FormatEx(buffer, 255, "yk_dzTeamCount %d", c); file.WriteLine(buffer); file.WriteLine("");
//Spawn Health file.WriteLine("// 设置初始血量"); file.WriteLine("// Set spawn health"); FormatEx(buffer, 255, "yk_dzSpawnHealth %d", d); file.WriteLine(buffer); file.WriteLine("");
//Max Health file.WriteLine("// 设置最大血量"); file.WriteLine("// Set max health"); FormatEx(buffer, 255, "yk_dzMaxHealth %d", e); file.WriteLine(buffer); file.WriteLine("");
//Start Need Players file.WriteLine("// 设置开始游戏需要准备玩家数"); file.WriteLine("// Set game start needs players count"); FormatEx(buffer, 255, "yk_dzReadyToStartPlayersCount %d", f); file.WriteLine(buffer); file.WriteLine("");
public void SQLCallback_Connection (Database db, const char[] error, int retry) { retry++; if (db == null || error[0]) { PrintToServer("Failed to connect to SQL database. [%03d] Error: %s", retry, error); CreateTimer(5.0, Timer_DababaseRetry, retry); return; } if (g_hDatabase != null) { delete db; return; } g_hDatabase = db; if (!g_hDatabase.SetCharset("utf8mb4")) { g_hDatabase.SetCharset("utf8"); } }
public Action Timer_DababaseRetry (Handle timer, int retry) { if (g_hDatabase != null) return Plugin_Stop; if (retry >= 100) { SetFailState("Database connection failed to initialize after 100 retrie"); return Plugin_Stop; } Database.Connect(SQLCallback_Connection, "csgo", retry); return Plugin_Stop; }
public void DB_InitUser (int client) { if (IsFakeClient(client)) return; char username[255], sql[255]; int steamid = GetSteamAccountID(client); GetClientName(client, username, 255); FormatEx(sql, 255, "SELECT * FROM dangerzone WHERE steamid = '%d'", steamid); DBResultSet results = SQL_Query(g_hDatabase, sql); if (results == null) { char error[255]; SQL_GetError(g_hDatabase, error, sizeof(error)); PrintToServer("Failed to query (error: %s)", error); } else if (!(results.FetchRow() && results.RowCount > 0)) { FormatEx(sql, 255, "INSERT INTO dangerzone (username, steamid) VALUES ('%s', '%d')", username, steamid); SQL_Query(g_hDatabase, sql); delete results; } }
public void DB_AddKillToPlayer (int client) { if (IsFakeClient(client)) return; char sql[255]; int steamid = GetSteamAccountID(client); FormatEx(sql, 255, "UPDATE `dangerzone` SET `kill` = `kill` + 1 WHERE `steamid` = '%d'", steamid); DBResultSet results = SQL_Query(g_hDatabase, sql); if (results == null) { char error[255]; SQL_GetError(g_hDatabase, error, sizeof(error)); PrintToServer("Failed to query (error: %s)", error); } else { delete results; } }
public void DB_AddDeathToPlayer (int client) { if (IsFakeClient(client)) return; char sql[255]; int steamid = GetSteamAccountID(client); FormatEx(sql, 255, "UPDATE `dangerzone` SET `death` = `death` + 1 WHERE `steamid` = '%d'", steamid); DBResultSet results = SQL_Query(g_hDatabase, sql); if (results == null) { char error[255]; SQL_GetError(g_hDatabase, error, sizeof(error)); PrintToServer("Failed to query (error: %s)", error); } else { delete results; } }
public void DB_AddWinToPlayer (int client) { if (IsFakeClient(client)) return; char sql[255]; int steamid = GetSteamAccountID(client); FormatEx(sql, 255, "UPDATE `dangerzone` SET `win` = `win` + 1 WHERE `steamid` = '%d'", steamid); DBResultSet results = SQL_Query(g_hDatabase, sql); if (results == null) { char error[255]; SQL_GetError(g_hDatabase, error, sizeof(error)); PrintToServer("Failed to query (error: %s)", error); } else { delete results; } }
////////////////////////////// // WELCOME // ////////////////////////////// public void YK_WelcomeMessage () { tPrintToChatAll("%t", "welcome line 1"); tPrintToChatAll("%t", "welcome line 2"); tPrintToChatAll("%t", "welcome line 3"); tPrintToChatAll("%t", "welcome line 4"); tPrintToChatAll("%t", "welcome line 5"); tPrintToChatAll("%t", "welcome line 6"); tPrintToChatAll("%t", "welcome line 1"); }