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

server crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 11-28-2020 , 06:33   server crash
Reply With Quote #1

hello. so i m working at this plugin and it s already done, but sometimes server crash and give "segmentation fault". i don t know why this is happening. i will be very thankful if someone would look over the code and tell me if it s something wrong that would crash server (ik code is terrible but i m still learning so if u have some good ideas of optimizing please tell me).


thanks.
Attached Files
File Type: sma Get Plugin or Get Source (menuvip.sma - 65 views - 16.3 KB)

Last edited by lexzor; 11-28-2020 at 06:34.
lexzor is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-28-2020 , 08:26   Re: server crash
Reply With Quote #2

the code is messy try to indent the code, here's some thoughts

PHP Code:
remove_entity(g_iMask[id]) 
instead of instantly removing the entity try safely removing it setting its flag to KILL_ME example (fakemeta)
PHP Code:
pev(entitypev_flagsFL_KILLME);
DLLFunc(DLLFunc_Thinkentity); 
i see you're hooking ResetHUD message for one person which doesn't make sense ?

anywho you can hook player spawn by hooking first round start
PHP Code:
register_event("HLTV""event_new_round""a""1=0""2=0"
and also Enable Ham_Spawn Post for player but first you need to register Ham_Spawn "player" in the plugin_init, also always check if user is alive in the beginning of its function and then you can disable the function when last player id spawns.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-28-2020 at 08:28.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
lexzor
Veteran Member
Join Date: Nov 2020
Old 11-29-2020 , 04:31   Re: server crash
Reply With Quote #3

Thanks for help.

I rewrite the code and now it s looking like this, but i still have a problem (SV_HullForBsp: Hit a worldspawn with no model (models/menuskin/t_covid_white.mdl))

PHP Code:
/* Plugin generated by AMXX-Studio */

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>
#include <ColorChat>
#include <engine>
#include <fakemeta>
#include <nvault>


#define PLUGIN "SkinMenu"
#define VERSION "3.0"
#define AUTHOR "lexzor"

new key MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0;
new const 
tag[ ]= "JoiNET"
new iTeam;

new 
checkCT[32]
new 
checkT[32]
new 
checkPS[32]
new 
iEntityMask;

new 
cmask[32]
new 
checkMS[32]
new 
checkMS3[32]
new 
checkMS2[][] = {
    
    
"WHITE",
    
"BLACK",
    
"RED",
    
"GREEN",
    
"YELLOW"
}

new 
name[32]
new 
vaultdata[256]
new 
nVault
new camera
new cam
new 13
new const nVaultName[ ] = "skinmenu";

new 
skins[][]={ // 12 skinuri, skins[0] este "", deci numaratoarea incepe de la 1 si se termina la 12
    // astfel definim i=1 (de unde incepe) si f12 (unde se termina) pentru precache
    
"",
    
"models/menuskin/t_santa.mdl",
    
"models/menuskin/ct_santa.mdl",
    
"models/menuskin/t_covid_white.mdl",
    
"models/menuskin/t_covid_black.mdl",
    
"models/menuskin/t_covid_red.mdl",
    
"models/menuskin/t_covid_green.mdl",
    
"models/menuskin/t_covid_yellow.mdl",
    
"models/menuskin/ct_covid_yellow.mdl",
    
"models/menuskin/ct_covid_white.mdl",
    
"models/menuskin/ct_covid_black.mdl",
    
"models/menuskin/ct_covid_red.mdl",
    
"models/menuskin/ct_covid_green.mdl",
    
""
}



new 
playerskins[][] = {
    
"sias",
    
"fbi",
    
"isis",
    
"alqaeda"
}

public 
plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_clcmd("amx_vskin""menuVIP")
    
register_clcmd("amx_show""show")
    
register_clcmd("amx_try""client_disconnected")
    
    
register_menu("menuVIP"key"menuVIP_handler")
    
register_menu("playerskin"key"playerskin_handler")
    
register_menu("covidmask"key"covidmask_handler")
    
//register_event( "ResetHUD", "taskdo", "be" );
    
RegisterHam(Ham_Spawn"player""taskdo"1
    
    
    
nVault nvault_open(nVaultName)
    
    if (
nVault == INVALID_HANDLE)
        
set_fail_state("[SKINMENU] Plugin can't open nVault file!")
}

public 
plugin_precache(){
    static 
playermodels[256]
    static 
models[256]
    
    for (new 
0sizeof(playerskins) -1i++){
        
        
formatex(playermodelscharsmax(playermodels), "models/player/%s/%s.mdl"playerskins[i], playerskins[i])
        
        
precache_model(playermodels)
        
    } 
    
    
precache_model(skins[1])
    
precache_model(skins[2])
    
precache_model(skins[3])
    
precache_model(skins[4])
    
precache_model(skins[5])
    
precache_model(skins[6])
    
precache_model(skins[7])
    
precache_model(skins[8])
    
precache_model(skins[9])
    
precache_model(skins[10])
    
precache_model(skins[11])
    
precache_model(skins[12])
    
    
}

public 
cmdSave(id){
    
    
formatexvaultdatacharsmax(vaultdata), "%i#%i#%i"checkPS[id], checkT[id], checkCT[id] )
    
    
nvault_set(nVaultnamevaultdata)
    
}

