Raised This Month: $51 Target: $400
 12% 

Model replace - plugin error?! Help please :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
remote44
Junior Member
Join Date: Jan 2015
Old 03-06-2015 , 10:17   Model replace - plugin error?! Help please :)
Reply With Quote #1

Hello
i have this plugin

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

new bool:array[33];

public 
plugin_precache()
{
    
precache_model("models/player/cent_t/cent_t.mdl");
    
precache_model("models/player/cent_ct/cent_ct.mdl");
}

public 
plugin_init()
{
    
register_plugin("Models""1.0""Mostwanted");
    
    
register_logevent"EventJoinTeam"3"1=joined team" );
    
register_logevent("event_new_round",2,"0=World triggered","1=Round_Start");
}

public 
EventJoinTeam()
{
    new 
iPlayer GetLoguserIndex();
    
    if(!array[
iPlayer])
    {
        if(
cs_get_user_team(iPlayer) == CS_TEAM_CT)
        {
            
cs_set_user_model(iPlayer"cent_ct");
        }
        if(
cs_get_user_team(iPlayer) == CS_TEAM_T)
        {
            
cs_set_user_model(iPlayer"cent_t");
        }    
    }
}

GetLoguserIndex()
{
    new 
szArg[61];
    
read_logargv(0,szArgcharsmax(szArg));
    
    new 
szName[32];
    
parse_loguser(szArgszNamecharsmax(szName));
    
    return 
get_user_index(szName);
}

public 
client_disconnect(id)
{
    
cs_reset_user_model(id);
}

public 
event_new_round()
{
    for( new 
id 1id <= 32id++ )
    {
        if(
cs_get_user_team(1) == CS_TEAM_CT)
        {
            if(
cs_get_user_model(id"cent_t"31))
            {
                
cs_set_user_model(1"cent_ct");
            }
        }
        if(
cs_get_user_team(1) == CS_TEAM_T)
        {
            if(
cs_get_user_model(id"cent_ct"31))
            {
                
cs_set_user_model(1"cent_t");
            }
        }    
    }

But it is not work download the files but do not replace the models..
What is the bad? help please

Last edited by remote44; 03-06-2015 at 10:17.
remote44 is offline
RateX
Veteran Member
Join Date: Jun 2012
Location: 0o. SEA .o0
Old 03-06-2015 , 10:34   Re: Model replace - plugin error?! Help please :)
Reply With Quote #2

Don't know, but try to set it at spawn using Ham_Spawn.
BTW, your cs_get_user_model() check make no sense.
__________________
Currently offline for study.
RateX is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-06-2015 , 10:57   Re: Model replace - plugin error?! Help please :)
Reply With Quote #3

When HLTV event is called players can be dead, so the error may come from here. Hook ClientUserInfoChanged and SetClientKeyValue and apply the model there with set_user_info(id, "model",..)(you need to pass full model string models/player/model/model.mdl in it)
__________________
HamletEagle is offline
Krtola
Veteran Member
Join Date: Oct 2013
Location: Serbia
Old 03-06-2015 , 12:09   Re: Model replace - plugin error?! Help please :)
Reply With Quote #4

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

#define ctmodel "your model name"
#define tsmodel "your model name"

new bool:array[33];

public 
plugin_precache()
{
    new 
szText[64]
    
format(szText63"models/player/%s/%s.mdl"ctmodelctmodel)
    
format(szText63"models/player/%s/%s.mdl"tsmodeltsmodel)
    
precache_model(szText)
}

public 
plugin_init()
{
    
register_plugin("Models""1.0""Mostwanted");
    
    
register_logevent"EventJoinTeam"3"1=joined team" );
    
register_logevent("event_new_round",2,"0=World triggered","1=Round_Start");
}

