AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   check grenade owner (https://forums.alliedmods.net/showthread.php?t=147345)

SpeeDeeR 01-08-2011 07:42

check grenade owner
 
Is it possible to get the grenade owner in FM_SetModel forward so it will set specific world model only if the owner is in specific team.
PHP Code:

public forward_model(entity,const model[])
{
    if(!
pev_valid(entity))
    {
        return 
FMRES_IGNORED;
    }
    
    if ( 
model] == 'm' && model] == 'w' && model] == '_' && model] == 'h')
    {
                
engfunc(EngFunc_SetModel,entity,model_nade_world);
                
fm_set_trail(entity,255,255,255,255);
                return 
FMRES_SUPERCEDE;
    }



DarkGod 01-08-2011 07:47

Re: check grenade owner
 
pev_owner ?

hleV 01-08-2011 08:24

Re: check grenade owner
 
The entity's owner is not yet set in SetModel forward. You could set entity's nextthink to get_gametime() + 0.01 or use a single StartFrame and check the owner there.

SpeeDeeR 01-08-2011 08:46

Re: check grenade owner
 
Can you show me the StarFrame way ?

hleV 01-12-2011 07:11

Re: check grenade owner
 
Code:
#include <cstrike>   new Entity, Forward;   public forward_model(entity,const model[]) {     if(!pev_valid(entity))     {         return FMRES_IGNORED;     }         if ( model[ 0 ] == 'm' && model[ 7 ] == 'w' && model[ 8 ] == '_' && model[ 9 ] == 'h')     {         Entity = entity;         Forward = register_forward(FM_StartFrame, "StartFrame");     } }   public StartFrame() {     switch (cs_get_user_team(pev(Entity, pev_owner)))     {         case CS_TEAM_T: engfunc(EngFunc_SetModel,entity,model_nade_world);         case CS_TEAM_CT: engfunc(EngFunc_SetModel,entity,model_nade_world);     }       fm_set_trail(entity,255,255,255,255);     unregister_forward(FM_StartFrame, Forward); }

Arkshine 01-12-2011 08:01

Re: check grenade owner
 
Quote:

Originally Posted by hleV (Post 1388849)
The entity's owner is not yet set in SetModel forward. You could set entity's nextthink to get_gametime() + 0.01 or use a single StartFrame and check the owner there.

It's well set before SetModel on throw.

SpeeDeeR 01-12-2011 12:26

Re: check grenade owner
 
Yeap, that worked hleV, thanks.

Arkshine 01-12-2011 12:41

Re: check grenade owner
 
pev_owner is enough if you need to get the owner when you throw a grenade.

hleV 01-12-2011 12:50

Re: check grenade owner
 
Quote:

Originally Posted by Arkshine (Post 1391920)
It's well set before SetModel on throw.

Oh. I guess it's not like in ESF for "aura" entity.

Arkshine 01-12-2011 13:44

Re: check grenade owner
 
Yes, to be more precise, SetModel with "models/w_hegrenade.mdl" is called :
  • when you pickup a grenade, it spawns a weapon_hegrenade entity ; owner is not set yet.
  • when you throw a grenade, it spawns a grenade entity ; owner is well set before.


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

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