public 
cmdGet(id){
    
    
get_user_name(idnamecharsmax(name))
    
    new 
checkps[10], checkt[10], checkct[10], checkms[10], checkms3[10]
    
    
nvault_get(nVaultnamevaultdatacharsmax(vaultdata))
    
    
replace_all(vaultdatacharsmax(vaultdata), "#"" ")
    
    
parse(vaultdatacheckpscharsmax(checkps), checktcharsmax(checkt), checkctcharsmax(checkct))
    
    
checkPS[id] = str_to_num(checkps)
    
    
checkT[id] = str_to_num(checkt)
    
    
checkCT[id] = str_to_num(checkct)
    
}

public 
menuVIP(id){
    static 
szMenu[650], ilen
    
    ilen 
0
    
    ilen 
+= formatex(szMenu[ilen], charsmax(szMenu), "\r[%s]\y VIP MENU^n^n"tag)
    
    
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r1.\w Player Skins^n^n")
    
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r2.\w Covid Mask^n^n")
    
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r3.\w Camera View - %s^n^n"camera "\r[3RD Person View]" "\r[Normal View]" )
    
    
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r0.\y Exit")
    
    
show_menu(idkeyszMenu, -1"menuVIP")
}


public 
menuVIP_handler(idkey){
    
    if (!(
is_user_alive(id))){
        
        
ColorChat(idGREEN"^x04[%s]^x01 You must be^x04 alive^x01 to use this menu!"tag)
        
        
menuVIP(id)
        
        return 
0
        
    
}
    
    switch(
key){
        
        case 
0:{
            
            
playerskin(id)
            
        }
        
        case 
1:{
            
            
covidmask(id)
            
        }
        
        
        case 
2:{
            
            if (
camera && !cam){
                
                
camera false;
                
                if(
is_user_alive(id))
                    
                
ColorChat(idGREEN"^x04[%s]^x01 You changed camera to^x04 Normal View^x01."tag);
                
                
client_cmd(id"cam")
                
                } else if (!
camera  && !cam){
                
                
camera true;
                
                if(
is_user_alive(id))
                    
                
ColorChat(idGREEN"^x04[%s]^x01 You changed camera to^x04 3RD Person View^x01."tag);
                
                
client_cmd(id"cam")
                
                } else if ( 
cam ){
                
                
ColorChat(idGREEN"^x04[%s]^x01 You can set^x04 view^x01 just in first^x04 15 seconds^x01 of every round!"tag)
                
            } 
            
menuVIP(id)
            
        }
        
        case 
9:{
            
            
ColorChat(idGREEN"^x04[%s]^x01 You left^x04 VIP SKIN MENU^x01."tag)
            
        }
        
    }
    
}

public 
playerskin(id){
    static 
szMenu2[650], ilen
    ilen 
0
    
    iTeam 
get_user_team(id)
    
    
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r[%s]\y PLAYER SKIN MENU^n^n"tag)
    
    
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r1.\y Default Skin - %s^n^n",  checkPS[id] == "\y[ON]" "\r[OFF]")
    
    if (
iTeam == 1){
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r2.\w ISIS Killer - %s^n"checkPS[id] == "\y[ON]" "\r[OFF]")
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r3.\w aL-Qaeda Hitman - %s^n^n"checkPS[id] == "\y[ON]" "\r[OFF]")
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r4.\w FBI Agent -\d [CT ONLY]^n")
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r5.\w SIAS Specialist -\d [CT ONLY]^n^n")
        
        }else if ( 
iTeam == ){
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r2.\w ISIS Killer -\d [T ONLY]^n")
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r3.\w aL-Qaeda Hitman -\d [T ONLY]^n^n")
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r4.\w FBI Agent - %s^n"checkPS[id] == "\y[ON]" "\r[OFF]")
        
        
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r5.\w SIAS Specialist - %s^n^n"checkPS[id] == "\y[ON]" "\r[OFF]")
    }
    
    
ilen += formatex(szMenu2[ilen], charsmax(szMenu2), "\r0.\y Back")
    
    
show_menu(idkeyszMenu2, -1"playerskin")
}

