Raised This Month: $ Target: $400
 0% 

Set model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
skatzfz
Senior Member
Join Date: Apr 2014
Old 06-20-2014 , 15:41   Set model
Reply With Quote #1

Hi! I'm trying to edit a shop plugin, and I wanted to know how can I set a player skin if someone buy it, for example:

- Zombie Mode 16000$
If someone buy it, automatically changes his skin to a zombie for one round

Thanks for help!
skatzfz is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-20-2014 , 15:50   Re: Set model
Reply With Quote #2

I think everything is explained here.
PHP Code:
#include <amxmodx>
#include <cstrike>
#include <hamsandwich>

public plugin_init() {
    
    
/*We register some random function to set the model*/
    
register_clcmd("say /model""SomeFunctionWhereWeSetTheModel")
    
    
/*We register the example spawn function, where we reset the model*/
    
RegisterHam(Ham_Spawn"player""PlayerSpawnFunction"1)
}

/*First you have to precache the model with it's exact dirrectory. If it's a player mode, it has to be 
in the "player" folder. You need to remember, that the engine sets the models depending on the folder they are in.
I mean that you can't get two models in one folder.
Now to precache it.*/
public plugin_precache()
{
    
precache_model("models/player/OurModel/OurModel.mdl")
    
/*You see the name and the directory of the model
    Remember, we need the folder's name to set it!*/
}

/*Here is the example function where we set the model*/
public SomeFunctionWhereWeSetTheModel(id)
{
    
/*Important check when setting model*/
    
if(is_user_alive(id))
    {
        
/*The native to set it*/
        
cs_set_user_model(id"OurModel"/*We get the folder's nameee!*/
    
}
}

/*Here is your example spawn function, where we reset the player's model*/
public PlayerSpawnFunction(id)
{
    
/*The check*/
    
if(is_user_alive(id))
    {
        
/*The native to get the original player model*/
        
cs_reset_user_model(id)
    }
}
//That's all 
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-21-2014 , 02:06   Re: Set model
Reply With Quote #3

Don't use cs_set_user_model,will cause SVC_BAD when many players are connected.

Last edited by HamletEagle; 06-21-2014 at 02:06.
HamletEagle is offline
skatzfz
Senior Member
Join Date: Apr 2014
Old 06-20-2014 , 16:24   Re: Set model
Reply With Quote #4

But it's not necessary to indicate which model will be replaced?
skatzfz is offline
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-20-2014 , 17:41   Re: Set model
Reply With Quote #5

Nope. You just set the new model. If you want, you can save the previuos model in some string, and in some conditons to set it (the previous model). But it doesn't matter which model do you replace.
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
Flick3rR
Veteran Member
Join Date: Feb 2014
Location: Bulgaria, Stara Zagora
Old 06-21-2014 , 03:08   Re: Set model
Reply With Quote #6

Any other better way?
__________________
Flick3rR is offline
Send a message via Skype™ to Flick3rR
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 06-21-2014 , 04:11   Re: Set model
Reply With Quote #7

Quote:
Originally Posted by Flick3rR View Post
Any other better way?
Read here: https://forums.alliedmods.net/showthread.php?t=69386
HamletEagle is offline
skatzfz
Senior Member
Join Date: Apr 2014
Old 06-21-2014 , 03:35   Re: Set model
Reply With Quote #8

My server has 32 slots :s
skatzfz 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 21:14.


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