Raised This Month: $ Target: $400
 0% 

set model + prevent crash


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ownage
BANNED
Join Date: Jul 2007
Location: I don't know
Old 07-12-2007 , 20:37   set model + prevent crash
Reply With Quote #1

using cs_set_user_model will sometimes dump the players in the server, without an error (SVC_BAD)

happens when there is only 12 people on the server

so i dont get sending it to one at a time would still crash?

Code:
        modloop=0         set_task(0.2,"looppm2",0,"",0,"a",32) public looppm2(){     modloop++     if(is_user_connected(modloop)&&is_user_alive(modloop)){         new szModel[33]         cs_get_user_model(modloop, szModel, 32)         if (containi(szModel, "mc") ==-1 && containi(szModel, "freeman") ==-1 ){             set_model2(modloop)             }         }     } public set_model(id){     if(!is_user_alive(id)||!is_user_connected(id)){         return     }         if(cs_get_user_team(id) == CS_TEAM_T){                     cs_set_user_model(id, "mc")                         }         else if(cs_get_user_team(id) == CS_TEAM_CT){                     cs_set_user_model(id, "freeman")             }     }

everything in the script is correct exept the damn function cs_set_user_model

whats weird is: if that svc_ban error happens, the player dont get disconnected at once, they get disconnected every .2 seconds, like i see other people getting booted .2 seconds one gone .2 seconds another one gone and .2 seconds im gone

is there any other way to prevent server "dump" crash ???

iv search and there is no good solution, and we need to get this settled, valve a piece of crap
Ownage is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 07-13-2007 , 10:53   Re: set model + prevent crash
Reply With Quote #2

People are getting disconnected every .2 seconds because thats what your loop interval is set at.