public 
playerskin_handler(idkey){
    
    if (!(
is_user_alive(id))){
        
        
ColorChat(idGREEN"^x04[%s]^x01 You must be^x04 alive^x01 to use this menu!"tag)
        
        
playerskin(id)
        
        return 
0
        
    
}
    
    
iTeam get_user_team(id)
    
    if(
is_user_alive(id)){
        switch(
key){
            
            case 
0: {
                
                
checkPS[id] = 0;
                
                
checkCT[id] = 0;
                
                
checkT[id] = 0;
                
                
cs_reset_user_model(id)
                
                
ColorChat(idGREEN"^x04[%s]^x01 You choose^x04 default^x01 skin!"tag)
                
            }
            
            case 
1:{
                
                if (
iTeam == 1){
                    
                    
checkT[id] = 1
                    
                    checkPS
[id] = 1
                    
                    cs_reset_user_model
(id)
                    
                    
cs_set_user_model(id"isis")
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You choose^x04 ISIS Killer^x01 skin!"tag)
                    
                    
                }
                if (
iTeam == 2){
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You can't choose this skin!"tag)
                    
                    
                }
                
                
playerskin(id)
                
            }
            
            case 
2:{
                
                if (
iTeam == 1){
                    
                    
checkT[id] = 2
                    
                    checkPS
[id] = 2
                    
                    cs_reset_user_model
(id)
                    
                    
cs_set_user_model(id"alqaeda")
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You choose^x04 aL-Qaeda Hitman^x01 skin!"tag)
                    
                    
playerskin(id)
                    
                }
                if (
iTeam == 2){
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You can't choose this skin!"tag)
                    
                    
playerskin(id)
                    
                }
                
            }
            
            case 
3:{
                
                if (
iTeam == 2){
                    
                    
checkCT[id] = 1
                    
                    checkPS
[id] = 3
                    
                    cs_reset_user_model
(id)
                    
                    
cs_set_user_model(id"fbi")
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You choose^x04 FBI Agent^x01 skin!"tag)
                    
                    
playerskin(id)
                    
                }
                if (
iTeam == 1){
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You can't choose this skin!"tag)
                    
                    
playerskin(id)
                    
                }
                
            }
            
            case 
4:{
                
                if (
iTeam == 2){
                    
                    
checkCT[id] = 2
                    
                    checkPS
[id] = 4
                    
                    cs_reset_user_model
(id)
                    
                    
cs_set_user_model(id"sias")
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You choose^x04 SIAS Specialist^x01 skin!"tag)
                    
                    
playerskin(id)
                    
                }
                if (
iTeam == 1){
                    
                    
ColorChat(idGREEN"^x04[%s]^x01 You can't choose this skin!"tag)
                    
                    
playerskin(id)
                    
                }
                
            }
            
            case 
9:{
                
                
menuVIP(id)
                
            }
            
        }
    } else 
ColorChat(idGREEN,"^x04[%s]^x01 You must be^x04 alive^x01 to use this menu!"tag)
}

public 
covidmask(id){
    
    static 
szMenu[650], ilen
    
    ilen 
0
    
    ilen 
+= formatex(szMenu[ilen], charsmax(szMenu), "\r[%s]\y COVIDMASK MENU^n^n"tag)
    
    
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r1.\w Covid Mask - %s^n"checkMS[id] ? "\y[ON]" "\r[OFF]" )
    
    if(
checkMS[id])
        
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r2.\w Covid Mask Color - \y[%s]^n^n"checkMS2[checkMS3[id]] )
    
    else if (!
checkMS[id])
        
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r2.\w Covid Mask Color - \d[DISABLED]^n^n")
    
    
    
    
ilen += formatex(szMenu[ilen], charsmax(szMenu), "\r0.\y Exit")
    
    
show_menu(idkeyszMenu, -1"covidmask")
    
}

public 
covidmask_handler(idkey){
    
    if (!(
is_user_alive(id))){
        
        
ColorChat(idGREEN"^x04[%s]^x01 You must be^x04 alive^x01 to use this menu!"tag)
        
        
covidmask(id)
        
        return 
0
        
    
}
    
    switch(
key){
        
        case 
0:{
            
            if(
checkMS[id] == 1){
                
                
checkMS[id] = 0
                
                ColorChat
(idGREEN"^x04[%s]^x01 You disabled^x04 Covid Mask^x01 skin!"tag)
                
            }
            
            else if (
checkMS[id] == 0){
                
                
checkMS[id] = 1
                
                ColorChat
(idGREEN"^x04[%s]^x01 You enabled^x04 Covid Mask^x01 skin!"tag)
                
            }
            
            
covidmask(id)
            
            
mask(id)
            
        }
        
        case 
1:{
            
            if (
checkMS[id])
                
            
checkMS3[id]++
            
            
            if(
checkMS3[id] == 5)
                
            
checkMS3[id] = 0
            
            covidmask
(id)
            
            
mask(id)    
            
            
        }
        
        case 
9:{
            
            
menuVIP(id)
            
        }
        
    }
    
}

