Raised This Month: $ Target: $400
 0% 

Random player model?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 01-11-2009 , 14:48   Random player model?
Reply With Quote #1

I've been working on something that includes multiple player models. But I can't quite get it right. Any idea on how to do it?
Would require selecting and setting one of these models randomly on a player after they spawn.
PHP Code:
new g_ct_models[][] =
{
    
"models/player/chicken/chicken.mdl",
    
"models/player/homersimpson/homersimpson.mdl",
    
"models/player/futbender/futbender.mdl"

fang is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-11-2009 , 15:43   Re: Random player model?
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <cstrike>

new g_ct_models[][] =
{
    
"models/player/chicken/chicken.mdl",
    
"models/player/homersimpson/homersimpson.mdl",
    
"models/player/futbender/futbender.mdl"
};

new 
g_maxplayers;

public 
plugin_init()
{
    
register_event"HLTV""hook_newround""a""1=0""2=0" );
    
g_maxplayers get_maxplayers();
}

public 
plugin_precache()
{
    for( new 
0sizeof g_ct_modelsi++ )
        
precache_modelg_ct_models] );
}

public 
hook_newround()
{
    new 
x;
    for( new 
1<= g_maxplayersi++ )
    {
        if( !
is_user_alive) )
            continue;
            
        
random_num0sizeof g_ct_models );
        
cs_set_user_modelig_ct_models] );
    }

__________________

anakin_cstrike is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-11-2009 , 15:48   Re: Random player model?
Reply With Quote #3

PHP Code:
#include <amxmodx>
#include <cstrike>

new g_ct_models[][] =
{
    
"chicken",
    
"homersimpson",
    
"futbender"
};

new 
g_maxplayers;

public 
plugin_init()
{
    
register_event"HLTV""hook_newround""a""1=0""2=0" );
    
g_maxplayers get_maxplayers();
}

public 
plugin_precache()
{
    new 
model[64];
    for( new 
0sizeof g_ct_modelsi++ )
    {
        
formatex(modelsizeof(model) - 1"models/player/%s/%s.mdl"g_ct_models[i], g_ct_models[i]);
        
precache_model(model);
    }
}

public 
hook_newround()
{
    new 
x;
    for( new 
1<= g_maxplayersi++ )
    {
        if( !
is_user_alive) )
            continue;
            
        
random_num0sizeof g_ct_models );
        
cs_set_user_modelig_ct_models] );
    }

Fixed.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 01-12-2009 at 11:52.
Exolent[jNr] is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-11-2009 , 15:58   Re: Random player model?
Reply With Quote #4

Should be:
PHP Code:
formatex(modelsizeof(model) - 1"models/player/%s.mdl"g_ct_models[i]); 
Am i right?
__________________

anakin_cstrike is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 01-11-2009 , 16:08   Re: Random player model?
Reply With Quote #5

Quote:
Originally Posted by anakin_cstrike View Post
Should be:
PHP Code:
formatex(modelsizeof(model) - 1"models/player/%s.mdl"g_ct_models[i]); 
Am i right?
Not because al player model have to be in a folder like the name LALA/LALA.MDL
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
fang
Senior Member
Join Date: Nov 2007
Location: New Jersey
Old 01-11-2009 , 16:31   Re: Random player model?
Reply With Quote #6

Ty very much everyone
fang is offline
X0Left4dead0X
BANNED
Join Date: Jan 2009
Old 01-11-2009 , 18:11   Re: Random player model?
Reply With Quote #7

Quote:
Originally Posted by anakin_cstrike View Post
Should be:
PHP Code:
formatex(modelsizeof(model) - 1"models/player/%s.mdl"g_ct_models[i]); 
Am i right?
Nope, the folder name needs to be chicken so it will load chicken/chicken.mdl like alien/alien.mdl ect
X0Left4dead0X is offline
BOYSplayCS
BANNED
Join Date: Apr 2008
Location: Gainesville, FL
Old 01-11-2009 , 19:13   Re: Random player model?
Reply With Quote #8

No. Just add the chicken.mdl into the models/player folder and it'll work perfectly fine.
BOYSplayCS is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 01-11-2009 , 21:44   Re: Random player model?
Reply With Quote #9

Quote:
Originally Posted by BOYSplayCS View Post
No. Just add the chicken.mdl into the models/player folder and it'll work perfectly fine.
No, that won't work for player models.
It has to be models/player/modelname/modelname.mdl, then cs_set_user_model(index, "modelname");
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
anakin_cstrike
Veteran Member
Join Date: Nov 2007
Location: Romania
Old 01-12-2009 , 07:39   Re: Random player model?
Reply With Quote #10

Anyway, he'll get 'string formated incorectly' no ? or if is the same string at %s, or %d, %i will work ?
PHP Code:
g_ct_models[i], g_ct_models[i]); 
</span></span>
__________________

anakin_cstrike is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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