Raised This Month: $ Target: $400
 0% 

Change user skin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-04-2016 , 14:07   Change user skin
Reply With Quote #1

Hi guys, I have a own menu for changing team in my server and personalized skins, and with instant auto team balance, even with the player models of connor, sometimes some users have T skin on CT side, or CT skin on T side...

I tryed this way to fix it, and it works, but when the server have a lot of players there, sometimes some players overflow...

PHP Code:
public new_round()
{    
    for(new 
i33i++)  
    {
        if(
is_user_connected(i))
        { 
            
set_task(3.0"models"i)
        }
    }
}

public 
models(id)
{
    if(
is_user_connected(id))
    {
        if ( 
cs_get_user_team(id) == CS_TEAM_CTcs_set_user_model(id"azul_ws")
        if ( 
cs_get_user_team(id) == CS_TEAM_Tcs_set_user_model(id"vermelho_ws")
    }
    
    
remove_task(id)

Is there a better way to make this? I already tryed with saving the user team in a variable and in the next round if he his in another team, change the skin, but it doesn't work because sometimes the player change team, and instant auto team ballance puts them in the other team again and they will have the skin of the team he changed...
I already tryed to save in a bool if the user was team ballanced but it doesnt work and I dont know why...
__________________

Last edited by skz; 05-04-2016 at 14:13.
skz is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-04-2016 , 14:50   Re: Change user skin
Reply With Quote #2

if(is_user_connected(id))

you forgot to add is_user_alive(id)

are you going to set models on dead players?

And before setting task, remove if another has been set

if(is_user_connected(i))
{
if(task_exists(i))
remove_task(i)
set_task(3.0, "models", i)
}

Last edited by siriusmd99; 05-04-2016 at 14:52.
siriusmd99 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-04-2016 , 15:08   Re: Change user skin
Reply With Quote #3

If is for all players, add:

PHP Code:
set_task(3.0,"models")

public 
models()
{
       new 
players[32],inum
       get_players
(players,inum,"a")
       for(new 
0;i<inum;i++)
       {
            if(
cs_get_user_team(players[i]]) == CS_TEAM_T)
            {
                    
cs_set_user_model(players[i], "vermelho_ws")
            }
            else if(
cs_get_user_team(players[i]) == CS_TEAM_CT)
            {
                   
cs_set_user_model(players[i],"azul_ws")
            }
      }

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-04-2016 at 15:11.
EFFx is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-04-2016 , 15:19   Re: Change user skin
Reply With Quote #4

Quote:
Originally Posted by EFFx View Post
If is for all players, add:

PHP Code:
set_task(3.0,"models")

public 
models()
{
       new 
players[32],inum
       get_players
(players,inum,"a")
       for(new 
0;i<inum;i++)
       {
            if(
cs_get_user_team(players[i]]) == CS_TEAM_T)
            {
                    
cs_set_user_model(players[i], "vermelho_ws")
            }
            else if(
cs_get_user_team(players[i]) == CS_TEAM_CT)
            {
                   
cs_set_user_model(players[i],"azul_ws")
            }
      }

Yes, it's better , no need to make task for every player but you missed something.

At the topic of the plugin :

PHP Code:
#define TASK_SETMODEL 5632 //or any numbers you want 
then :

PHP Code:
if(task_exists(TASK_SETMODEL))
remove_task(TASK_SETMODEL)
set_task(3.0,"models"TASK_SETMODEL

And you can use :

PHP Code:
switch(cs_get_user_team(players[i]){
case 
CS_TEAM_Tcs_set_user_model(players[i], "vermelho_ws")
case 
CS_TEAM_CTcs_set_user_model(players[i],"azul_ws")

It wont call function cs_get_user_team 2 times if first returns false.
siriusmd99 is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-04-2016 , 15:37   Re: Change user skin
Reply With Quote #5

overflowed as same
__________________
skz is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-04-2016 , 16:40   Re: Change user skin
Reply With Quote #6

PHP Code:
public new_round()
{    
    new 
players[32],inum 
    get_players
(players,inum,"c"
    for(new 
0;i<inum;i++) 
    { 
        if(
task_exists(TASK_SETMODEL))  remove_task(TASK_SETMODEL
        
set_task(3.0,"models"TASK_SETMODEL)  
    }
}

public 
models() 

    new 
players[32],inum 
    get_players
(players,inum,"a"
    for(new 
0;i<inum;i++) 
    { 
        switch(
cs_get_user_team(players[i]))
        { 
            case 
CS_TEAM_Tcs_set_user_model(players[i], "vermelho_ws"
            case 
CS_TEAM_CTcs_set_user_model(players[i],"azul_ws"
        } 
    }  
    
remove_task(TASK_SETMODEL)

this way worked, thanks for your help!
__________________
skz is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-04-2016 , 16:45   Re: Change user skin
Reply With Quote #7

Quote:
Originally Posted by skz View Post
PHP Code:
public new_round()
{    
    new 
players[32],inum 
    get_players
(players,inum,"c"
    for(new 
0;i<inum;i++) 
    { 
        if(
task_exists(TASK_SETMODEL))  remove_task(TASK_SETMODEL
        
set_task(3.0,"models"TASK_SETMODEL)  
    }
}

public 
models() 

    new 
players[32],inum 
    get_players
(players,inum,"a"
    for(new 
0;i<inum;i++) 
    { 
        switch(
cs_get_user_team(players[i]))
        { 
            case 
CS_TEAM_Tcs_set_user_model(players[i], "vermelho_ws"
            case 
CS_TEAM_CTcs_set_user_model(players[i],"azul_ws"
        } 
    }  
    
remove_task(TASK_SETMODEL)

this way worked, thanks for your help!

Yes, but remove get players and loop at round start event

Use this code:

PHP Code:
public new_round()
{    
    
   if(
task_exists(TASK_SETMODEL))  remove_task(TASK_SETMODEL
   
set_task(3.0,"models"TASK_SETMODEL)  
    
}

public 
models() 

    new 
players[32],inum 
    get_players
(players,inum,"a"
    for(new 
0;i<inum;i++) 
    { 
        switch(
cs_get_user_team(players[i]))
        { 
            case 
CS_TEAM_Tcs_set_user_model(players[i], "vermelho_ws"
            case 
CS_TEAM_CTcs_set_user_model(players[i],"azul_ws"
        } 
    }  
    
remove_task(TASK_SETMODEL)

siriusmd99 is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 05-04-2016 , 17:01   Re: Change user skin
Reply With Quote #8

You're right, sirius, if is for all players, dont need get_players because functions that have not a id, like models() dont need that and set_task(TASK_SETMODEL), just add set_task(3.0,"models")

Like

PHP Code:
public new_round() 
{     
   
set_task(3.0,"models")   
     


public 
models()  
{  
    new 
players[32],inum  
    get_players
(players,inum,"a")  
    for(new 
0;i<inum;i++)  
    {  
        switch(
cs_get_user_team(players[i])) 
        {  
            case 
CS_TEAM_Tcs_set_user_model(players[i], "vermelho_ws")  
            case 
CS_TEAM_CTcs_set_user_model(players[i],"azul_ws")  
        }  
    }   

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 05-04-2016 at 17:02.
EFFx is offline
siriusmd99
Veteran Member
Join Date: Oct 2013
Location: Republic of Moldova
Old 05-04-2016 , 17:12   Re: Change user skin
Reply With Quote #9

No, we need ID because if there happens new round before 3 seconds passed then function will be called again.

Like :
new round, set task
after 1 second:
new round, set task
After 2 seconds - function, after 1 second - function.
It just calls the function too frequent and early.
siriusmd99 is offline
skz
Senior Member
Join Date: Jul 2014
Location: Portugal
Old 05-06-2016 , 16:35   Re: Change user skin
Reply With Quote #10

PHP Code:
public new_round()
{    
    if(
task_exists(TASK_SETMODEL))  remove_task(TASK_SETMODEL
    
set_task(3.0,"models"TASK_SETMODEL)  
}

public 
models() 

    new 
players[32],inum 
    get_players
(players,inum,"a"
    for(new 
0;i<inum;i++) 
    { 
        switch(
cs_get_user_team(players[i]))
        { 
            case 
CS_TEAM_Tcs_set_user_model(players[i], "vermelho_ws"
            case 
CS_TEAM_CTcs_set_user_model(players[i],"azul_ws"
        } 
    }  
    
remove_task(TASK_SETMODEL)

It continues to give overflow to all players on the round start
__________________
skz 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 02:09.


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