public 
mask(id){
    
    if (!(
is_user_alive(id))) return 0
    
    iTeam 
get_user_team(id)
    
    if(!(
pev_valid(iEntityMask)))
        
    
iEntityMask cmask[id] = create_entity("info_target")
    
    if(
pev_valid(iEntityMask)){
        
        if(
checkMS[id] == 1){
            
            
set_pev(cmask[id], pev_effectspev(cmask[id], pev_effects) & ~EF_NODRAW
            
        }
        
        else  if (
checkMS[id] == 0){
            
            
set_pev(cmask[id], pev_effectspev(cmask[id], pev_effects) | EF_NODRAW)
            
        }
        
        if ( 
iTeam == 1) {
            
            switch(
checkMS3[id]){
                
                
                case 
entity_set_model(cmask[id], skins[3])
                    
                case 
entity_set_model(cmask[id], skins[4])
                    
                case 
entity_set_model(cmask[id], skins[5])
                    
                case 
entity_set_model(cmask[id], skins[6])
                    
                case 
entity_set_model(cmask[id], skins[7])
                }
            
            } else if ( 
iTeam == ){
            
            switch(
checkMS3[id]){
                
                case 
entity_set_model(cmask[id], skins[8])
                    
                case 
entity_set_model(cmask[id], skins[9])
                    
                case 
entity_set_model(cmask[id], skins[10])
                    
                case 
entity_set_model(cmask[id], skins[11])
                    
                case 
entity_set_model(cmask[id], skins[12])
                    
            }
            
        }
        
        
entity_set_intiEntityMaskEV_INT_movetypeMOVETYPE_FOLLOW );
        
        
entity_set_edictiEntityMaskEV_ENT_aimentid );
        
    }
    
    
}

public 
show(id){
    
    if(
get_user_flags(id) & ADMIN_IMMUNITY)
        
    
ColorChat(idGREEN"^x04[%s]^x01 SkinCT %i, SkinT %i, Mask %i , MaskColor %i!"tagcheckCT[id], checkT[id], checkMS[id], checkMS3[id])
    
}

public 
client_disconnected(id){
    
    
cmdSave(id)
    
    if (
pev_valid(cmask[id]) && cmask[id] > ){
        
        
remove_entity(cmask[id])
        
        
ColorChat(0GREEN"^x04[%s]^x01 %i"tagcmask[id])
        
    }
}

public 
client_connect(id){
    
    
cmdGet(id)
    
}

public 
skincheck(id){
    
    
cam false
    
    iTeam 
get_user_team(id)
    
    if(
is_user_alive(id) && checkPS[id] != 0){
        
        if ( 
iTeam == ){
            
            if (
checkT[id] == cs_reset_user_model(id)
            
            switch(
checkT[id]){
                
                case 
1:{
                    
                    
cs_reset_user_model(id)
                    
                    
cs_set_user_model(id"isis")
                    
                }
                
                case 
2:{
                    
                    
cs_reset_user_model(id)
                    
                    
cs_set_user_model(id"alqaeda")
                    
                }
                
            }
            
            
            } else if ( 
iTeam == ){
            
            if (
checkCT[id] == cs_reset_user_model(id)
            
            switch(
checkCT[id]){
                
                case 
1:{
                    
                    
cs_reset_user_model(id)
                    
                    
cs_set_user_model(id"fbi")
                    
                }
                
                case 
2:{
                    
                    
cs_reset_user_model(id)
                    
                    
cs_set_user_model(id"sias")
                    
                }
                
            }
            
        }
        
    }
    
}

public 
camset(id){
    
    
//if(!(get_user_flags(id) & VIP_FLAG)) return 0
    
    
set_view(idCAMERA_NONE)
    
    
cam true
    
    camera 
false
    
}

public 
taskdo(id){
    
    
set_task(0.1"skincheck"id)
    
    
set_task(0.1"mask"id)
    
    
set_task(15.0"camset"id)
    


Last edited by lexzor; 11-29-2020 at 04:31.
lexzor 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 09:40.


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