AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   Cancel Defuse on hit (https://forums.alliedmods.net/showthread.php?t=340590)

Ark_Procession 11-26-2022 13:15

Cancel Defuse on hit
 
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 :twisted:

deprale 11-27-2022 01:49

Re: Cancel Defuse on hit
 
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")
        }



Ark_Procession 11-27-2022 13:03

Re: Cancel Defuse on hit
 
Quote:

Originally Posted by deprale (Post 2793795)
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?

deprale 11-27-2022 19:55

Re: Cancel Defuse on hit
 
1 Attachment(s)
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

Ark_Procession 11-27-2022 21:05

Re: Cancel Defuse on hit
 
Quote:

Originally Posted by deprale (Post 2793861)
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:oops:
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.

deprale 11-27-2022 23:01

Re: Cancel Defuse on hit
 
1 Attachment(s)
Quote:

Originally Posted by Ark_Procession (Post 2793867)
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:oops:
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.

Ark_Procession 11-28-2022 00:30

Re: Cancel Defuse on hit
 
Quote:

Originally Posted by deprale (Post 2793871)
Try this, unsure if it works though it's untested.

Hey

its not working.

deprale 11-28-2022 01:00

Re: Cancel Defuse on hit
 
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.

Ark_Procession 11-28-2022 14:55

Re: Cancel Defuse on hit
 
Quote:

Originally Posted by deprale (Post 2793880)
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

administratora 12-19-2022 16:53

Re: Cancel Defuse on hit
 
Quote:

Originally Posted by Ark_Procession (Post 2793934)
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!");
    }




All times are GMT -4. The time now is 08:01.

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