Raised This Month: $51 Target: $400
 12% 

Server crashes on round restart


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
SaBBa
Member
Join Date: Dec 2012
Old 01-11-2021 , 02:23   Server crashes on round restart
Reply With Quote #1

I don't have real players, I am testing mod with bodbots, when I am dying and bt kills all bot's, on respawn server fails. I think that's because all players spawn at once, error :

Code:
L 01/11/2021 - 11:17:52: [CSTRIKE] Invalid player 25
L 01/11/2021 - 11:17:52: [AMXX] Displaying debug trace (plugin "csomod_2.amxx")
L 01/11/2021 - 11:17:52: [AMXX] Run time error 10: native error (native "cs_set_user_model")
L 01/11/2021 - 11:17:52: [AMXX]    [0] csomod_2.sma::set_player_class (line 233)
L 01/11/2021 - 11:17:52: [AMXX]    [1] csomod_2.sma::fwHamPlayerSpawnPost (line 68)
FATAL ERROR (shutting down): SZ_GetSpace: overflow without FSB_ALLOWOVERFLOW set on Server Reliable Datagram


Also, menu is not opening on M button click.

My code:

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fun>
#include <fakemeta>
#include <fakemeta_util>
#include <hamsandwich>

const PRIMARY_WEAPONS_BITSUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90)

new 
selected_class[33]
new 
player_selected[33]

new const 
class_names[][] = {
    
"Fernando",
    
"Blair"
}

new const 
class_models[][] = {
    
"models/player/fernando/fernando.mdl",
    
"models/player/blair/blair.mdl"
}

new const 
class_model_names[][] = {
    
"fernando",
    
"blair"
}

public 
plugin_init()
{
    
register_clcmd("chooseteam""main_menu")
    
register_clcmd("jointeam""main_menu")
    
register_clcmd("say /m""main_menu")
}

public 
plugin_precache()
{
    for (new 
isizeof class_modelsi++) {
        
engfunc(EngFunc_PrecacheModelclass_models[i])
    }
}

public 
client_putinserver(id) {
    
selected_class[id] = 0
    player_selected
[id] = 0
}

public 
client_disconnected(id)
{
    
cs_reset_user_model(id);
}


public 
main_menu(id)
{
    new 
menu menu_create("\rGame Menu""main_menu_handler")
    
menu_additem(menu"\wChange Class""1"0)
    
menu_additem(menu"\wShop""2"0)
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
main_menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    new 
key str_to_num(data)

    switch(
key)
    {
        case 
1:
        {
            
class_menu(id)
        }
        case 
2:
        {
            
shop_menu(id)
        }
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}

public 
shop_menu(id)
{
    new 
menu menu_create("\rShop Menu""shop_menu_handler")
    
menu_additem(menu"\wBuy +50HP""1"0)
    
menu_additem(menu"\wBuy M4A1""2"0)
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
}

public 
shop_menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    new 
key str_to_num(data)

    switch(
key)
    {
        case 
1:
        {
            if(
cs_get_user_money(id) >= 5000) {
                
set_user_health(idget_user_health(id)+50)
                
cs_set_user_money(idcs_get_user_money(id)-5000)
            } else {
                
client_print(idprint_chat"[CSO] You have don't have enough money.")
            }
            
        }
        case 
2:
        {
            if(
cs_get_user_money(id) >= 3000) {
                
drop_primary_weapons(id)
                
give_item(id"weapon_m4a1")
                
give_item(id"ammo_")
                
cs_set_user_money(idcs_get_user_money(id)-3000)
            } else {
                
client_print(idprint_chat"[CSO] You have don't have enough money.")
            }
        }
    }
    
    
menu_destroy(menu)
    return 
PLUGIN_HANDLED
}


public 
ClCmdSelectModel(idmenuid)
{
    if(!
is_user_alive(id))
        return 
PLUGIN_HANDLED;

    
class_menu(id)
    return 
PLUGIN_CONTINUE;
}

