AlliedModders

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

ironskillz1 01-19-2013 10:47

DodgeBall
 
Okay so how can i make so when you trow a dodgeball it will disappear after 4 seconds on the ground
and is it any way i can do so the model is on the ground when i throw a dodgeball its half in the ground and half up

Code:

public Ham_Touch_Grenade_Pre( iEntity, id )
{
if( GAME_SNOWBALL <= g_iCurrentGame <= GAME_ZMBOMBS || g_iCurrentGame == GAME_SNOWBALL )
{
 if(is_user_alive(id))
 {
  ExecuteHamB(Ham_Killed, id, pev(iEntity, pev_owner), 0)
 
  remove_entity(iEntity)
 }
}
}
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
}
public think_grenade(ent)
{
 new model[32];
 entity_get_string(ent, EV_SZ_model, model, 31)
 
 if(equali(model,"models/w_dodgeball.mdl"))
 {
  return PLUGIN_CONTINUE
 }
 
 // stop grenade from blowing up
 return PLUGIN_HANDLED
}


ironskillz1 01-20-2013 07:18

Re: DodgeBall
 
I did this code it removes all dodgeball snowball zombiebomb with a 5 seconds task
so sometimes when you throw it dispear exactly when you throw it
how can i do so each dodgeball/snowball/zombiebomb dispear 5 seconds after you throw it

Code:

public remove()
{
 new ent = - 1, model[32]
 while((ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "grenade")))
 {
  pev(ent, pev_model, model, 32)
  if (equal(model, "models/SWE-KUNG/w_dodgeball.mdl") || equal(model, "models/SWE-KUNG/w_snowball.mdl") || equal(model, "models/SWE-KUNG/w_zombiebomb.mdl"))
  {
  engfunc(EngFunc_RemoveEntity, ent)
  }
 }
}


AngeIII 01-20-2013 07:31

Re: DodgeBall
 
PHP Code:

public remove_ent(iEnt)
{
     if(
pev_valid(iEnt))
         
engfunc(EngFunc_RemoveEntity,iEnt);
 } 

and somewhere set task -> set_task(5.0,"remove_ent",entity_id);
for example in set_model function.

but inside touch you should remove_task(entity_id). cause it can double remove..so this is bad..

ironskillz1 01-20-2013 08:20

Re: DodgeBall
 
Nothing disappears now :S
code
Code:

public remove_ent(iEnt)
{
if(pev_valid(iEnt))
engfunc(EngFunc_RemoveEntity,iEnt);
}

Code:

public Ham_Touch_Grenade_Pre( iEntity, id, ent, entity_id)
{
if( GAME_SNOWBALL <= g_iCurrentGame <= GAME_ZMBOMBS || g_iCurrentGame == GAME_SNOWBALL )
{
 if(is_user_alive(id))
 {
  ExecuteHamB(Ham_Killed, id, pev(iEntity, pev_owner), 0)
 
  remove_entity(iEntity)
  remove_task(entity_id)
  }
 }
}
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
}
public think_grenade(iEntity, ent, entity_id)
{
if( GAME_SNOWBALL <= g_iCurrentGame <= GAME_ZMBOMBS || g_iCurrentGame == GAME_SNOWBALL || g_iCurrentGame == GAME_ANGRYBIRDS)
{
 new model[32];
 entity_get_string(ent, EV_SZ_model, model, 31)
 
 if(equali(model,"models/w_dodgeball.mdl"))
 {
  return PLUGIN_CONTINUE
 }
 
 // stop grenade from blowing up
 set_task(5.0,"remove_ent",entity_id);
 return PLUGIN_HANDLED
 }
}


AngeIII 01-20-2013 08:51

Re: DodgeBall
 
you have a lot of mistakes..

PHP Code:

public Ham_Touch_Grenade_PreiEntityid )
{
if( 
GAME_SNOWBALL <= g_iCurrentGame <= GAME_ZMBOMBS || g_iCurrentGame == GAME_SNOWBALL )
{
 if(
is_user_alive(id))
 {
  
ExecuteHamB(Ham_Killedidpev(iEntitypev_owner), 0)
 
  
remove_entity(iEntity)
  if(
task_exists(iEntity))
    
remove_task(iEntity);
 }
}
}
public 
fwdSetModel(ent,const model[])

if(!
pev_valid(ent) || !equal(model,"models/w_hegrenade.mdl")) 
 return 
