AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Set model (https://forums.alliedmods.net/showthread.php?t=242515)

skatzfz 06-20-2014 15:41

Set model
 
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!

Flick3rR 06-20-2014 15:50

Re: Set model
 
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 


skatzfz 06-20-2014 16:24

Re: Set model
 
But it's not necessary to indicate which model will be replaced?

Flick3rR 06-20-2014 17:41

Re: Set model
 
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.

HamletEagle 06-21-2014 02:06

Re: Set model
 
Don't use cs_set_user_model,will cause SVC_BAD when many players are connected.

Flick3rR 06-21-2014 03:08

Re: Set model
 
Any other better way?

skatzfz 06-21-2014 03:35

Re: Set model
 
My server has 32 slots :s

HamletEagle 06-21-2014 04:11

Re: Set model
 
Quote:

Originally Posted by Flick3rR (Post 2154944)
Any other better way?

Read here: https://forums.alliedmods.net/showthread.php?t=69386


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

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