AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Model Changing in DoD (https://forums.alliedmods.net/showthread.php?t=22050)

Zor 12-17-2005 13:45

Model Changing in DoD
 
Hey all. I'm working on a new plugin. This plugin as the topic states is going to change models for admins in DoD. I have been doing some searching and located a cs_set_user_model. And then went into the code and found out how it works. But, no dice. I have tried register_forward(FM_SetModel) and register_event(ResetHUD) and then within each of these checked the model to be models/player.mdl and forced it to be a certain model. Now when I attempt to join and look at myself or other admins It stays the same. No model changes. So I'm posting the basic test code. Can someone give a shout if they see where the problem is.

Thanks, and Cheers!

Code:

register_event("ResetHUD", "handle_model", "b")
public handle_model(id)
{
        if(!is_user_connected(id) || !get_cvar_num("dod_am_enabled"))
                return PLUGIN_CONTINUE
       
        // Get Model
        new mdl[128]
        entity_get_string(id, EV_SZ_model, mdl, 127)
       
        new team = entity_get_int(id, EV_INT_team)
       
        if(contain(mdl, "player.mdl") && team > 0)
        {
                entity_set_string(id, EV_SZ_model, models[team - 1])
        }
       
        new temp[128]
        entity_get_string(id, EV_SZ_model, temp, 127)
        log_amx("entid: %d model: %s", id, temp)
               
        return PLUGIN_CONTINUE
}

Code:

register_forward(FM_SetModel, "handle_model")
public handle_model(id, const mdl[])
{
  if(!is_valid_ent(id) || !get_cvar_num("dod_am_enabled"))
      return FMRES_IGNORED

  new temp[128]
  new team = entity_get_int(id, EV_INT_team)
 
  if(contain(mdl, "models/player.mdl") && team > 0)
  {
      entity_set_string(id, EV_SZ_model, models[team - 1])
      entity_get_string(id, EV_SZ_model, temp, 127)
      log_amx("entid: %d model: %s", id, temp)

      return FMRES_SUPERCEDE
  }

  entity_get_string(id, EV_SZ_model, temp, 127)
  log_amx("entid: %d model: %s", id, temp) 
   
  return FMRES_IGNORED
}


Cheap_Suit 12-17-2005 15:01

Code:

/* The actual return value of the function, use these instead of PLUGIN_HANDLED etc when
 * returning from registered forwards.
 */
#define FMRES_HANDLED        2
#define FMRES_SUPERCEDE        4
#define FMRES_IGNORED        1
#define FMRES_OVERRIDE        3

Code:
register_forward(FM_SetModel, "handle_model") public handle_model(id, const mdl[]) {    if(!is_valid_ent(id) || !get_cvar_num("dod_am_enabled"))       return FMRES_IGNORED        new team = entity_get_int(id, EV_INT_team)        if(contain(mdl, "models/player.mdl") && team > 0)    {       entity_set_string(id, EV_SZ_model, models[team - 1])       return FMRES_SUPERCEDE    }        new temp[128]    entity_get_string(id, EV_SZ_model, temp, 127)    log_amx("entid: %d model: %s", id, temp)            return FMRES_IGNORED }

Zor 12-17-2005 16:11

@Cheap_Suit

Yeah did that, thanks though. Just that I got rid of the code cause I didn't think it was working. Then when I was doing this thread I used the code above and forgot to change the FM returns.

Cheers!

Cheap_Suit 12-17-2005 18:13

Might be this...
Code:
containi(mdl, ”models/player.mdl)
Proper Usage:
Code:
containi(mdl, ”models/player.mdl) != -1

Zor 12-17-2005 19:40

Nope, that just a redundant statement. I know that it gets that far with my code as at one point in time I have a log_amx command within the if statement.

Thanks, Cheers!

XxAvalanchexX 12-18-2005 04:34

Request a DoD model changing function. In the meantime, you can do what Target suggested:

Quote:

Originally Posted by T(+)rget
To get it working with FM you'd need to completely block ClientUserInfoChanged when model changing is occuring and also set SET_CLIENT_KEYVALUE in PlayerPostThink.

Its how it works in VexdUM, think CStrike module using pvdata offsets?


watch 12-18-2005 08:16

I've been trying to do this with tfc without using the tfc module because tfc_setmodel is the only function i use from it.

afaik entity_set_string EV_SZ_model just doesnt work for players

DispatchKeyValue(id,"replacement_model","Aqua fresh"); works in tfc but you have to respawn for it to take effect. How would i make it take effect immediately?

but i think replacement_model is a tfc specific function from item_tfgoal Is there an entity in DOD that allows you to change the playermodel

Zor 12-18-2005 09:54

@XxAvalanchexX

Thanks for the information. But I do have some questiong. I can understand what T(+)rget wrote. But the implementation is in question. Would I do the following for the ClientUserInfoChanged:

Code:

public client_infochanged(id)
{
    if(model has been changed && this is an admin)
    {
          change model back again
          return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}

As for the PlayerPostThink, that should be simple:

Code:

public client_PostThink(id)
{
 if(model has been changed && this is an admin)
    {
          change model back again
          return PLUGIN_HANDLED
    }
    return PLUGIN_CONTINUE
}

Now the thing is, will these overide the changes, I dont want to be changing the model a billion times as this will cause lagg at least I would assume. Could you or maybe T(+)rget give me some code to look at. I aint no slacker when it comes to coding. Just never played with this kinda stuff before.

Cheers!

Jordan 12-18-2005 11:36

entity_set_model????????????????????

You probably just could do this:

Code:
/* Plugin generated by AMXX-Studio */ #include <amxmodx> #include <amxmisc> #include <engine> #define PLUGIN "Admin Model" #define VERSION "1.0" #define AUTHOR "Zor" public plugin_init() {     register_plugin("Admin Model", "1.0", "Zor") } public plugin_precache()     precache_model("models/player.mdl") public client_putinserver(id){     new entid     if(is_user_admin(id))     entity_set_model(entid, "models/player.mdl")     return PLUGIN_HANDLED }

Why can't you do this?

watch 12-18-2005 11:48

ive tried entity_set_model before and it doesnt work with players


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

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