AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Server Crash (https://forums.alliedmods.net/showthread.php?t=207491)

ironskillz1 02-03-2013 06:19

Server Crash
 
Why do my server Crash when im using kill code
Code:

set_pev(ent, pev_flags, pev(ent, pev_flags) | FL_KILLME);
¨
or
Code:

engfunc(EngFunc_RemoveEntity, ent);
Code:

register_forward(FM_SetModel, "fwdSetModel", 1);
Code:

public fwdSetModel(ent,const model[])
{
 if(!pev_valid(ent) || !equal(model,"models/w_hegrenade.mdl"))
  return FMRES_IGNORED
 
 switch(g_iCurrentGame)
 {
  case GAME_DGBALL: engfunc(EngFunc_SetModel, ent, g_szDodgeball_World)
  case GAME_ZMBOMBS: engfunc(EngFunc_SetModel, ent, g_szZombiebomb_World)
  case GAME_SNOWBALL: engfunc(EngFunc_SetModel, ent, g_szSnowball_World)
  case GAME_ANGRYBIRDS: engfunc(EngFunc_SetModel, ent, g_szAngryBirds_World)
  default: return FMRES_IGNORED
 }
 return FMRES_SUPERCEDE
set_task( 4.0, "KILL")
}

Code:

public KILL(ent)
{
engfunc(EngFunc_RemoveEntity, ent);
}

When i throw some Dodgeball they disspear after 4 seconds but then the server crash

Sylwester 02-03-2013 07:16

Re: Server Crash
 
Probably because variable ent in KILL function is 0. To make it store entity index you need to set task like this:
PHP Code:

set_task(4.0"KILL"ent

Also in code you posted set_task is never executed, and you should check if ent is valid in KILL function before trying to remove it.

ironskillz1 02-03-2013 10:39

Re: Server Crash
 
Quote:

Originally Posted by Sylwester (Post 1886132)
Probably because variable ent in KILL function is 0. To make it store entity index you need to set task like this:
PHP Code:

set_task(4.0"KILL"ent

Also in code you posted set_task is never executed, and you should check if ent is valid in KILL function before trying to remove it.

Still crashes
Code:

public fwdSetModel(ent,const model[])
{
 if(!pev_valid(ent) || !equal(model,"models/w_hegrenade.mdl"))
  return FMRES_IGNORED
 
 switch(g_iCurrentGame)
 {
  case GAME_DGBALL: engfunc(EngFunc_SetModel, ent, g_szDodgeball_World)
  case GAME_ZMBOMBS: engfunc(EngFunc_SetModel, ent, g_szZombiebomb_World)
  case GAME_SNOWBALL: engfunc(EngFunc_SetModel, ent, g_szSnowball_World)
  case GAME_ANGRYBIRDS: engfunc(EngFunc_SetModel, ent, g_szAngryBirds_World)
  default: return FMRES_IGNORED
 }
 set_task(4.0, "KILL", ent)
 return FMRES_SUPERCEDE
}
public KILL(ent, const model[])
{
 if(!pev_valid(ent) || !equal(model,"models/w_hegrenade.mdl"))
 engfunc(EngFunc_RemoveEntity, ent);
}


hleV 02-03-2013 12:06

Re: Server Crash
 
You wrote that const model[] out of nowhere...

Sylwester 02-03-2013 12:29

Re: Server Crash
 
and the check in KILL function is wrong (right now you are trying to remove entity when it's not valid).

ironskillz1 02-03-2013 12:29

Re: Server Crash
 
Quote:

Originally Posted by hleV (Post 1886244)
You wrote that const model[] out of nowhere...

Works now thanks

ironskillz1 02-04-2013 09:40

Re: Server Crash
 
Quote:

Originally Posted by ironskillz1 (Post 1886257)
Works now thanks

Sorry its still crashes

When im spam throw dodgeball the server crashes
Code:

public fwdSetModel(ent,const model[])
{
 if(!pev_valid(ent) || !equal(model,"models/w_hegrenade.mdl"))
  return FMRES_IGNORED
 
 switch(g_iCurrentGame)
 {
  case GAME_DGBALL: engfunc(EngFunc_SetModel, ent, g_szDodgeball_World)
  case GAME_ZMBOMBS: engfunc(EngFunc_SetModel, ent, g_szZombiebomb_World)
  case GAME_SNOWBALL: engfunc(EngFunc_SetModel, ent, g_szSnowball_World)
  case GAME_ANGRYBIRDS: engfunc(EngFunc_SetModel, ent, g_szAngryBirds_World)
  default: return FMRES_IGNORED
 }
 set_task(4.0, "KILL", ent)
 return FMRES_SUPERCEDE
}
public KILL(ent)
{
 if(!pev_valid(ent))
return FMRES_IGNORED
 engfunc(EngFunc_RemoveEntity, ent);
}



All times are GMT -4. The time now is 20:32.

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