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

[REQ] Team T infects team CT


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
benqcon
Member
Join Date: Jul 2020
Old 07-31-2023 , 14:43   [REQ] Team T infects team CT
Reply With Quote #1

Is there any plugins that make CT player change team when they are hit by T player knife's?
I tried to make it whenever a terrorist player hits a ct player twice with a knife, the ct player becomes terrorist.
Can anyone help me or give me a starting point?
benqcon is offline
benqcon
Member
Join Date: Jul 2020
Old 07-31-2023 , 14:56   Re: [REQ] Team T infects team CT
Reply With Quote #2

PS: this is the code I tried to use:

Quote:
#include < amxmodx >

public client_putinserver(id) {
set_pev(id, pev_team, 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) && get_user_team(id) == CS_TEAM_CT && get_user_team(attacker) == CS_TEAM_T) {
if (weapon == CSW_KNIFE) {
new hits = get_pdata_int(attacker, "knife_hits");
hits++;

if (hits >= 2) {
set_user_team(id, CS_TEAM_T, true, true);
client_cmd(id, "say_team 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;
}
benqcon is offline
benqcon
Member
Join Date: Jul 2020
Old 07-31-2023 , 15:08   Re: [REQ] Team T infects team CT
Reply With Quote #3

Im sorry, this is the best thing I could do but it still doesn't work:

Quote:
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < cstrike >
#include < fakemeta >

public client_putinserver(id) {
if (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) && get_user_team(id) == CS_TEAM_CT && get_user_team(attacker) == CS_TEAM_T) {
if (weapon == CSW_KNIFE) {
new hits = get_pdata_int(attacker, "knife_hits");
hits++;

if (hits >= 2) {
set_user_team(id, CS_TEAM_T, true, true);
client_cmd(id, "say_team 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;
}
benqcon is offline
mlibre
Veteran Member
Join Date: Nov 2015
Location: return PLUGIN_CONTINUE
Old 07-31-2023 , 17:49   Re: [REQ] Team T infects team CT
Reply With Quote #4

use cs_set_user_team
__________________
mlibre is offline
benqcon
Member
Join Date: Jul 2020
Old 08-01-2023 , 03:50   Re: [REQ] Team T infects team CT
Reply With Quote #5

I did, but still doesn't compile
benqcon is offline
Tote
Senior Member
Join Date: Jul 2023
Old 08-01-2023 , 14:24   Re: [REQ] Team T infects team CT
Reply With Quote #6

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;
}

Last edited by Tote; 08-01-2023 at 14:32.
Tote is offline
benqcon
Member
Join Date: Jul 2020
Old 08-02-2023 , 04:37   Re: [REQ] Team T infects team CT
Reply With Quote #7

It compiles but now it just breaks my server if I try to add a bot ��
Someone suggested this code for me but it doesn't do anything:
Quote:
#include < amxmodx >
#include < amxmisc >
#include < hamsandwich >
#include < cstrike >
#include < fakemeta >

new g_knife_hits[33];
const REQUIRE_HITS = 2;

public plugin_init()
{
RegisterHam(Ham_TakeDamage, "player", "fw_takedamage");
}

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

public fw_takedamage(victim, inflictor, attacker, Float:dmg, dmg_bits)
{
if (!is_user_connected(attacker) || !is_user_connected(victim) || attacker == victim)
return HAM_IGNORED;

if (is_user_alive(attacker) && is_user_alive(victim) && cs_get_user_team(attacker) == CS_TEAM_T && cs_get_user_team(victim) == CS_TEAM_CT && get_user_weapon(attacker) == CSW_KNIFE)
{
g_knife_hits[victim] ++;
if (g_knife_hits[victim] >= REQUIRE_HITS)
{
cs_set_user_team(victim, CS_TEAM_T, true);
client_cmd(victim, "say_team You were switched to the T team for getting knifed twice by a T player.");
}
}

return HAM_IGNORED;
}
benqcon is offline
DJEarthQuake
Veteran Member
Join Date: Jan 2014
Location: Astral planes
Old 08-03-2023 , 09:08   Re: [REQ] Team T infects team CT
Reply With Quote #8

Quote:
Originally Posted by benqcon View Post
Is there any plugins that make CT player change team when they are hit by T player knife's?
I tried to make it whenever a terrorist player hits a ct player twice with a knife, the ct player becomes terrorist.
Can anyone help me or give me a starting point?
Code:
#include amxmodx #include cstrike #include hamsandwich //CZ #tryinclude cs_ham_bots_api #define PLUGIN   "Blade make Terrorist" #define VERSION  "1.0.0" #define AUTHOR   "SPiNX" #define URL      "github.com/djearthquake" #define MAX_PLAYERS 32 new XBotDamage, HamHook:XDamage, Xcvar public plugin_init() {     #if AMXX_VERSION_NUM >= 179 && AMXX_VERSION_NUM <= 190     register_plugin(PLUGIN, VERSION, AUTHOR)     #else     register_plugin(PLUGIN, VERSION, AUTHOR, URL)     #endif     XDamage = RegisterHam(Ham_TakeDamage, "player", "@PostTakeDamage", 1);     Xcvar = register_cvar("enable_knife_infection", "1")     if(get_cvar_pointer("bot_quota"))     {         #if !defined _cs_ham_bots_api_included         #error Need Hambots "http://github.com/djearthquake/amxx/tree/main/scripting/czero/AI"         #endif         XBotDamage = RegisterHamBots(Ham_TakeDamage, "@PostTakeDamage");     } } public plugin_end() {     DisableHamForwardBots(XBotDamage)     DisableHamForward(XDamage) } @PostTakeDamage(iVictim, iInflictor, iAttacker, Float:iDamage, iDamagebits) {     static iCvar; iCvar = get_pcvar_num(Xcvar)     iCvar ?  EnableHamForwardBots(XBotDamage) :  DisableHamForwardBots(XBotDamage)     iCvar ?  EnableHamForward(XDamage) :  DisableHamForward(XDamage)     static iKnife[MAX_PLAYERS]     if(is_user_connected(iAttacker) && is_user_connected(iVictim))     {         static iGat;iGat = get_user_weapon(iAttacker)         static iTeam; iTeam = get_user_team(iVictim)         if(iTeam == 2)         if(iGat == CSW_KNIFE)         {             iKnife[iVictim]++             client_print 0, print_chat, "%n was struck by %n's knife %i times!", iVictim, iAttacker, iKnife[iVictim]             if(iKnife[iVictim] == 2)             {                 iKnife[iVictim] = 0                 cs_set_user_team(iVictim, 1)             }         }     } }

I tested this on CZ with bots.
DJEarthQuake 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 01:08.


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