AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   register_touch dont work (https://forums.alliedmods.net/showthread.php?t=192447)

hitmany 08-10-2012 10:12

register_touch dont work
 
when I'm on a sprite, nothing happens
plugin_init
PHP Code:

register_touch("env_sprite""player""portal_touch"

PHP Code:

public set_portal(id)
{

    new 
g_ent
    
new Float:g_aim_origin[3]
    new 
Float:g_ent_angles[3]
    
set_pev(g_entpev_scale1.0 )
    
g_ent create_entity("env_sprite")
    
entity_set_string(g_entEV_SZ_classname"iportal")
    
engfunc(EngFunc_SetModelg_ent"sprites/portal.spr")
    
    static 
Float:normal[3]
    
    
fm_get_aim_origin_normal(idg_aim_originnormal)
    
normal[0] *= -1.0
    normal
[1] *= -1.0
    normal
[2] *= -1.0
    vector_to_angle
(normalg_ent_angles)
    
engfunc(EngFunc_SetOriging_entg_aim_origin)
    
set_pev(g_entpev_anglesg_ent_angles)
    
entity_set_size(g_ent,Float:{0.0,0.0,0.0},Float:{30.0,30.0,30.0})
    
entity_set_int(g_entEV_INT_solidSOLID_TRIGGER)
    
set_pev(g_entpev_rendermodekRenderTransAdd)
    
set_pev(g_entpev_renderamt220.0)
    
set_pev(g_entpev_framerate15.0 )
    
set_pev(g_entpev_spawnflagsSF_SPRITE_STARTON)
    
DispatchSpawn(g_ent)
    
set_pev(g_entpev_anglesg_ent_angles)
    
entity_set_edict(g_ent,EV_ENT_ownerid)
    
player_portals[id]++
    if(
player_portal[id] == 1)
    {
    
player_portal1[id] = g_ent
    client_print
(id,print_chat"POR %d",player_portal1[id])
    }
    else if(
player_portal[id] == 2)
    {
    
player_portal2[id] = g_ent
    client_print
(id,print_chat"POR %d",player_portal2[id])
    }


  return 
PLUGIN_CONTINUE;


touch
PHP Code:

public portal_touch(ptr,id)
{
 if(
is_user_alive(id))
 {
  static 
szClassName[32]
  
pev(ptrpev_classnameszClassNamesizeof szClassName 1)
  
  if(
equal(szClassName"iportal"))
  {
   return 
FMRES_IGNORED
  
if(player_portal1[id] == ptr)
        {
        new 
Float:fOrigin[3];
        
pev(player_portal2[id], pev_originfOrigin);
        
set_user_origin(id,fOrigin)
        
parseAngle(idplayer_portal1[id], player_portal2[id]);
        
client_print(id,print_chat"POR %d",player_portal2[id])
        }
        else if(
player_portal2[id] == ptr)
        {
        new 
Float:fOrigin[3];
        
pev(player_portal1[id], pev_originfOrigin);
        
set_user_origin(id,fOrigin)
        
parseAngle(idplayer_portal2[id], player_portal1[id]);
        
client_print(id,print_chat"POR %d",player_portal1[id])
    }    }
  
   }
   
server_cmd("say Touch ID: %d",id
   
 return 
FMRES_IGNORED


other used functions
Spoiler

isotonic 08-10-2012 17:35

Re: register_touch dont work
 
May be instead of
PHP Code:

if(equal(szClassName"iportal")) 

you should use
PHP Code:

if(!equal(szClassName"iportal")) 


ConnorMcLeod 08-10-2012 18:04

Re: register_touch dont work
 
Quote:

Originally Posted by isotonic (Post 1768723)
May be instead of
PHP Code:

if(equal(szClassName"iportal")) 

you should use
PHP Code:

if(!equal(szClassName"iportal")) 


:down::down::down::down:



Try setting EV_INT_solid to SOLID_TRIGGER, i think env_sprite by default is SOLID_NOT so touch is null and never sent.

hitmany 08-11-2012 10:58

Re: register_touch dont work
 
Quote:

Originally Posted by ConnorMcLeod (Post 1768748)
:down::down::down::down:

Try setting EV_INT_solid to SOLID_TRIGGER, i think env_sprite by default is SOLID_NOT so touch is null and never sent.

Its not help me(
Why he is not register touch??

PHP Code:

public portal_touch(ptr,id)
{
 if(
is_user_alive(id))
 {
  static 
szClassName[32]
  
pev(ptrpev_classnameszClassNamesizeof szClassName 1)
  
  if(!
equal(szClassName"iportal"))
    return 
FMRES_IGNORED
    
  
if(player_portal1[id] == ptr)
        {
        new 
Float:fOrigin[3];
              
pev(player_portal2[id], pev_originfOrigin);
        
//set_pev(id, pev_origin, fOrigin);
        
set_user_origin(id,fOrigin)
        
parseAngle(idplayer_portal1[id], player_portal2[id]);
        
client_print(id,print_chat"POR %d",player_portal2[id])
        }
        else if(
player_portal2[id] == ptr)
        {
        new 
Float:fOrigin[3];
              
pev(player_portal1[id], pev_originfOrigin);
        
//set_pev(id, pev_origin, fOrigin);
        
set_user_origin(id,fOrigin)
        
parseAngle(idplayer_portal2[id], player_portal1[id]);
        
client_print(id,print_chat"POR %d",player_portal1[id])
        }    
  
   }
   
server_cmd("say Touch ID: %d",id
   
 return 
FMRES_IGNORED



Arkshine 08-11-2012 12:08

Re: register_touch dont work
 
- Use "iportal" instead of "env_sprite" in register_touch
- Make sure player_portal1[id] is holding the right value, and is set also.
- Add debug test to check forward is well called and such.


All times are GMT -4. The time now is 05:49.

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