Code:
if (containi(szModel, "mc") ==-1 && containi(szModel, "freeman") ==-1 ){
needs to be || not && because the model is either MC or FREEMAN, it can't be both.

You also included the wrong function with your program (the set_model2) so the problem could lay in there.
I'm not sure why you are using a set_task loop to loop though all the players rather then a for loop, which would be faster.
__________________
toazron1 is offline
Send a message via AIM to toazron1
_Master_
Senior Member
Join Date: Dec 2006
Old 07-13-2007 , 12:01   Re: set model + prevent crash
Reply With Quote #3

1. depending on the rest of the code you should use static vars instead of global ones (if you modify it elsewhere you're in big trouble).
2. remove is_user_alive() from the task.
3. please post full code (also for set_model2() ).
_Master_ is offline
toazron1
Senior Member
Join Date: Oct 2006
Old 07-13-2007 , 12:42   Re: set model + prevent crash
Reply With Quote #4

Quote:
Originally Posted by _Master_ View Post
2. remove is_user_alive() from the task.
You might need to need an alive check depening on how CS works for setting the model. I know NS resets its model when the person spawns. However, you don't need is_user_alive and is_user_connected, its redundent.
__________________
toazron1 is offline
Send a message via AIM to toazron1
_Master_
Senior Member
Join Date: Dec 2006
Old 07-16-2007 , 06:46   Re: set model + prevent crash
Reply With Quote #5

Quote:
Originally Posted by toazron1 View Post
You might need to need an alive check depening on how CS works for setting the model. I know NS resets its model when the person spawns. However, you don't need is_user_alive and is_user_connected, its redundent.
Set model relies on pre_think to "keep" the model after new_round. It does not need the user to be alive but connected.
@ Ownage: my statement above.
_Master_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 07-16-2007 , 07:09   Re: set model + prevent crash
Reply With Quote #6

public zplugin_precache(){

Should be

public plugin_precache(){

Except if zplugin_precache is st from umitem.inc but i don't think so.
ConnorMcLeod is offline
Ownage
BANNED
Join Date: Jul 2007
Location: I don't know
Old 07-13-2007 , 14:53   Re: set model + prevent crash
Reply With Quote #7

mode is messed up brb

Last edited by Ownage; 07-13-2007 at 14:56.
Ownage is offline
Ownage
BANNED
Join Date: Jul 2007
Location: I don't know
Old 07-13-2007 , 15:01   Re: set model + prevent crash
Reply With Quote #8

Code:
#include <amxmodx> #include <umitem> #include <cstrike> #include <engine> #include <fakemeta> #include <fun> new gMsgScreenFade; new ldt[33] new gHasCovenantPower[33] new cvar_arena     new cvar_hp new cvar_model new cvar_shieldap new hp[33] new lasthp[33] new invis[33] new invischarge = 30 new modloop public plugin_init() {         register_plugin("ITEM Halo Energy Shield","1.1","OWNAGR")       register_item("Halo 2 R Shield & [press F for 6 sec Camouflage]", "ARMOR (shield) goes down first, then hp, does not protect from 1 shot / instant kills, Press F for invisiblity", 16000)         register_event("HLTV",         "Event_NewRound",     "a",     "1=0", "2=0")         cvar_arena = register_cvar("sv_halo","0")     cvar_model=register_cvar("sv_mcfreeman","0")         cvar_shieldap = register_cvar("sv_haloap","200")     cvar_hp = register_cvar("sv_halohp","200")         register_clcmd("h","h")     register_clcmd("sh" ,"Enable_Item")     register_clcmd("nosh" ,"Disable_Item")         server_cmd("sv_halo 0")     server_cmd("sv_haloap 200")     server_cmd("sv_halohp 200")         register_clcmd("+rope", "hook_on")     gMsgScreenFade = get_user_msgid("ScreenFade"); } public zplugin_precache(){     precache_model("models/player/freeman/freeman.mdl")     precache_model("models/player/mc/mc.mdl") } //need invis[id] >=invischarge for invis public hook_on(id){     if (!gHasCovenantPower[id]){                 if(is_user_alive(id)){             client_cmd(id,"impulse 100")         }                 return PLUGIN_CONTINUE     }     else if(invis[id]<invischarge){         client_print(id,print_center,"Invisibility not recharged yet! ( %i/%i )",invis[id],invischarge)         return PLUGIN_CONTINUE     }     client_print(id,print_center,"You are hard to see! Charging.....")     client_print(id,print_chat,"[OWNAGE HALO 2 INVISIBLITY] Camouflage activated! You are hard to see! Charging.....")         new tid[2]     tid[0] = id     set_task(0.1, "invisibility", 0, tid,2 , "a", 60)         set_task(6.3,"noinvis", 0, tid,2 )     invis[id]=0     return PLUGIN_CONTINUE     } public invisibility(tid[]){     if(is_user_connected(tid[0])){         set_user_rendering(tid[0],kRenderFxGlowShell, 0,0,0, kRenderTransTexture,45)     } } public noinvis(tid[]){     if(is_user_alive(tid[0])){         set_user_rendering(tid[0], kRenderFxGlowShell, 0, 0, 0, kRenderTransAlpha, 255)         client_print(tid[0],print_center,"Invisibility is over!")         client_print(tid[0],print_chat,"[OWNAGE HALO 2 INVISIBLITY] Invisibility is over!")     } } public Event_NewRound() {     if (get_pcvar_num(cvar_arena)){         set_task(3.0,"arena")             }         set_task(4.5,"ref")             modelall2() //there is 2 methods, modeall and modeall2, one is do it all, one is delayed                 return PLUGIN_CONTINUE } public arena(){     client_print(0,print_center,"Its Halo 2 style! HP & AP recharge! Aim for the head!")         //set_pcvar_num(cvar_shieldap,255)         new Players[32], iNum, target     get_players(Players, iNum, "a")         for(new i = 0; i < iNum; ++i)     {         target = Players[i]         if(is_user_alive(target)&& !gHasCovenantPower[target]){                     client_cmd(target,"sh")                     }     }     modelall2() //there is 2 methods, modeall and modeall2, one is do it all, one is delayed } public modelall(){         new mod = get_pcvar_num(cvar_model)     if(mod==0||mod==1){         new Players[32], iNum,id         get_players(Players, iNum, "a")         for(new i = 0; i < iNum; ++i)         {             id=Players[i]             new szModel[33]             cs_get_user_model(id, szModel, 32)             if (containi(szModel, "mc") ==-1||containi(szModel, "freeman") ==-1){                 set_model(id)             }                                                 }         }     } public modelall2(){         new mod = get_pcvar_num(cvar_model)     if(mod==0||mod==1){         modloop=0         set_task(0.3,"looppm",0,"",0,"a",32)         }     } public looppm(){     modloop++     if(is_user_connected(modloop)&&is_user_alive(modloop)){             set_model(modloop)                     }     } public set_model(id){     if(!is_user_alive(id)||!is_user_connected(id)){         return     }     server_cmd("amx_chat %d",id)     if(cs_get_user_team(id) == CS_TEAM_T){         new szModel[33]         cs_get_user_model(id, szModel, 32)         if (containi(szModel, "mc") ==-1){             cs_set_user_model(id, "mc")                     }     else if(cs_get_user_team(id) == CS_TEAM_CT){         new szModel[33]         cs_get_user_model(id, szModel, 32)         if (containi(szModel, "freeman") ==-1){             cs_set_user_model(id, "freeman")                     }                         } } public ref(){     new Players[32], iNum, target     get_players(Players, iNum, "a")         for(new i = 0; i < iNum; ++i)     {         target = Players[i]         if(is_user_alive(target)&& gHasCovenantPower[target]){             ldt[target]=0             invis[target]=invischarge-1         }     } } public h(id){     client_print(id,print_chat,"HP %i,AP %i",get_user_health(id),get_user_armor(id)) } public client_disconnect(id){     Disable_Item(id) } public Enable_Item(id) {     gHasCovenantPower[id]=1     if(!task_exists(id)){         set_task(1.03, "shieldloop", id, "", 0, "b")     }     ldt[id]=0     invis[id]=invischarge         cs_set_user_armor(id, get_pcvar_num(cvar_shieldap),CS_ARMOR_VESTHELM)     set_user_health(id,get_pcvar_num(cvar_hp))         return PLUGIN_HANDLED }     public Disable_Item(id) {     gHasCovenantPower[id]=0     remove_task(id)         return PLUGIN_HANDLED } public shieldloop(id){     ldt[id]--         if(invis[id]==invischarge){         client_print(id,print_chat,"[OWNAGE HALO 2 INVISIBLITY] Invisiblity charged! Press F to use!")         client_print(id,print_center,"[OWNAGE HALO 2 INVISIBLITY] Invisiblity charged! Press F to use!")         client_cmd(id,"spk sound/buttons/button7")         client_cmd(id,"spk sound/buttons/button7")                     }     invis[id]++ } public client_PreThink(id){     //client_print(id,print_console,"halo shield task")     //ldt[id]--     if( is_user_alive(id) && gHasCovenantPower[id]){                 hp[id] = get_user_health(id)             new playerarmor = get_user_armor(id)                         if(hp[id]!=lasthp[id]){             ldt[id]=8             if(hp[id]<99){                 message_begin( MSG_ONE_UNRELIABLE , gMsgScreenFade , {0,0,0} ,id );                 write_short( (1<<9) ); // duration                 write_short( (1<<9) ); // hold time                 write_short( (1<<12) ); // fade type                 write_byte( 120 ); //red                 write_byte( 0 ); //blue                 write_byte( 0 ); //green                 write_byte( 120 ); //alpha                 message_end();                 }             else{ //yellow                 if(playerarmor < get_pcvar_num(cvar_shieldap)){                     set_user_rendering( id, kRenderFxGlowShell, 20, 20, 0, kRenderNormal,  45);                     if(!task_exists(id+100)&&is_user_alive(id)){                         set_task(1.1,"noglow",id+100)                         }                 }             }         }         lasthp[id]=hp[id]         if(playerarmor < get_pcvar_num(cvar_shieldap)/5  && ldt[id] < 1){             cs_set_user_armor(id, get_pcvar_num(cvar_shieldap),CS_ARMOR_VESTHELM)             set_user_health(id,get_pcvar_num(cvar_hp))             client_cmd(id,"stopsound")             client_cmd(id,"spk sound/items/suitchargeok1")                         if( playerarmor < 1){                 client_cmd(id,"spk sound/items/suitchargeok1")                 client_cmd(id,"spk sound/items/suitchargeok1")             }                         client_print(id,print_center,"Your energy shields have recharged")                         set_user_rendering( id, kRenderFxGlowShell, 0, 155, 0, kRenderNormal, 20 );             if(!task_exists(id+100)&&is_user_alive(id)){                 set_task(1.8,"noglow",id+100)             }                         message_begin( MSG_ONE_UNRELIABLE , gMsgScreenFade , {0,0,0} ,id );             write_short( (1<<10) ); // duration             write_short( (1<<10) ); // hold time             write_short( (1<<12) ); // fade type             write_byte( 0 ); //red             write_byte( 255 ); //green             write_byte( 0); //blue             write_byte( 120 ); //alpha             message_end();         }         else if( playerarmor < get_pcvar_num(cvar_shieldap) && ldt[id] < 1){             cs_set_user_armor(id, get_pcvar_num(cvar_shieldap),CS_ARMOR_VESTHELM)             set_user_health(id,get_pcvar_num(cvar_hp))                         client_cmd(id,"spk sound/items/suitchargeok1")                         set_user_rendering( id, kRenderFxGlowShell, 0, 150, 0, kRenderNormal, 20 );             if(!task_exists(id+100)&&is_user_alive(id)){                 set_task(1.8,"noglow",id+100)             }                                     message_begin( MSG_ONE_UNRELIABLE , gMsgScreenFade , {0,0,0} ,id );             write_short( (1<<9) ); // duration             write_short( (1<<9) ); // hold time             write_short( (1<<12) ); // fade type             write_byte( 0 ); //red             write_byte( 255 ); //g             write_byte( 0); //b             write_byte( 60 ); //alpha             message_end();         }                     //new playerhp = get_user_health(id)                 if(hp[id] < 99&&playerarmor <1){             client_print(id,print_center,"Your shields are low, take cover!")             set_user_rendering( id, kRenderFxGlowShell, 15, 0,17, kRenderNormal, 40);                 }                 new sethp = get_pcvar_num(cvar_hp)                 if(hp[id]!=sethp){                         new missinghp = (sethp-hp[id])                         if( playerarmor>=missinghp){                 new damageap = playerarmor - missinghp                 cs_set_user_armor(id, damageap ,CS_ARMOR_VESTHELM)                 set_user_health(id,sethp)             }             else if( playerarmor > 0){                 set_user_health(id,hp[id]+playerarmor)                 set_user_armor(id,0)             }         }     }     return PLUGIN_CONTINUE } public noglow(zomg){     new idtemp=zomg-100     if(is_user_alive(idtemp)&&is_user_connected(idtemp)){         set_user_rendering( idtemp, kRenderFxGlowShell, 0, 0,0, kRenderNormal, 16 );     } }
Ownage is offline
Ownage
BANNED
Join Date: Jul 2007
Location: I don't know
Old 07-13-2007 , 15:03   Re: set model + prevent crash
Reply With Quote #9

something weird: when i only set the terrorists to mc, and on round start all mc get dumped, not the cts, even thou the set model is not called
Ownage is offline
Ownage
BANNED
Join Date: Jul 2007
Location: I don't know
Old 07-16-2007 , 13:58   Re: set model + prevent crash
Reply With Quote #10

lol i made it z so its temperarly disabled

precache has nothing to do with the crashing, just that half life engine sucks at changing models
Ownage is offline
Reply


Thread Tools
Display Modes

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 21:31.


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