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

change, improvement kills_changeteam-plugin.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
iveto69
Member
Join Date: Aug 2018
Old 12-14-2019 , 07:04   change, improvement kills_changeteam-plugin.
Reply With Quote #1

The plugin generally reports and works perfectly, transferring, immediately after the number of kills (indicated by kills_changeteam), but the problem is that when changing teams, the transferred player does not change his skin until he dies again having been transferred, and so it becomes quite healthy confusion ?!
Will this problem be somehow remedied?
Thanks.

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

new const PlayerModels[ ][ ] = 
{
	"arctic", "leet", "guerilla", "terror", "gign", "urban", "sas", "gsg9"
}

new g_iKills[33]

new g_KillsChange

public plugin_init()
{
	register_plugin("Kills Change Team", "0.1", "N")
	
	register_event("DeathMsg", "player_killed", "a")
	
	g_KillsChange = register_cvar("kills_changeteam", "20")
}

public client_putinserver(id)
{
	g_iKills[id] = 0;
}

public player_killed()
{
	new iVictim = read_data(2)
	new iKiller = read_data(1)
	
	g_iKills[iKiller]++; // ako e ubieca mu dobavqme kill
	g_iKills[iVictim] = 0; // ako e ubitiq mu reskame kilovete
	
	// proverqvame kilovete na ubieca i ako sa >= na nasheto chislo deistvame
	if(g_iKills[iKiller] >= get_pcvar_num(g_KillsChange))
	{
		change_team(iKiller); //smenqme teama
		g_iKills[iKiller] = 0; // reskame mu kilovete
	}
}

public change_team(id)
{
	if(is_user_connected(id))
	{
		new name[33]
		get_user_name(id,name,32)
		
		if(cs_get_user_team(id) == CS_TEAM_CT)
			CC_SendMatched(0, CC_COLOR_TEAM, "Attention:^4 Terrorist team needs^1 %s skills^4 and his team was changed!", name);
		else 
			CC_SendMatched(0, CC_COLOR_TEAM, "Attention:^4 CT team needs^1 %s skills^4 and his team was changed!", name);
			
			
		cs_reset_user_model( id ); // reset model
		cs_set_user_model( id, PlayerModels[ cs_get_user_team( id ) == CS_TEAM_CT ? random_num( 0, 3 ) : random_num( 4,7 ) ] ); 
		
		cs_set_user_team(id, cs_get_user_team(id) == CS_TEAM_CT ? CS_TEAM_T : CS_TEAM_CT);
		
	}
}
iveto69 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 12-14-2019 , 07:48   Re: change, improvement kills_changeteam-plugin.
Reply With Quote #2

You do not need to reset or set user model itself, you need to specify on cs_set_user_team instead: https://www.amxmodx.org/api/cstrike/cs_set_user_team
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
iveto69
Member
Join Date: Aug 2018
Old 12-15-2019 , 04:54   Re: change, improvement kills_changeteam-plugin.
Reply With Quote #3

Quote:
Originally Posted by ^SmileY View Post
You do not need to reset or set user model itself, you need to specify on cs_set_user_team instead: https://www.amxmodx.org/api/cstrike/cs_set_user_team
In this version, what should the code look like?
Sorry for my bad English!
iveto69 is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 12-16-2019 , 06:02   Re: change, improvement kills_changeteam-plugin.
Reply With Quote #4

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

new g_iKills[33]

new 
g_KillsChange

public plugin_init()
{
    
register_plugin("Kills Change Team""0.1""N")
    
    
register_event("DeathMsg""player_killed""a")
    
    
g_KillsChange register_cvar("kills_changeteam""20")
}

public 
client_putinserver(id)
{
    
g_iKills[id] = 0;
}

public 
player_killed()
{
    new 
iVictim read_data(2)
    new 
iKiller read_data(1)
    
    
g_iKills[iKiller]++; // ako e ubieca mu dobavqme kill
    
g_iKills[iVictim] = 0// ako e ubitiq mu reskame kilovete
    
    // proverqvame kilovete na ubieca i ako sa >= na nasheto chislo deistvame
    
if(g_iKills[iKiller] >= get_pcvar_num(g_KillsChange))
    {
        
change_team(iKiller); //smenqme teama
        
g_iKills[iKiller] = 0// reskame mu kilovete
    
}
}

public 
change_team(id)
{
    if(
is_user_connected(id))
    {
        new 
name[33]
        
get_user_name(id,name,32)
        
        if(
cs_get_user_team(id) == CS_TEAM_CT)
            
CC_SendMatched(0CC_COLOR_TEAM"Attention:^4 Terrorist team needs^1 %s skills^4 and his team was changed!"name);
        else 
            
CC_SendMatched(0CC_COLOR_TEAM"Attention:^4 CT team needs^1 %s skills^4 and his team was changed!"name);
            
            
        
cs_set_user_team(idcs_get_user_team(id) == CS_TEAM_CT CS_TEAM_T CS_TEAM_CT);
        
    }

__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 

Last edited by ^SmileY; 12-16-2019 at 06:02.
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
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 11:10.


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