AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [SOLVED] Using only 2 models in the game (https://forums.alliedmods.net/showthread.php?t=140004)

GalegO 10-08-2010 01:19

[SOLVED] Using only 2 models in the game
 
Hi Guys!

I'm trying to make my first plugin. And one thing I want is to use only one skin for each team ("urban" and "terror"). I've tried to adapt the various codes that I found in the forum but nothing worked. Could anyone help me?

PS: Plugin for Condition Zero

Thanks

EDIT: Now it's works :) Thanks!

hornet 10-08-2010 01:37

Re: Using only 2 models in the game
 
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

new mdlTs[]="terror";
new 
mdlCTs[]="urban";

public 
plugin_init() 
{
    
register_plugin("Team Models","1.0","hornet");
    
    
RegisterHam(Ham_Spawn,"player","PlayerSpawn");
}

public 
PlayerSpawn(id)
{
    if( 
cs_get_user_team(id) == CS_TEAM_CT )
    
cs_set_user_model(id,mdlCTs);
    else if( 
cs_get_user_team(id) == CS_TEAM_T)
    
cs_set_user_model(id,mdlTs);


Those player models don't need to be precached because the game does that automatically. But if you ever want to use custom models, then you'll need to precache them:

PHP Code:

public plugin_precache()
{
    
precache_model("models/player/customT/customT.mdl");
    
precache_model("models/player/customCT/customCT.mdl");



fysiks 10-08-2010 02:08

Re: Using only 2 models in the game
 
Use a switch for cs_get_user_team(id).

GalegO 10-08-2010 13:09

Re: Using only 2 models in the game
 
Thanks guys! This is correct use of switch?

PHP Code:

        switch(cs_get_user_team(id))
        {
            case 
1: (CS_TEAM_CT):
            {
                
cs_set_user_model(id,mdlCTs)
            }
            case 
2: (CS_TEAM_T):
            {
                
cs_set_user_model(id,mdlTs)
            }
        } 

PS: @fysiks, Give to you 5 stars in your thread about the User Lang for notepad++. Very Useful :) GOOD JOB MAN!!l

ConnorMcLeod 10-08-2010 13:21

Re: Using only 2 models in the game
 
No.

Also, use rather this plugin : http://forums.alliedmods.net/showthread.php?p=958925

And sets .ini file like :


Code:

"leet" "terror"
"arctic" "terror"
"gsg9" "urban"
"gign" "urban"
"sas" "urban"
"guerilla" "terror"
"militia" "terror"
"spetsnaz" "urban"

About your switch question :
PHP Code:

        switch(cs_get_user_team(id))
        {
            case 
CS_TEAM_T:
            {
                
cs_set_user_model(id,mdlTs)
            }
            case 
CS_TEAM_CT:
            {
                
cs_set_user_model(id,mdlCTs)
            }

        } 

But you would need tp register ham forward as post and not pre.
Anyway, use the linked plugin.

Zezima14 10-08-2010 13:29

Re: Using only 2 models in the game
 
Quote:

Originally Posted by hornet (Post 1318678)
PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <hamsandwich>

new mdlTs[]="terror";
new 
mdlCTs[]="urban";

public 
plugin_init() 
{
    
register_plugin("Team Models","1.0","hornet");
    
    
RegisterHam(Ham_Spawn,"player","PlayerSpawn");
}

public 
PlayerSpawn(id)
{
    if( 
cs_get_user_team(id) == CS_TEAM_CT )
    
cs_set_user_model(id,mdlCTs);
    else if( 
cs_get_user_team(id) == CS_TEAM_T)
    
cs_set_user_model(id,mdlTs);


Those player models don't need to be precached because the game does that automatically. But if you ever want to use custom models, then you'll need to precache them:

PHP Code:

public plugin_precache()
{
    
precache_model("models/player/customT/customT.mdl");
    
precache_model("models/player/customCT/customCT.mdl");



Change all in playerspawn for
PHP Code:

cs_set_user_modelid, (cs_get_user_team(id)==CS_TEAM_T) ? mdlTs mdlCTs 


YamiKaitou 10-08-2010 13:36

Re: Using only 2 models in the game
 
Quote:

Originally Posted by Zezima14 (Post 1319160)
Change all in playerspawn for
PHP Code:

cs_set_user_modelid, (cs_get_user_team(id)==CS_TEAM_T) ? mdlTs mdlCTs 


And if they are on CS_TEAM_SPEC?

GalegO 10-08-2010 13:44

Re: Using only 2 models in the game
 
Quote:

Originally Posted by ConnorMcLeod (Post 1319153)
No.

Also, use rather this plugin : http://forums.alliedmods.net/showthread.php?p=958925

And sets .ini file like :


Code:

"leet" "terror"
"arctic" "terror"
"gsg9" "urban"
"gign" "urban"
"sas" "urban"
"guerilla" "terror"
"militia" "terror"
"spetsnaz" "urban"

About your switch question :
PHP Code:

        switch(cs_get_user_team(id))
        {
            case 
CS_TEAM_T:
            {
                
cs_set_user_model(id,mdlTs)
            }
            case 
CS_TEAM_CT:
            {
                
cs_set_user_model(id,mdlCTs)
            }

        } 

But you would need tp register ham forward as post and not pre.
Anyway, use the linked plugin.

Thanks, but I don't want use one plugin for this step of my plugin, becouse this step only works if my plugin is desactive, That's because I've found a bug and this part resolve this.

Quote:

Originally Posted by Zezima14 (Post 1319160)
Change all in playerspawn for
PHP Code:

cs_set_user_modelid, (cs_get_user_team(id)==CS_TEAM_T) ? mdlTs mdlCTs 


Like this?

PHP Code:

public player_spawn(id)
{    
    if(
get_cvar_num("sv_thpop") != 1
    {
        new 
players[32],count
        get_players
(playerscount)
        
        
set_user_godmode(id)
        
set_user_hitzones(0id255)
        
set_user_maxspeed(id1.0)
        
set_user_gravity(id1.0)
        
give_item(id"weapon_knife")
        
set_user_rendering(id,kRenderFxNone,0,0,0,kRenderTransAlpha,255)
        
        
cs_set_user_modelid, (cs_get_user_team(id)==CS_TEAM_T) ? model_TR model_CT )
        
    }
    return 
PLUGIN_CONTINUE



fysiks 10-08-2010 13:58

Re: Using only 2 models in the game
 
DO NOT use Zezima14's suggestion.

GalegO 10-08-2010 14:00

Re: Using only 2 models in the game
 
My "script" of switch is correct to use?


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

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