FMRES_IGNORED
 
 
switch(g_iCurrentGame)
 {
  case 
GAME_DGBALLengfunc(EngFunc_SetModelentg_szDodgeball_World)
   case 
GAME_ZMBOMBSengfunc(EngFunc_SetModelentg_szZombiebomb_World)
   case 
GAME_SNOWBALLengfunc(EngFunc_SetModelentg_szSnowball_World)
   case 
GAME_ANGRYBIRDSengfunc(EngFunc_SetModelentg_szAngryBirds_World)
   default: return 
FMRES_IGNORED
 
}
  
set_task(5.0,"delete_it",ent);
 return 
FMRES_SUPERCEDE
}
public 
think_grenade(ent
{
 new 
model[32];
 
entity_get_string(entEV_SZ_modelmodel31)
 
 if(
equali(model,"models/w_dodgeball.mdl")) 
 {
  return 
PLUGIN_CONTINUE
 
}
 
 
// stop grenade from blowing up
 
return PLUGIN_HANDLED
}

public 
delete_it(iEnt)
{
     if(
pev_valid(iEnt))
         
engfunc(EngFunc_RemoveEntity,iEnt);



ironskillz1 01-20-2013 09:13

Re: DodgeBall
 
Quote:

Originally Posted by AngeIII (Post 1876788)
you have a lot of mistakes..

PHP Code:

public Ham_Touch_Grenade_PreiEntityid )
{
if( 
GAME_SNOWBALL <= g_iCurrentGame <= GAME_ZMBOMBS || g_iCurrentGame == GAME_SNOWBALL )
{
 if(
is_user_alive(id))
 {
  
ExecuteHamB(Ham_Killedidpev(iEntitypev_owner), 0)
 
  
remove_entity(iEntity)
  if(
task_exists(iEntity))
    
remove_task(iEntity);
 }
}
}
public 
fwdSetModel(ent,const model[])

if(!
pev_valid(ent) || !equal(model,"models/w_hegrenade.mdl")) 
 return 
FMRES_IGNORED
 
 
switch(g_iCurrentGame)
 {
  case 
GAME_DGBALLengfunc(EngFunc_SetModelentg_szDodgeball_World)
   case 
GAME_ZMBOMBSengfunc(EngFunc_SetModelentg_szZombiebomb_World)
   case 
GAME_SNOWBALLengfunc(EngFunc_SetModelentg_szSnowball_World)
   case 
GAME_ANGRYBIRDSengfunc(EngFunc_SetModelentg_szAngryBirds_World)
   default: return 
FMRES_IGNORED
 
}
  
set_task(5.0,"delete_it",ent);
 return 
FMRES_SUPERCEDE
}
public 
think_grenade(ent
{
 new 
model[32];
 
entity_get_string(entEV_SZ_modelmodel31)
 
 if(
equali(model,"models/w_dodgeball.mdl")) 
 {
  return 
PLUGIN_CONTINUE
 
}
 
 
// stop grenade from blowing up
 
return PLUGIN_HANDLED
}
 
public 
delete_it(iEnt)
{
     if(
pev_valid(iEnt))
         
engfunc(EngFunc_RemoveEntity,iEnt);



WTF my sever crash when i have this code

if i throw some dodgeball they disappears but the server crash random after

AngeIII 01-20-2013 09:58

Re: DodgeBall
 
i think it because you need some more checks.. and also i dont see full code so i dont know if you really correct use that. but btw you can change function definition instead of pev_valid, engfunc remove ent. to server_print("debug delete_id called with ent_id: %d",iEnt);
and check what happens.
also see a logs files, also check the console, also check other plugins.. also you can add some server_print("debug line X"); // where x is a some line of code.
to check in what place server crashes, think it is because setmodel called more that twice.. so you need to check if task_exists -> delete task, and after set it again..

ironskillz1 01-20-2013 11:29

Re: DodgeBall
 
tried evrything but either it doesnt work or it crashes



have any one else any ides?

zEEDu 01-21-2013 07:35

Re: DodgeBall
 
No, because this plugin you're trying t fix is an very old version of Mokens gamemenu that he made for Scandic-Gamers for private use. So i won't help you.

AngeIII 01-21-2013 07:51

Re: DodgeBall
 
ironskillz1, just remove everything what you added from my code and use older version, after that step-by-step add the needed lines. and after each step check how plugins work..


All times are GMT -4. The time now is 13:23.

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