Raised This Month: $39 Target: $400
 9% 

Cancel Defuse on hit


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-26-2022 , 14:15   Cancel Defuse on hit
Reply With Quote #1

Simple request, i hope.

Cancel bot/human player defuse when get hit by bullets,bomb,knife etc. any damage.

So the ct has to start defusing all over, given its still alive
Ark_Procession is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-27-2022 , 02:49   Re: Cancel Defuse on hit
Reply With Quote #2

PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
new bool:isDefusing
new defuser

//const m_bIsDefusing    = 929 // (1.8.3+ only) 949 if linux (didn't work in my tests, default hlds with amxx 1.10)

public plugin_init( )
{
    
register_plugin"Stop Def on Dmg""alliedmods""1.0" )
    
RegisterHamHam_TakeDamage"player""fw_TakeDamage" )
    
register_event("BarTime""bomb_defuse_start""be""1=5""1=10")
    
register_event("BarTime""bomb_defuse_stop""b""1=0")
}

public 
bomb_defuse_start(id)
{
    
isDefusing true
    defuser 
id
}

public 
bomb_defuse_stop(id)
{
    
isDefusing false
}

public 
fw_TakeDamagevictiminflictorattackerFloat:damage ){
    if (
is_user_connected(victim) && (victim == defuser && isDefusing) ) {
        
StopDefuser(victim)
    }
}

StopDefuser(const player//Credits https://forums.alliedmods.net/showpost.php?p=2592752&postcount=4
{
    const 
m_bStartDefuse 384                                                    
    
const m_bIsDefusing  929
    
static gmsgBarTime

    
if(!gmsgBarTime)
    {
        
gmsgBarTime get_user_msgid("BarTime")
    }

    if( 
is_user_connected(player) )
        {
            
set_pdata_bool(playerm_bIsDefusingfalse)
            
set_pdata_bool(playerm_bStartDefusefalse)
            
            
message_begin(MSG_ONEgmsgBarTime_player)
            {
                
write_short(0)
                
message_end()
            }
            
            
engclient_cmd(player"lastinv")
            
engclient_cmd(player"lastinv")
        }

__________________

Last edited by deprale; 11-27-2022 at 03:16.
deprale is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-27-2022 , 14:03   Re: Cancel Defuse on hit
Reply With Quote #3

Quote:
Originally Posted by deprale View Post
PHP Code:
#include <amxmodx>
#include <hamsandwich>
#include <fakemeta>
new bool:isDefusing
new defuser

//const m_bIsDefusing    = 929 // (1.8.3+ only) 949 if linux (didn't work in my tests, default hlds with amxx 1.10)

public plugin_init( )
{
    
register_plugin"Stop Def on Dmg""alliedmods""1.0" )
    
RegisterHamHam_TakeDamage"player""fw_TakeDamage" )
    
register_event("BarTime""bomb_defuse_start""be""1=5""1=10")
    
register_event("BarTime""bomb_defuse_stop""b""1=0")
}

public 
bomb_defuse_start(id)
{
    
isDefusing true
    defuser 
id
}

public 
bomb_defuse_stop(id)
{
    
isDefusing false
}

public 
fw_TakeDamagevictiminflictorattackerFloat:damage ){
    if (
is_user_connected(victim) && (victim == defuser && isDefusing) ) {
        
StopDefuser(victim)
    }
}

