Raised This Month: $ Target: $400
 0% 

Solved Have crash when restart/change map


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ArmaturaGEniy
New Member
Join Date: Aug 2023
Old 01-10-2024 , 02:41   Have crash when restart/change map
Reply With Quote #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"StartMatchForAdmin99"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;
        
GetRandomInt(02);
            
        
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 <= && 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 clientint 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(clientnamesizeof(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 clientint 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(clientnamesizeof(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.1Restart);
    
CreateTimer(2.0Restart1);
    
CreateTimer(3.0Restart2);
    
CreateTimer(10.0SetNoKnifes);
}

public 
Action RoundEndKnife(Event event, const char[] namebool 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 05j++)
            if ((
iTempWeapon GetPlayerWeaponSlot(clientj)) != -1)
            {
                if (
== 2
                    continue;
                if (
IsValidEntity(iTempWeapon))
                    
RemovePlayerItem(clientiTempWeapon);
            }
        
ClientCommand(client"slot3");
    }
}

public 
Action PlayerSpawn(Handle event, const char[] namebool 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(clientCS_TEAM_T);
        }
        else if(
GetClientTeam(client) == CS_TEAM_T && !IsFakeClient(client)) {
            
CS_SwitchTeam(clientCS_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[] namebool 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(client60);
    }
    return 
Plugin_Handled;
}

public 
int Menu_CallbackTeam(Menu menuMenuAction actionint param1int param2) {
    switch(
action) {
        case 
MenuAction_Select:
        {
            
char item[64];
            
menu.GetItem(param2itemsizeof(item));

            if(
StrEqual(item"switch")) {
                
g_bChooseTeamYes true;
                
CreateTimer(0.1RestartForSwap);
                
CreateTimer(1.9SetNoSwitch);
                
char nickname[64];
                
char msg[64];
                
GetClientName(param1nicknamesizeof(nickname));
                
Format(msgsizeof(msg), "\x01[\x04CS:GO Relaunch\x01]: \x0B%s\x01 choose \x04SWITCH"nickname);
                
PrintToChatAll(msg);
            }
            else if(
StrEqual(item"stay")) {
                
CreateTimer(0.1Restart1);
                
char nickname[64];
                
char msg[64];
                
GetClientName(param1nicknamesizeof(nickname));
                
Format(msgsizeof(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.0Restart);
            
CreateTimer(3.0Restart1);
            
CreateTimer(4.2Restart2);
        }
        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 clientint 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
ArmaturaGEniy is offline
ArmaturaGEniy
New Member
Join Date: Aug 2023
Old 01-10-2024 , 09:29   Re: Have crash when restart/change map
Reply With Quote #2

n't init env_sprite
Can't init env_sprite
Can't init env_sprite
Can't init env_sprite
Can't init env_sprite
Can't init light_spot
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init light_spot
Can't init light_spot
Can't init light_spot
Can't init light_spot
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init light_spot
Can't init logic_auto
Can't init light_environment
Can't init light_spot
Can't init light_spot
Can't init light_spot
Can't init light_spot
Can't init light
Can't init light
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init func_areaportal
Can't init prop_dynamic
Can't init prop_dynamic
Can't init prop_dynamic
Can't init prop_dynamic
Can't init prop_dynamic
Can't init prop_dynamic
Can't init info_player_start
Can't init func_areaportal
Can't init light
Can't init light

Displayed before crash
ArmaturaGEniy is offline
ArmaturaGEniy
New Member
Join Date: Aug 2023
Old 01-10-2024 , 10:40   Re: Have crash when restart/change map
Reply With Quote #3

I fix, problem is OnClientDisconnect, i changed to OnClientDisconnect_Post and its work!
ArmaturaGEniy is offline
Reply



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

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

Forum Jump


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


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