AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Touch - yes again (https://forums.alliedmods.net/showthread.php?t=84572)

Dr.G 01-28-2009 10:11

Touch - yes again
 
I am about to make a plugin that block some grenade exploits in dod_avalanche. I can easyly create some small solid boxes that makes the grenades bounch off when ppl try to toss a nade into one of those spots, but since its solids it makes some odd "bumps" in the map that i dont like.

So is it possible catch when a grenade touches that entity i have created, and send the grenade eg. outside the map? And would it be possible catch the owner of the grenade and give him a warning and/or even add admin immunity?

Thanks in advance!

xPaw 01-28-2009 11:45

Re: Touch - yes again
 
yes it is

PHP Code:

RegisterHam(Ham_Touch"grenade""fwd_Ham_Touch");

// ...

public fwd_Ham_Touch(ident)
{
    
// ...



Dr.G 01-28-2009 12:00

Re: Touch - yes again
 
Iam pretty sure HAM cant catch it since the entity i made to block those exploits isnt default entitys...

I did tryed like this but nothing happend...

PHP Code:

register_forward(FM_Touch,"hook_touch"

PHP Code:

public hook_touch(ptr,ptd)
{
 if(
get_pcvar_num(p_enable))
 {
  static 
szClassName[32]
  
pev(ptrpev_classnameszClassNamesizeof szClassName 1)
  
  if(
equali(szClassName,"weapon_handgrenade") || (equali(szClassName,"weapon_stickgreande")))
  {
   new 
obj_classname[32]
   
pev(ptdpev_classnameobj_classnamesizeof obj_classname 1)
   if(!
equali(obj_classname"nade_fix"))
    return 
FMRES_IGNORED
    
   
new Float:origin[3]
   
origin[0] = 200.0
   origin
[1] = 720.0
   origin
[2] = 440.0
   set_pev
(ptr,pev_origin,origin)
  }
 }
 return 
FMRES_IGNORED


And how bout the admin immunity...

Exolent[jNr] 01-28-2009 14:19

Re: Touch - yes again
 
Quote:

Originally Posted by Dr.G
Iam pretty sure HAM cant catch it since the entity i made to block those exploits isnt default entitys...

RegisterHamFromEntity()

ConnorMcLeod 01-28-2009 14:23

Re: Touch - yes again
 
You didn't made the grenade but the touched entity, to, RegisterHam will work with classname "grenade".
If you want to hook the touch with your custom entity, then you need to hook it with the initial classname (in most cases : "info_target"), but that's not what you want to do.
It's better to use ham for this touch ;)

Exolent[jNr] 01-28-2009 14:28

Re: Touch - yes again
 
Also
PHP Code:

   new Float:origin[3]
   
origin[0] = 200.0
   origin
[1] = 720.0
   origin
[2] = 440.0
   set_pev
(ptr,pev_origin,origin

Why are you creating a new variable instead of using the values you want?
PHP Code:

   set_pev(ptr,pev_origin,Float:{200.0,720.0,440.0}) 


Dr.G 01-28-2009 15:08

Re: Touch - yes again
 
So i need to register both entitys to the same forward?? Shiiit my brain is boiling....

ups that variable was a copy paste thing...

PHP Code:

RegisterHam(Ham_Touch"grenade""fwd_Ham_Touch"); 
RegisterHamFromEntity(Ham_Touch"nade_fix""fwd_Ham_Touch");
 
 
public 
fwd_Ham_Touch(ident); 

    
// ... 



ConnorMcLeod 01-28-2009 16:00

Re: Touch - yes again
 
No, only RegisterHam with "grenade" classname, or weapon_handgrenade or whatever is this entity classname.
If it's the same as cs, as soon as you have launched the nade, classname is "grenade" (in fact the launched nade is a new entity and the nade that you were holding doesn't exist anymore).

So, something like this :

PHP Code:

RegisterHam(Ham_Touch"grenade""Grenade_Touch")

public 
Grenade_TouchiNade iEnt )
{
    if( !
pev_validiEnt ) )
        return 
HAM_IGNORED
    
static szClassName[9]
    
pev(iEntpev_classnameszClassNamecharsmax(szClassName))
    if( !
equalszClassName"nade_fix") )
        return 
HAM_IGNORED
    engfunc
(Engfunc_RemoveEntityiNade)
    return 
HAM_SUPERCEDE



xPaw 01-29-2009 06:29

Re: Touch - yes again
 
ye Dr.G can you give me origins/ or already created entitys code, for block that bug pls

Dr.G 01-29-2009 19:19

Re: Touch - yes again
 
yea ofcource u can... i still cant catch that damn touch tho lol. Ill send the code tomorrow or so...


All times are GMT -4. The time now is 01:53.

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