Hi,
First off, I'm a noob. so please. spare me.
I asked for help through the suggestion section but I guess
the one who replied didn't really have time so I was thinking of trying
it out. I have a VERY LIMITED knowledge of AMXX coding. But I do know
how to formulate logic on stuff but on another programming language.
so,
I'm basing my code on
Defuse Mistake 1.4 code.
The main purpose of it is "Plant Mistake" so basically, the bomb will detonate on a random chance when planted.
I also tried to use
[FAQ/Tutorial] CS Bomb Scripting as a reference.
can someone please help me?
P.S.
+credits goes to the creator of Defue Mistake 1.4:
RedShift187
Code:
#include <amxmodx>
#include <fakemeta>
#define PLUGIN "Bomb Odds"
#define VERSION "1"
#define AUTHOR "jezznar"
#define C4PTmr 3
new pmistake
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
//read cvar for percentage mistake ~ percentage conversion later
pmistake = register_cvar("pmistake","10")
//Check map if it has a bombsite before registering events
if(engfunc(EngFunc_FindEntityByString, -1, "classname", "func_bomb_target") > 0)
{
//function call when bomb plant is started
register_event("BarTime", "planting_bomb", "be", "1=3")
//function call when bomb explodes: cancel tasks
register_logevent("task_cancel", 6, "3=Target_Bombed")
//function call when c4 planting is cancelled: cancel tasks
register_event("BarTime", "task_cancel", "b", "1=0")
}
return PLUGIN_HANDLED
}
public planting_bomb(id) {
//new id = get_loguser_index()
//get the username of the user index
new pname[32]
get_user_name(id,pname,32)
new risk = get_pcvar_num(pmistake)
//random chance generation
new mistake = random_num(1, 100)
//compare mistake if equal or less than risk
//if true: c4 explosion
if (mistake <= risk)
{
//converts mistake to percent then multiplies it to the
//time needed to plant the bomb (around 3 seconds, C4PTmr)
//time before explosion = mistake% * C4PTmr
new time = mistake / 100 * C4PTmr
set_task(float(time),"bomb_explosion",1234)
client_print(0,print_chat, "%s triggered the bomb to explode", pname)
client_print(0,print_center, "%s triggered the bomb to explode", pname)
}
return PLUGIN_CONTINUE
}
public task_cancel()
{
//cancels task of explosion
remove_task(1234)
return PLUGIN_CONTINUE
}
public bomb_explosion()
{
new bombent = engfunc(EngFunc_FindEntityByString, -1, "model", "models/w_c4.mdl")
set_pdata_float(bombent, 100, get_gametime())
return PLUGIN_CONTINUE
}