AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [RESOLVED] Replacing player models using FAKEMETA (https://forums.alliedmods.net/showthread.php?t=48260)

slmclarengt 12-08-2006 19:55

[RESOLVED] Replacing player models using FAKEMETA
 
Please check this code - to me, it looks fine, but my server will not start. Looking to replace the default CS models with Christmas models.

Code:
 #include <amxmodx>  #include <fakemeta>  #define TREE "models/c14-cristmastree.mdl"  #define ARCTIC "models/player/arctic/arctic.mdl"  #define GUERILLA "models/player/guerilla/guerilla.mdl"  #define LEET "models/player/leet/leet.mdl"  #define MILITIA "models/player/militia/militia.mdl"  #define TERROR "models/player/terror/terror.mdl"  public plugin_init()  {     register_plugin("Model replacement (christmas)","0.10","Avalanche");     register_forward(FM_SetModel,"fw_setmodel");  }  public plugin_precache()  {     precache_model(TREE);     precache_model(ARCTIC);     precache_model(GUERILLA);     precache_model(LEET);     precache_model(MILITIA);     precache_model(TERROR);  }  public fw_setmodel(ent,model[])  {     if(equali(model,"models/w_c4.mdl"))     {         engfunc(EngFunc_SetModel,ent,TREE);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/arctic/arctic.mdl"))     {         engfunc(EngFunc_SetModel,ent,ARCTIC);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/guerilla/guerilla.mdl"))     {         engfunc(EngFunc_SetModel,ent,GUERILLA);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/leet/leet.mdl"))     {         engfunc(EngFunc_SetModel,ent,LEET);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/militia/militia.mdl"))     {         engfunc(EngFunc_SetModel,ent,MILITIA);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/terror/terror.mdl"))     {         engfunc(EngFunc_SetModel,ent,TERROR);         return FMRES_SUPERCEDE;     }     return FMRES_IGNORED;  }

it's from avalanche but I modified it to do more than one model.

Slmclarengt

VEN 12-09-2006 06:54

Re: Replacing models using FAKEMETA (simple)
 
Seems like it's the problem with your "models/c14-cristmastree.mdl"

Do you realise that this pointless?
Quote:

if(equali(model,"models/player/terror/terror.mdl"))
{
engfunc(EngFunc_SetModel,ent,TERROR);
return FMRES_SUPERCEDE;
}
TERROR equal to "models/player/terror/terror.mdl"

slmclarengt 12-09-2006 21:10

Re: Replacing models using FAKEMETA (simple)
 
Quote:

Originally Posted by VEN (Post 412724)
Seems like it's the problem with your "models/c14-cristmastree.mdl"

Do you realise that this pointless?TERROR equal to "models/player/terror/terror.mdl"

Yes, it is "redundant" not pointless, because it would check if the model existed and replace it (but it never worked). Now it looks like this:

Code:
 #include <amxmodx>  #include <fakemeta>  #define TREE "models/c14-cristmastree.mdl"  #define ARCTIC "models/player/arctic/arctic-christmas.mdl"  #define GUERILLA "models/player/guerilla/guerilla-christmas.mdl"  #define LEET "models/player/leet/leet-christmas.mdl"  #define MILITIA "models/player/militia/militia.mdl"  #define TERROR "models/player/terror/terror-christmas.mdl"  public plugin_init()  {     register_plugin("Model replacement (christmas)","0.10","Avalanche");     register_forward(FM_SetModel,"fw_setmodel");  }  public plugin_precache()  {     precache_model(TREE);     precache_model(ARCTIC);     precache_model(GUERILLA);     precache_model(LEET);     precache_model(MILITIA);     precache_model(TERROR);  }  public fw_setmodel(ent,model[])  {     if(equali(model,"models/w_c4.mdl"))     {         engfunc(EngFunc_SetModel,ent,TREE);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/arctic/arctic.mdl"))     {         engfunc(EngFunc_SetModel,ent,ARCTIC);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/guerilla/guerilla.mdl"))     {         engfunc(EngFunc_SetModel,ent,GUERILLA);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/leet/leet.mdl"))     {         engfunc(EngFunc_SetModel,ent,LEET);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/militia/militia.mdl"))     {         engfunc(EngFunc_SetModel,ent,MILITIA);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/terror/terror.mdl"))     {         engfunc(EngFunc_SetModel,ent,TERROR);         return FMRES_SUPERCEDE;     }     return FMRES_IGNORED;  }

The christmas tree bomb works perfectly, but not all the player models. The models download onto the computer, but do not actually show in-game... WHY!!??

Slmclarengt

VEN 12-10-2006 05:22

Re: Replacing models using FAKEMETA (simple, but help plz)
 
Because player model isn't set like that. It uses "model" ClientKeyValue. You can use cstrike cs_set_user_model or port it to FM.

slmclarengt 12-10-2006 15:01

Re: Replacing models using FAKEMETA (simple, but help plz)
 
Then I tried
Code:
public client_connect(id) {     if(is_user_connected(id))     {         cs_set_user_model(id, TREE) //bomb         cs_set_user_model(id, ARCTIC) //T         cs_set_user_model(id, GUERILLA) //T         cs_set_user_model(id, LEET) //T         cs_set_user_model(id, MILITIA) //T         cs_set_user_model(id, TERROR) //T     }     else         set_task(5.0, "client_connect", id) }

Instead of

Code:
public fw_setmodel(ent,model[])  {     if(equali(model,"models/w_c4.mdl"))     {         engfunc(EngFunc_SetModel,ent,TREE);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/arctic/arctic.mdl"))     {         engfunc(EngFunc_SetModel,ent,ARCTIC);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/guerilla/guerilla.mdl"))     {         engfunc(EngFunc_SetModel,ent,GUERILLA);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/leet/leet.mdl"))     {         engfunc(EngFunc_SetModel,ent,LEET);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/militia/militia.mdl"))     {         engfunc(EngFunc_SetModel,ent,MILITIA);         return FMRES_SUPERCEDE;     }     if(equali(model,"models/player/terror/terror.mdl"))     {         engfunc(EngFunc_SetModel,ent,TERROR);         return FMRES_SUPERCEDE;     }     return FMRES_IGNORED;  }

The cs_set_user_model actually screwed my server over because I don't know which function to call, client_connect or client_authorized or neither? I am newb in this regard, but understand the main concepts.

Slmclarengt

[ --<-@ ] Black Rose 12-10-2006 15:09

Re: Replacing models using FAKEMETA (simple, but help plz)
 
Quote:

Originally Posted by slmclarengt (Post 413461)
The cs_set_user_model actually screwed my server over because I don't know which function to call, client_connect or client_authorized or neither?

ResetHUD event, check if player is alive and connected.

This is how to use cs_set_user_model().
Code:
#include <amxmodx> #include <cstrike> public plugin_init() {     register_plugin("", "", "")     register_event("ResetHUD", "event_ResetHUD", "be") } public plugin_precache()     precache_model("models/player/christmas/christmas.mdl")     public event_ResetHUD(id)     cs_set_user_model(id, "christmas")

slmclarengt 12-10-2006 15:24

Re: Replacing models using FAKEMETA (simple, but help plz)
 
Quote:

Originally Posted by [ --<-@ ] Black Rose (Post 413467)
ResetHUD event, check if player is alive and connected.

This is how to use cs_set_user_model().
Code:
#include <amxmodx> #include <cstrike> public plugin_init() {     register_plugin("", "", "")     register_event("ResetHUD", "event_ResetHUD", "be") } public plugin_precache()     precache_model("models/player/leet/leet.mdl")     public event_ResetHUD(id)     cs_set_user_model(id, "leet")

So presumably I have to replace the CS model with the custom model I want replaced and name it the same name.

IE: I take the christmas model, change name from christmas.mdl to leet.mdl, then use the plugin to use the custom leet.mdl?

Slmclarengt

[ --<-@ ] Black Rose 12-10-2006 15:25

Re: Replacing models using FAKEMETA (simple, but help plz)
 
No, there is a model named leet.
Edited code

slmclarengt 12-10-2006 15:27

Re: Replacing models using FAKEMETA (simple, but help plz)
 
Quote:

Originally Posted by [ --<-@ ] Black Rose (Post 413479)
No, there is a model named leet.
Edited code

But then how would christmas know to replace leet?

Slmclarengt

[ --<-@ ] Black Rose 12-10-2006 15:46

Re: Replacing models using FAKEMETA (simple, but help plz)
 
Something like...
Code:
#include <amxmodx> #include <cstrike> #include <fakemeta> public plugin_init() {     register_plugin("", "", "")     register_forward(FM_SetModel,"fw_setmodel"); } public plugin_precache()     precache_model("models/player/christmas/christmas.mdl") public fw_setmodel(ent,model[]) {         if ( equal(model, "models/player/leet/leet.mdl") )         cs_set_user_model(ent, "christmas") }


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

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