Hi, I was trying to make a plugin that deactivates bomb sites and that when a user drops a bomb the bomb is transfered to him if is alive or to other teammates if the user has died or disconnected.
The first part, disabling bomb sites is working with ConnorMcLeod code.
The part that isn't working is the fm_give_item function. This logevent registers when the bomb is dropped and I it is working fine because I get the message no to drop the bomb but then I drop and I don't receive the bomb again, so the fm_give_item isn't working, I don't know why so I came to ask your help
Thanks
Code:
/*
Credits go to:
- ConnorMcLeod for SetBombSites
- VEN for everything else
*/
#include <amxmodx>
#include <engine>
#include <fakemeta_util.inc>
#define PLUGIN "Bomb FM"
#define VERSION "0.2"
#define AUTHOR "marquezs"
new bool:bActive
stock get_loguser_index() {
new loguser[80], name[32]
read_logargv(0, loguser, 79)
parse_loguser(loguser, name, 31)
return get_user_index(name)
}
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
if (!engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target"))
return
register_logevent("logevent_function_p", 3, "2=Dropped_The_Bomb")
SetBombSites(bActive)
}
public logevent_function_p() {
new id = get_loguser_index()
if(is_user_alive(id))
{
fm_give_item(id, "weapon_c4")
client_print(id, print_chat, "Do not drop the bomb again")
}
else if(!is_user_connected(id) || !is_user_alive(id))
{
new idp[32], num
get_players(idp, num, "ae", "TERRORIST")
if (!num)
return
new user_b = random_num(0, num)
fm_give_item(user_b, "weapon_c4")
client_print(0, print_chat, "Here is the bomb, enjoy")
}
else
client_print(0, print_chat, "Errorr")
}
SetBombSites( bool:bActive )
{
new iEnt = -1
while( (iEnt = find_ent_by_class(iEnt, "func_bomb_target")) > 0 )
{
entity_set_int(iEnt, EV_INT_solid, bActive ? SOLID_TRIGGER : SOLID_NOT)
}
while( (iEnt = find_ent_by_class(iEnt, "info_bomb_target")) > 0 )
{
entity_set_int(iEnt, EV_INT_solid, bActive ? SOLID_TRIGGER : SOLID_NOT)
}
}