StopDefuser(const player//Credits https://forums.alliedmods.net/showpost.php?p=2592752&postcount=4
{
    const 
m_bStartDefuse 384                                                    
    
const m_bIsDefusing  929
    
static gmsgBarTime

    
if(!gmsgBarTime)
    {
        
gmsgBarTime get_user_msgid("BarTime")
    }

    if( 
is_user_connected(player) )
        {
            
set_pdata_bool(playerm_bIsDefusingfalse)
            
set_pdata_bool(playerm_bStartDefusefalse)
            
            
message_begin(MSG_ONEgmsgBarTime_player)
            {
                
write_short(0)
                
message_end()
            }
            
            
engclient_cmd(player"lastinv")
            
engclient_cmd(player"lastinv")
        }

Thanks, very kind.

having an error compiling it:

C:\Users\efler\Desktop\addons\amxmodx\scripti ng\custom_def_cancel.sma(1) : fatal error 100: cannot read from file: "<amxmodx>"

the code is exactly the same , i suspect there is something wrong with my compiler

edit: i dont think there is a problem with my compiler, but im getting this on several code i found browsing the forums.

all my 40 plugins recompile without this issue. anyone know what's up?

i even downloaded amx on another pc , copied your code, tried to compile it and didnt work. so not a problem on my end,
not even with a web compiler, amx studio or a random pawn compiler from github.

what is going on?

Last edited by Ark_Procession; 11-27-2022 at 19:54. Reason: whatisgoingon
Ark_Procession is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-27-2022 , 20:55   Re: Cancel Defuse on hit
Reply With Quote #4

I compiled it on 1.10 and it was fine... thats a very strange issue.

Might wanna fix that scripti ng thing though, the folder can do that i guess if it has spaces.
Also I hope you're not on 1.8.2 because that offset is not gonna work, set_pdata was introduced in 1.8.3 as well, there is a stock for that but it would be easier if you just... updated from 1.8.2 if you are on that.

Looks like you might have wrote "" by accident in front of #include (HERE)<amxmodx>

Let's see if you can use it if the website compiles it for you
Attached Files
File Type: sma Get Plugin or Get Source (bombdefusestophit.sma - 11 views - 1.6 KB)
__________________

Last edited by deprale; 11-27-2022 at 20:56.
deprale is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-27-2022 , 22:05   Re: Cancel Defuse on hit
Reply With Quote #5

Quote:
Originally Posted by deprale View Post
I compiled it on 1.10 and it was fine... thats a very strange issue.

Might wanna fix that scripti ng thing though, the folder can do that i guess if it has spaces.
Also I hope you're not on 1.8.2 because that offset is not gonna work, set_pdata was introduced in 1.8.3 as well, there is a stock for that but it would be easier if you just... updated from 1.8.2 if you are on that.

Looks like you might have wrote "" by accident in front of #include (HERE)<amxmodx>

Let's see if you can use it if the website compiles it for you
I know the error says that there is that character, is the weirdest thing. this is a freshly install win 10.
i copied the code to a new sma file created from scratch as i said with multiple ways and even 2 computers. not sure whats going on.

The sma you provide compiles just fine. i hate this error
Tested it, doesnt seem to cancel a bot defusing, can you add support for bots?

Edit: using zbot and condition zero. not willing to change for podbots.

Last edited by Ark_Procession; 11-27-2022 at 22:12.
Ark_Procession is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-28-2022 , 00:01   Re: Cancel Defuse on hit
Reply With Quote #6

Quote:
Originally Posted by Ark_Procession View Post
I know the error says that there is that character, is the weirdest thing. this is a freshly install win 10.
i copied the code to a new sma file created from scratch as i said with multiple ways and even 2 computers. not sure whats going on.

The sma you provide compiles just fine. i hate this error
Tested it, doesnt seem to cancel a bot defusing, can you add support for bots?

Edit: using zbot and condition zero. not willing to change for podbots.
Try this, unsure if it works though it's untested.
Attached Files
File Type: sma Get Plugin or Get Source (bombdefusestophit.sma - 14 views - 1.6 KB)
__________________
deprale is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-28-2022 , 01:30   Re: Cancel Defuse on hit
Reply With Quote #7

Quote:
Originally Posted by deprale View Post
Try this, unsure if it works though it's untested.
Hey

its not working.
Ark_Procession is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-28-2022 , 02:00   Re: Cancel Defuse on hit
Reply With Quote #8

Uhm then I'm not too sure about bots especially zbots which is grey area as BAILOPAN has specified many ages ago.

It should work with podbots for sure though, I can't think of any way to make it work for bots or rather zbots specifically, I tested with podbots and it worked.
__________________
deprale is offline
Ark_Procession
Senior Member
Join Date: Jun 2020
Location: Argentina
Old 11-28-2022 , 15:55   Re: Cancel Defuse on hit
Reply With Quote #9

Quote:
Originally Posted by deprale View Post
Uhm then I'm not too sure about bots especially zbots which is grey area as BAILOPAN has specified many ages ago.

It should work with podbots for sure though, I can't think of any way to make it work for bots or rather zbots specifically, I tested with podbots and it worked.
Alright man, already a big help to have it for humans

thank you
Ark_Procession is offline
administratora
Member
Join Date: Mar 2015
Old 12-19-2022 , 17:53   Re: Cancel Defuse on hit
Reply With Quote #10

Quote:
Originally Posted by Ark_Procession View Post
Alright man, already a big help to have it for humans

thank you
If the one provided is not working, try that one:

PHP Code:
#include <amxmodx>
#include <fun>

new g_iDefuseOnGoing[33];

public 
client_preinfochanged(id)
{
    if (
g_iDefuseOnGoing[id])
    {
        
g_iDefuseOnGoing[id] = 0;
        
client_print(idprint_center"Defuse cancelled due to damage!");
    }
}

public 
bomb_defuse(idtime)
{
    
g_iDefuseOnGoing[id] = 1;
    
set_task(float(time), "defuse_task"id);
}

public 
defuse_task(id)
{
    
g_iDefuseOnGoing[id] = 0;
    
client_print(idprint_center"Bomb defused successfully!");
}

public 
client_death(id)
{
    if (
g_iDefuseOnGoing[id])
    {
        
g_iDefuseOnGoing[id] = 0;
        
client_print(idprint_center"Defuse cancelled due to death!");
    }

administratora is offline
Reply


Thread Tools
Display Modes

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 20:28.


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