AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Question about register_touch() (https://forums.alliedmods.net/showthread.php?t=184445)

Ang52 05-05-2012 10:30

Question about register_touch()
 
if i will do this:

PHP Code:

#include < amxmodx >
#include < engine >

public plugin_init( )
{
    
register_touch"player""grenade""TouchEntity" );


it should called when player touch grenade right.
so how i sets the type of the grenade?

<VeCo> 05-05-2012 11:04

Re: Question about register_touch()
 
Check the grenade's entity model.

claudiuhks 05-05-2012 11:07

Re: Question about register_touch()
 
I don't recommend to use Engine :nono:

Try hooking it with Ham Sandwich

PHP Code:

RegisterHamHam_Touch"weapon_hegrenade""OnHegreadeTouch" );

public 
OnHegrenadeTouchiTouchediToucher )
{
  static 
MaxClients; if( !MaxClients MaxClients get_maxplayers( );

  if( 
iTouched MaxClients )
  {
    
// iTouched is player and iToucher is hegrenade
  
}

  else if( 
iToucher MaxClients )
  {
    
// iTouched is hegrenade and iToucher is player
  
}



Ang52 05-05-2012 11:37

Re: Question about register_touch()
 
Quote:

Originally Posted by claudiuhks (Post 1702639)
I don't recommend to use Engine :nono:

Try hooking it with Ham Sandwich

PHP Code:

RegisterHamHam_Touch"weapon_hegrenade""OnHegreadeTouch" );

public 
OnHegrenadeTouchiTouchediToucher )
{
  static 
MaxClients; if( !MaxClients MaxClients get_maxplayers( );

  if( 
iTouched MaxClients )
  {
    
// iTouched is player and iToucher is hegrenade
  
}

  else if( 
iToucher MaxClients )
  {
    
// iTouched is hegrenade and iToucher is player
  
}



thanks for show me a second way.
but why you're not recommend to use Engine for this.

<VeCo> 05-05-2012 11:41

Re: Question about register_touch()
 
Thrown grenade entity classname is "grenade", not "weapon_hegrenade".

Engine or hamsandwich - there isn't really a difference in this case, it's depending on what do you need it for and what do you want to use.

Backstabnoob 05-05-2012 11:46

Re: Question about register_touch()
 
PHP Code:

#include < amxmodx >
#include < engine >


public plugin_init() 
{
    
register_touch"player""grenade""TouchEntity" )
}

public 
TouchEntityplayerent )
{
    new 
Model20 ]
    
entity_get_stringentEV_SZ_modelModelcharsmaxModel ) )
    
    if( 
containiModel"flashbang" ) != -)
        
// touched flashbang


If you want to block the touch, you'll have to hook both player -> grenade and grenade -> player touches.

Also there's nothing wrong in using engine for this purpose.

Ang52 05-05-2012 12:13

Re: Question about register_touch()
 
Thank you all for your help.

claudiuhks 05-05-2012 12:39

Re: Question about register_touch()
 
Quote:

Originally Posted by <VeCo> (Post 1702662)
Thrown grenade entity classname is "grenade", not "weapon_hegrenade".

Engine or hamsandwich - there isn't really a difference in this case, it's depending on what do you need it for and what do you want to use.

Alright, if you are referring at thrown grenade, you should hook grenade classname.
How could you say there's no difference between Engine and Ham Sandwich?
Engine is doing many computations than Ham Sandwich :rtfm::rtfm::rtfm::rtfm:

Backstabnoob 05-05-2012 15:14

Re: Question about register_touch()
 
No it doesn't matter here whether you use engine or ham sandwich as the difference is pretty much trivial, if any at all.


All times are GMT -4. The time now is 00:29.

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