Raised This Month: $32 Target: $400
 8% 

Solved cs_set_user_model


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-15-2021 , 13:21   cs_set_user_model
Reply With Quote #1

Hello! I have this code

PHP Code:
ublic plugin_init(){
    
register_logevent("taskdo"2"1=Round_Start"
}

public 
taskdo(id){
    
    
set_task(1.0"skincheck")
    
}

public 
skincheck(id){
    
    if(
is_user_alive(id)){
        
        new 
iSkin[32]
        
        
cs_get_user_model(idiSkincharsmax(iSkin))
        
        if (
equaliiSkin"fbi" ) || equali iSkin"sias" )){
            
            if ( 
cs_get_user_team(id) == CS_TEAM_T ){
                
                
cs_reset_user_model(id)
                
                switch(
checkT[id]){
                    
                    case 
1:{
                        
                        
cs_set_user_model(id"isis")
                        
                        
checkPS[id] = 1
                        
                    
}
                    
                    case 
2:{
                        
                        
cs_set_user_model(id"alqaeda")
                        
                        
checkPS[id] = 2
                        
                    
}
                    
                }
                
                
            }
            } else if  (
equaliiSkin"isis" ) || equali iSkin"alqaeda" )){
            
            if( 
cs_get_user_team(id) == CS_TEAM_CT ){
                
                
cs_reset_user_model(id)
                
                switch(
checkCT[id]){
                    
                    case 
1:{
                        
                        
cs_set_user_model(id"fbi")
                        
                        
checkPS[id] = 3
                        
                    
}
                    
                    case 
2:{
                        
                        
cs_set_user_model(id"sias")
                        
                        
checkPS[id] = 4
                        
                    
}
                    
                }
                
            }
            
        }
        
    } else 
ColorChat(0GREEN"^x04[%s]^x01 Player is not alive!" )
    

The problem is that the output is this
PHP Code:
ColorChat(0GREEN"^x04[%s]^x01 Player is not alive!" 
I don't know why is not working

Last edited by lexzor; 01-17-2021 at 08:12.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-15-2021 , 15:21   Re: cs_set_user_model
Reply With Quote #2

Because there's no "id" defined anywhere so it's 0. Even if you did put it in set_task, "round start" is a global event and there is no "id".
Why are you doing this in "round start" instead of "player spawn" event?
__________________

Last edited by OciXCrom; 01-15-2021 at 15:22.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 01:28   Re: cs_set_user_model
Reply With Quote #3

because player spawn would give me an server console error that say "Invalid player 1" or any other number. i will try something and i will repost it here
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 01:40   Re: cs_set_user_model
Reply With Quote #4

Ok, i tried what u said to me and now it's working. but i have another question.

it's neccesarly to use "cs_reset_user_model" before "cs_set_user_model" or i can just use set user model
lexzor is offline
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 03:30   Re: cs_set_user_model
Reply With Quote #5

also, i have another problem.

skin "alqaeda" is a model for terrorist

if i have that model enabled when i'm terrorist. some players see me as a default counter-terrorist models.

I don't have the same problem as them and i don't know why this is happening. what should i do ? this is skincheck code

PHP Code:
public plugin_init() {
    
RegisterHam(Ham_Spawn"player""skincheck"1
}

public 
skincheck(id){    
    if(
is_user_alive(id) && get_user_flags(id) & VIP_FLAG){    
        
cs_reset_user_model(id)        
        if ( 
cs_get_user_team(id) == CS_TEAM_T ){            
            switch(
checkT[id]){                
                case 
1:{                    
                    
cs_set_user_model(id"isis")                
                    
checkPS[id] = 1                    
                
}
                
                case 
2:{                    
                    
cs_set_user_model(id"alqaeda")                    
                    
checkPS[id] = 2                    
                
}                
            }            
            } else if( 
cs_get_user_team(id) == CS_TEAM_CT ){            
            switch(
checkCT[id]){                
                case 
1:{                    
                    
cs_set_user_model(id"fbi")                    
                    
checkPS[id] = 3                    
                
}
                
                case 
2:{                    
                    
cs_set_user_model(id"sias")                    
                    
checkPS[id] = 4                    
                
}                
            }            
        }        
    }


Last edited by lexzor; 01-17-2021 at 03:42.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-17-2021 , 07:47   Re: cs_set_user_model
Reply With Quote #6

Quote:
Originally Posted by lexzor View Post
because player spawn would give me an server console error that say "Invalid player 1" or any other number. i will try something and i will repost it here
What's the logic behind that?! I always use PlayerSpawn to set player models. If you check if the user is alive, you can't possibly get an "invalid player" error.

Quote:
Originally Posted by lexzor View Post
Ok, i tried what u said to me and now it's working. but i have another question.

it's neccesarly to use "cs_reset_user_model" before "cs_set_user_model" or i can just use set user model
Can the player have 2 player models at once? Obviously cs_set_user_model replaces the previous one and "reset" is pointless.

Quote:
Originally Posted by lexzor View Post
also, i have another problem.

skin "alqaeda" is a model for terrorist

if i have that model enabled when i'm terrorist. some players see me as a default counter-terrorist models.

I don't have the same problem as them and i don't know why this is happening. what should i do ? this is skincheck code
Show the code where you precache the models, if you even do it. If not, that's the problem.
Or you didn't upload the files on your server/downloadurl or players use "cl_minmodels 1".
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 07:56   Re: cs_set_user_model
Reply With Quote #7

PHP Code:
new playerskins[][] = {
    
"sias",
    
"fbi",
    
"isis",
    
"alqaeda"
}

public 
plugin_precache(){
    static 
playermodels[256]
    
    for (new 
0sizeof(playerskins) -1i++){    
        
formatex(playermodelscharsmax(playermodels), "models/player/%s/%s.mdl"playerskins[i], playerskins[i])    
        
precache_model(playermodels)    
    } 

i deleted all models from my cs folder and now i get same problem. the skin isn't event there, the folder doesn t exist in my models folder, but he exists in server models. how is this even possible ?

Last edited by lexzor; 01-17-2021 at 07:57.
lexzor is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-17-2021 , 07:57   Re: cs_set_user_model
Reply With Quote #8

Why "sizeof - 1"? There's your problem. The last skin isn't registered because of the "-1".
Also, I'd suggest using a better function to handle this:

Code:
precache_player_model(const szModel[], &id = 0) {     new model[128]     formatex(model, charsmax(model), "models/player/%s/%sT.mdl", szModel, szModel)     if(file_exists(model))         id = precache_generic(model)     static const extension[] = "T.mdl"     #pragma unused extension     copy(model[strlen(model) - charsmax(extension)], charsmax(model), ".mdl")     return precache_model(model) }

Some models have an additional T.mdl file. This one takes it in mind, plus it only requires the model name as an argument, same as "cs_set_user_model".
__________________

Last edited by OciXCrom; 01-17-2021 at 07:58.
OciXCrom is offline
Send a message via Skype™ to OciXCrom
lexzor
Veteran Member
Join Date: Nov 2020
Old 01-17-2021 , 08:12   Re: cs_set_user_model
Reply With Quote #9

Thank you! that -1 was the problem. Thank you a lot man.
lexzor is offline
Reply


Thread Tools
Display Modes

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 15:31.


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