public 
class_menu(id)
{
    new 
menu menu_create("\rChoose Class:""class_menu_handler")
    for (new 
0sizeof class_namesi++) {
        new 
name[64];
        
formatex(namecharsmax(name), "\w%s"class_names[i])
        new 
index[16];
        
num_to_str((i+1), indexcharsmax(index))
        
menu_additem(menunameindex0)
    }
    
menu_setprop(menuMPROP_EXITMEXIT_ALL)
    
menu_display(idmenu0)
    
}
public 
class_menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu)
        return 
PLUGIN_HANDLED
    
}

    new 
data[6], iName[64]
    new 
accesscallback
    menu_item_getinfo
(menuitemaccessdata5iName63callback)
    new 
key str_to_num(data)

    if(!
player_selected[id]) {
        
player_selected[id] = 1
        
for(new 1<= sizeof class_namesi++) {
            if(
key == i) {
                
set_player_class(idkey-1)
            }
        }
    }

    
client_print(idprint_chat,"[CSO] Your new class is: %s"class_names[key-1])
    
selected_class[id] = key-1
    
    menu_destroy
(menu)
    return 
PLUGIN_HANDLED
}

public 
set_player_class(id, class) {
    
cs_set_user_model(idclass_model_names[class]);
    
give_item(id"item_assaultsuit")
    return 
PLUGIN_HANDLED
}

stock drop_primary_weapons(id)    
{
    static 
weapons 32 ], numiweaponid
    num 

    get_user_weapons 
(idweaponsnum )
    
    for ( 
0numi++ )
    {
        
weaponid weapons ]
        if  ( ( (
1<<weaponid) & PRIMARY_WEAPONS_BITSUM ) )        
        {
            static 
wname[32]
            
get_weaponname(weaponidwnamecharsmax(wname))
            
engclient_cmd(id"drop"wname)
        }
    }


P.S. I want to add lvls too, can you how me a good example of lvl system ?
__________________

Last edited by SaBBa; 01-15-2021 at 04:14.
SaBBa is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 01-11-2021 , 07:46   Re: Server crashes on round restart
Reply With Quote #2

To solve this just check if the player is connected before calling cs_set_user_model
Code:
L 01/11/2021 - 11:17:52: [CSTRIKE] Invalid player 25
For levels, do a search. There's a bunch of plugins in this forum you could use as an example.
__________________









Last edited by CrazY.; 01-11-2021 at 08:11.
CrazY. is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-11-2021 , 08:08   Re: Server crashes on round restart
Reply With Quote #3

It's a common problem when trying to apply models to all players at once. I suggest you use this module to change player models. I had the same issue and this module helped a lot.

Level system - https://forums.alliedmods.net/showthread.php?t=308540
Better simply add the plugin and use the API inside yours if you need to, rather than trying to create an entire level system from scratch.
__________________

Last edited by OciXCrom; 01-11-2021 at 08:09.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
SaBBa
Member
Join Date: Dec 2012
Old 01-11-2021 , 11:24   Re: Server crashes on round restart
Reply With Quote #4

Quote:
Originally Posted by OciXCrom View Post
It's a common problem when trying to apply models to all players at once. I suggest you use this module to change player models. I had the same issue and this module helped a lot.

Level system - https://forums.alliedmods.net/showthread.php?t=308540
Better simply add the plugin and use the API inside yours if you need to, rather than trying to create an entire level system from scratch.
Amazing, you helped me a lot. Models fixed, rank system is fine for me too.

One last thing, M button still triggers team menu instead of mine, how can I override it ?
SaBBa is offline
ConorCC
Member
Join Date: Feb 2014
Old 01-11-2021 , 11:50   Re: Server crashes on round restart
Reply With Quote #5

Should return with PLUGIN_HANDLED
ConorCC is offline
SaBBa
Member
Join Date: Dec 2012
Old 01-11-2021 , 12:32   Re: Server crashes on round restart
Reply With Quote #6

Quote:
Originally Posted by ConorCC View Post
Should return with PLUGIN_HANDLED
wow, I spent really a lot time to figure out, why it was not working, thanks a lot
SaBBa 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 03:14.


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