Raised This Month: $ Target: $400
 0% 

[Help] Bomb Odds


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
jezznar
Junior Member
Join Date: Aug 2013
Old 09-05-2013 , 03:16   [Help] Bomb Odds
Reply With Quote #1

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
}

Last edited by jezznar; 09-06-2013 at 04:20. Reason: created my own code. just based it on defuse mistake 1.4 code flow
jezznar is offline
 



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 18:58.


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