New Member
|
![Old](images/statusicon/post_old.svg)
01-10-2024
, 02:41
Have crash when restart/change map
|
#1
|
HI, i have crash server when restarting map or change map
Sry for my bad english
Code:
PHP Code:
#include <sourcemod>
#include <cstrike>
#include <sdktools>
public Plugin myinfo =
{
name = "REBORN PUG",
author = "Cahid Armatura",
description = "",
version = "1.0.0",
url = "https://github.com/zloybik/"
};
int player_ReadyStatus[MAXPLAYERS+1];
int ReadyPlayersInMM = 0;
int CountPlayersInServer;
bool g_bKnivesIsNotActive = false;
bool g_bChooseTeamEnd = false;
bool g_bChooseTeamYes = false;
bool g_bKnifeRoundEnd = true;
bool g_bLiveIsActive = false;
bool g_bTimeToChangeMap = false;
public void OnPluginStart() {
RegConsoleCmd("sm_r", SetReadyClient, "Set to client READY status");
RegConsoleCmd("sm_ur", SetUnReadyClient, "Set to client UNREADY status");
RegAdminCmd("sm_start", StartMatchForAdmin, 99, "For Admin start", "z");
}
public void OnMapStart() {
ServerCommand("exec CSGORELAUNCH/warmup.cfg");
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: warmup.cfg is \x04loaded\x01!");
if(g_bTimeToChangeMap == true) {
g_bTimeToChangeMap = false;
}
if(g_bChooseTeamEnd == true) {
g_bChooseTeamEnd = false;
}
if(g_bLiveIsActive == true) {
g_bLiveIsActive = false;
}
}
public void OnMapEnd() {
if(g_bTimeToChangeMap == false) {
g_bTimeToChangeMap = true;
}
if(g_bTimeToChangeMap == true) {
char maps[][] = {
"de_dust2",
"de_inferno",
"de_mirage"
}
int i;
i = GetRandomInt(0, 2);
ServerCommand("map %s", maps[i]);
}
}
public void OnClientPutInServer(int client) {
if(!IsFakeClient(client)) {
++CountPlayersInServer;
player_ReadyStatus[client] = 0;
}
}
public void OnClientDisconnect(int client) {
if(!IsFakeClient(client)) {
if(player_ReadyStatus[client] == 0) {
//... nothing
}
else
{
player_ReadyStatus[client] = 0;
MinusPlayerInRM();
}
--CountPlayersInServer;
if(CountPlayersInServer <= 1 && g_bLiveIsActive == true && !IsFakeClient(client)) {
ServerCommand("exec CSGORELAUNCH/warmup.cfg");
ServerCommand("mp_unpause_match");
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: warmup.cfg is \x04loaded\x01!");
PrintHintTextToAll("Game is stopped, because players <= 1");
g_bLiveIsActive = false;
}
else
{
//... nothing
}
}
}
public Action MinusPlayerInRM() {
ReadyPlayersInMM = ReadyPlayersInMM - 1;
}
public Action PlusPlayerInRM() {
ReadyPlayersInMM = ReadyPlayersInMM + 1;
}
public Action SetReadyClient(int client, int args) {
if(g_bLiveIsActive == false) {
if(player_ReadyStatus[client] == 1) {
ReplyToCommand(client, "\x01[\x04CS:GO Relaunch\x01]: You already ready. If you want unready, write in chat !ur");
}
else
{
player_ReadyStatus[client] = 1;
PlusPlayerInRM();
PrintHintTextToAll("%d of 2 is ready. If you want unready, write in chat !ur", ReadyPlayersInMM);
char name[64];
GetClientName(client, name, sizeof(name));
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: \x0B%s\x01 is \x04ready\x01!", name);
if(ReadyPlayersInMM == 1) {
StartMatch();
}
}
}
else {
ReplyToCommand(client, "\x01[\x04CS:GO Relaunch\x01]: Game is \x04LIVE\x01");
}
}
public Action SetUnReadyClient(int client, int args) {
if(g_bLiveIsActive == false) {
if(player_ReadyStatus[client] == 0) {
ReplyToCommand(client, "\x01[\x04CS:GO Relaunch\x01]: You already unready. If you want ready, write in chat !r");
}
else
{
player_ReadyStatus[client] = 0;
MinusPlayerInRM();
PrintHintTextToAll("%d of 2 is ready. If you want ready, write in chat !r", ReadyPlayersInMM);
char name[64];
GetClientName(client, name, sizeof(name));
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: \x0B%s\x01 is \x02unready\x01!", name);
}
}
else {
ReplyToCommand(client, "\x01[\x04CS:GO Relaunch\x01]: Game is \x04LIVE\x01");
}
}
public Action StartMatch() {
g_bKnivesIsNotActive = false;
g_bKnifeRoundEnd = false;
g_bKnifeRoundEnd = true;
g_bLiveIsActive = true;
HookEvent("player_spawn", PlayerSpawn);
HookEvent("round_mvp", ChooseTeam);
HookEvent("round_end", RoundEndKnife);
ServerCommand("exec CSGORELAUNCH/Knife.cfg");
ServerCommand("mp_give_player_c4 0");
CreateTimer(0.1, Restart);
CreateTimer(2.0, Restart1);
CreateTimer(3.0, Restart2);
CreateTimer(10.0, SetNoKnifes);
}
public Action RoundEndKnife(Event event, const char[] name, bool dontBroadcast) {
if(g_bKnifeRoundEnd == false) {
ServerCommand("mp_pause_match");
g_bKnifeRoundEnd = true;
}
}
stock void StripOnePlayerWeapons(int client)
{
if (IsPlayerAlive(client))
{
int iTempWeapon = -1;
for (int j = 0; j < 5; j++)
if ((iTempWeapon = GetPlayerWeaponSlot(client, j)) != -1)
{
if (j == 2)
continue;
if (IsValidEntity(iTempWeapon))
RemovePlayerItem(client, iTempWeapon);
}
ClientCommand(client, "slot3");
}
}
public Action PlayerSpawn(Handle event, const char[] name, bool dontBroadcast)
{
if(g_bKnivesIsNotActive == false) {
StripOnePlayerWeapons(GetClientOfUserId(GetEventInt(event, "userid")));
}
if(g_bChooseTeamYes == true) {
int client = GetClientOfUserId(GetEventInt(event, "userid"));
if(GetClientTeam(client) == CS_TEAM_CT && !IsFakeClient(client)) {
CS_SwitchTeam(client, CS_TEAM_T);
}
else if(GetClientTeam(client) == CS_TEAM_T && !IsFakeClient(client)) {
CS_SwitchTeam(client, CS_TEAM_CT);
}
}
}
public Action Restart(Handle timer) {
ServerCommand("mp_restartgame 1");
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: Game is \x04LIVE\x01! Restart \x041");
}
public Action Restart1(Handle timer) {
ServerCommand("mp_restartgame 1");
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: Game is \x04LIVE\x01! Restart \x042");
}
public Action Restart2(Handle timer) {
ServerCommand("mp_restartgame 3");
PrintToChatAll("\x01[\x04CS:GO Relaunch\x01]: Game is \x04LIVE\x01! Restart \x043");
}
public Action SetNoKnifes(Handle timer) {
g_bKnivesIsNotActive = true;
ServerCommand("mp_give_player_c4 1");
g_bKnifeRoundEnd = false;
}
public Action ChooseTeam(Event event, const char[] name, bool dontBroadcast) {
if(g_bChooseTeamEnd == false) {
int client = GetClientOfUserId(event.GetInt("userid"));
Menu menu = new Menu(Menu_CallbackTeam);
menu.SetTitle("CS:GO Relaunch waiting your choose...");
menu.AddItem("switch", "Switch");
menu.AddItem("stay", "Stay");
menu.Display(client, 60);
}
return Plugin_Handled;
}
public int Menu_CallbackTeam(Menu menu, MenuAction action, int param1, int param2) {
switch(action) {
case MenuAction_Select:
{
char item[64];
menu.GetItem(param2, item, sizeof(item));
if(StrEqual(item, "switch")) {
g_bChooseTeamYes = true;
CreateTimer(0.1, RestartForSwap);
CreateTimer(1.9, SetNoSwitch);
char nickname[64];
char msg[64];
GetClientName(param1, nickname, sizeof(nickname));
Format(msg, sizeof(msg), "\x01[\x04CS:GO Relaunch\x01]: \x0B%s\x01 choose \x04SWITCH", nickname);
PrintToChatAll(msg);
}
else if(StrEqual(item, "stay")) {
CreateTimer(0.1, Restart1);
char nickname[64];
char msg[64];
GetClientName(param1, nickname, sizeof(nickname));
Format(msg, sizeof(msg), "\x01[\x04CS:GO Relaunch\x01]: \x0B%s\x01 choose \x04STAY", nickname);
PrintToChatAll(msg);
}
ServerCommand("exec CSGORELAUNCH/Live.cfg");
ServerCommand("mp_unpause_match");
CreateTimer(2.0, Restart);
CreateTimer(3.0, Restart1);
CreateTimer(4.2, Restart2);
}
case MenuAction_End:
{
delete menu;
}
}
}
public Action RestartForSwap(Handle timer) {
ServerCommand("mp_restartgame 1");
}
public Action SetNoSwitch(Handle timer) {
g_bChooseTeamYes = false;
g_bChooseTeamEnd = true;
}
public Action StartMatchForAdmin(int client, int args) {
StartMatch();
}
Game CS:GO
sourcemod SourcePawn Compiler 1.7.3-dev+5315(Because i have project in csgo 2016 and this plugin for this.)
And maybe problem is OnMapStart and OnMapEnd, but idk how to repair it :/
Last edited by DarkDeviL; 01-10-2024 at 18:31.
Reason: Added CODE + Solved tag
|
|