public 
EventJoinTeam()
{
    new 
iPlayer GetLoguserIndex();
    
    if(!array[
iPlayer])
    {
        if(
cs_get_user_team(iPlayer) == CS_TEAM_CT)
        {
            
cs_set_user_model(iPlayer"cent_ct");
        }
        if(
cs_get_user_team(iPlayer) == CS_TEAM_T)
        {
            
cs_set_user_model(iPlayer"cent_t");
        }    
    }
}

GetLoguserIndex()
{
    new 
szArg[61];
    
read_logargv(0,szArgcharsmax(szArg));
    
    new 
szName[32];
    
parse_loguser(szArgszNamecharsmax(szName));
    
    return 
get_user_index(szName);
}

public 
client_disconnect(id)
{
    
cs_reset_user_model(id);
}

public 
event_new_round()
{
    for( new 
id 1id <= 32id++ )
    {
        if(
cs_get_user_team(1) == CS_TEAM_CT)
        {
                
cs_set_user_model(1"ctmodel");
            
        }
        if(
cs_get_user_team(1) == CS_TEAM_T)
        {
                
cs_set_user_model(1"tsmodel");
        }    
    }

or this
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <cstrike>
#include <cs_player_models_api>

#define ctmodel "your model name"
#define tsmodel "your model name"

new bool:array[33];

public 
plugin_precache()
{
    new 
szText[64]
    
format(szText63"models/player/%s/%s.mdl"ctmodelctmodel)
    
format(szText63"models/player/%s/%s.mdl"tsmodeltsmodel)
    
precache_model(szText)
}

public 
plugin_init()
{
    
register_plugin("Models""1.0""Mostwanted");
    
    
register_logevent"EventJoinTeam"3"1=joined team" );
    
RegisterHam(Ham_Spawn"player""spawn_new_model"1)
}

public 
EventJoinTeam()
{
    new 
iPlayer GetLoguserIndex();
    
    if(!array[
iPlayer])
    {
        if(
cs_get_user_team(iPlayer) == CS_TEAM_CT)
        {
            
cs_set_user_model(iPlayer"cent_ct");
        }
        if(
cs_get_user_team(iPlayer) == CS_TEAM_T)
        {
            
cs_set_user_model(iPlayer"cent_t");
        }    
    }
}

GetLoguserIndex()
{
    new 
szArg[61];
    
read_logargv(0,szArgcharsmax(szArg));
    
    new 
szName[32];
    
parse_loguser(szArgszNamecharsmax(szName));
    
    return 
get_user_index(szName);
}

public 
client_disconnect(id)
{
    
cs_reset_user_model(id);
}

public 
spawn_new_model(id)
{
        if(
cs_get_user_team(1) == CS_TEAM_CT)
        {
                
cs_set_player_model(id"ctmodel");
            
        }

        if(
cs_get_user_team(1) == CS_TEAM_T)
        {
                
cs_set_player_model(id"tsmodel");
        }    


Last edited by Krtola; 03-06-2015 at 12:10.
Krtola is offline
Send a message via Skype™ to Krtola
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 03-06-2015 , 12:17   Re: Model replace - plugin error?! Help please :)
Reply With Quote #5

Why peoples never listen to what we are saying and after that they come back complaining ? cs_set_user_model method is not reliable, it can crash the server very easy, especially when you try to change more player models at the same time(this would be the case on a full server or so). The method that I explained is safer to use. In fact, I have tested both ways and saw how they work.

Mostwanted code has some things that needs fixing, without even speacking about the poor method of changing modes.
__________________

Last edited by HamletEagle; 03-06-2015 at 12:50.
HamletEagle is offline
xkp
Member
Join Date: Jan 2015
Location: AlliedLand
Old 03-07-2015 , 07:12   Re: Model replace - plugin error?! Help please :)
Reply With Quote #6

https://forums.alliedmods.net/showthread.php?t=164453
https://forums.alliedmods.net/showthread.php?t=163555

try this modules ;)
__________________
xkp is offline
Send a message via Skype™ to xkp
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 04:38.


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