Your code is missing some function. No plugin can run without function plugin_init() where it registers the plugin. Also remember you cant use get_ command with cs_ and cs_ command with get_
For ex if you are using cs_get_user_team(id) you cant use get_user_team(id) with it or if using get_user_team(id) you cant use cs_team_ct command with here, here is the fixed code.
EDITED: client_cmd is used to execute command on a player, To print something in chat to show to the player you can use client_print.
EDITED (2): Why use true, true in function setting team? doesn't make any sense, just transfer by using cs_set_user_team(id, CS_TEAM_T) , fixed for you.
EDITED (3): This code has many problems, I dont know if it will even work, But still try.
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < cstrike >
#include < fakemeta >
new knife_hits;
public plugin_init()
{
register_plugin("Change team", "1.0", "Author")
}
public client_putinserver(id) {
if (cs_get_user_team(id) == CS_TEAM_CT) {
set_pdata_int(id, knife_hits, 0);
}
}
public client_damage(id, damage, attacker, weapon, hp, ap) {
if (!is_user_connected(id) || !is_user_connected(attacker) || id == attacker)
return PLUGIN_CONTINUE;
if (is_user_alive(id) && is_user_alive(attacker) && cs_get_user_team(id) == CS_TEAM_CT && cs_get_user_team(attacker) == CS_TEAM_T) {
if (weapon == CSW_KNIFE) {
new hits = get_pdata_int(attacker, knife_hits);
hits++;
if (hits >= 2) {
cs_set_user_team(id, CS_TEAM_T);
client_print(id, print_chat, "You were switched to the T team for getting knifed twice by a T player.")
}
set_pdata_int(attacker, knife_hits, hits);
}
}
return PLUGIN_CONTINUE;
}