Hello, I need to add a check if a terrorist or a counter terrost has triggered a trap here:
Code:
if(g_use_button){
client_print(0,print_chat, "[Deathrun[4]Fun] You Used A Trap, FreeRound Is Not Possble!");
return PLUGIN_HANDLED
}
Because on some maps CT's have to push a button to open the door and the plugin counts it as a trap and T's cant give a free round. Here is the whole code
Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta_util>
#define PLUGIN "FreeRun"
#define VERSION "1.0"
#define AUTHOR "PomanoB"
new g_free
new g_cvar_t_only
new g_free_time
new bool:g_bFree
new bool:g_use_button
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
g_cvar_t_only = register_cvar("free_run_t_only", "1")
register_clcmd("say free", "cmdFree")
register_clcmd("say /free", "cmdFree")
register_event("HLTV", "eventRoundStart", "a", "1=0", "2=0")
RegisterHam(Ham_Spawn, "player", "player_spawn",1)
RegisterHam(Ham_Touch, "armoury_entity", "fwdTouch")
RegisterHam(Ham_Touch, "weaponbox", "fwdTouch")
RegisterHam(Ham_Use, "func_button", "fwdUse")
}
public player_spawn(id){
if(g_bFree){
set_task(5.0, "strip_weapons", id)
}
}
public strip_weapons(id){
fm_strip_user_weapons(id)
fm_give_item(id, "weapon_knife")
}
public eventRoundStart() {
g_free = false
g_bFree = false
g_free_time = true
g_use_button = false
set_task(20.0,"timer")
}
public timer(){
g_free_time = false
}
public cmdFree(id) {
if (get_pcvar_num(g_cvar_t_only) && get_user_team(id) != 1) {
client_print(0,print_chat, "[Deathrun[4]Fun] Only T's Can Give FreeRound!");
return PLUGIN_HANDLED
}
if(g_use_button){
client_print(0,print_chat, "[Deathrun[4]Fun] You Used A Trap, FreeRound Is Not Possble!");
return PLUGIN_HANDLED
}
if(g_free_time){
new players[32], plNum
get_players(players, plNum, "ace", "TERRORIST")
g_free = true
g_bFree = true
set_hudmessage(0, 255, 255, 0.02, -1.0)
show_hudmessage(0, "FreeRound!")
new i
get_players(players, plNum, "ah")
for (i = 0; i < plNum; i++) {
fm_strip_user_weapons(players[i])
fm_give_item(players[i], "weapon_knife")
}
}else{
set_hudmessage(0, 255, 255, 0.02, -1.0)
show_hudmessage(id, "Only In the first 20 sec.!")
}
return PLUGIN_HANDLED
}
public fwdTouch(ent, id) {
if (is_user_alive(id) && g_free)
return HAM_SUPERCEDE
return HAM_IGNORED
}
public fwdUse(ent, idcaller, idactivator, use_type, Float:value) {
g_use_button = true
if (is_user_alive(idactivator) && g_free && get_user_team(idactivator) == 1) {
client_print(0,print_chat, "[Deathrun[4]Fun] It's FreeRound, You Cannot Use Traps!");
return HAM_SUPERCEDE
}
return HAM_IGNORED
}