Raised This Month: $32 Target: $400
 8% 

Old problem: no points from bomb explode/defuse


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-13-2022 , 19:15   Old problem: no points from bomb explode/defuse
Reply With Quote #1

The topic has been discussed but as far as I can find it has not been properly solved:
https://forums.alliedmods.net/showth...t=15962&page=2
If a CT is killed by the bomb, planter gets points.

If it is not possible to solve this for the common usage, maybe someone can get a solution that fits my needs:
On my server the bomb is planted straight away and the bomb is stripped from players, so who actually gets the + 3 points is not always the planter / defuser.

Because of this I'm trying to think of a way to strip 3 points from whoever gained 3 points from the last round.

I KNOW this is very very bad code but it explains what I'm trying to do so maybe someone could do it better:

PHP Code:
new g_playersWithFrags[33][2]

//This is called when bomb explodes:
public GetAllPlayersWithFrags()
{
    new 
iPlayers32 ] , iNum id iFrags;
    
get_players(iPlayers iNum);
    for (new 
iNum i++)
    {
        
id iPlayers[i];
        
iFrags get_user_frags(id);
        
g_playerWithFrags[id][0] = id;
        
g_playerWithFrags[id][1] = iFrags;
    }
    
set_task(6.0"RemoveThreeFrags");
}

//This is triggered by delay so someone got +3 points, who? Remove three points from whoever.
public RemoveThreeFrags()
{
    new 
iPlayers32 ] , iNum id iFrags;
    
get_players(iPlayers iNum);
    for (new 
iNum i++)
    {
        
id iPlayers[i];
        if (
get_user_frags(id) == (g_playerWithFrags[id][1] + 3)) // This only works if I remove the "+ 3"
        
{
            
ExecuteHam(Ham_AddPointsid, -3true);
        }
    }

Sorry for this abomination and thanks for any help.
If someone could tell me why the comparison does not work that would atleast give me something that "works".

Last edited by GoldNux; 11-13-2022 at 19:38.
GoldNux is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-14-2022 , 16:42   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #2

Here you can use this hook to strip the 3 frags given to the defuser

PHP Code:
register_logevent("logevent_defuse"3"2=Defused_The_Bomb")

public 
logevent_defuse()
{
   new 
id = ........ The defuser id from the log.
   
set_user_frags(idget_user_frags(id) - 3)

}

And the same thing for the planter...
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !

Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-14-2022 , 21:50   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #3

Quote:
Originally Posted by Natsheh View Post
Here you can use this hook to strip the 3 frags given to the defuser

PHP Code:
register_logevent("logevent_defuse"3"2=Defused_The_Bomb")

public 
logevent_defuse()
{
   new 
id = ........ The defuser id from the log.
   
set_user_frags(idget_user_frags(id) - 3)

}

And the same thing for the planter...

and the defuser of the log is?, does not exist
you can hook the event, the act, but not get the one that put it like that, you have to look for the classname of the c4 which is "weapon_c4", from there get the owner, (assuming that the owner of the c4 is the one who planted it)

"new id = ........ The defuser id from the log."

It makes me laugh when they put these things in the middle when they don't even know

here you have a real guide, the logevent is only a hook of when something in particular happens, but it does not leave you any other tool

https://forums.alliedmods.net/showthread.php?t=40164

IMPORTANT Edit: if you just want to get the index of the planted and the defused, better hook the sound/voice, when someone defuses or plants, the player says a phrase, "the bomb has been planted", "the bomb was defused" , there you get the exact moment and index(I don't know if it works, it's just an idea, but you can follow the guide above if it doesn't work)


PHP Code:
public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_forward(FM_EmitSound "EmitSound");
}
public 
EmitSound(idchannel, const sound[])
{
    if(
equal(sound "weapons/planted.wav")) // i dont know the real name sound
    
{
           
// The bomb has been planted

           
set_user_frags(idget_user_frags(id) + 3)
    }
    else if(
equal(sound"weapons/defused.wav" ))
    {
           
// the bomb has been defused

           
set_user_frags(idget_user_frags(id) + 3)
    }


Last edited by MrPickles; 11-14-2022 at 22:12.
MrPickles is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-15-2022 , 01:25   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #4

For more information about when the frags are set to the defuser and the planter you can always relay onto the source code from
Quote:
regamedll
Also if you want to hook bomb explosion event you can use this hook
PHP Code:
RegisterHam(Ham_Use"func_bomb_target""fw_BombTarget_Explode_Post", .Post true); 
Or you can use csx module forwards/functions which are much simpler.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-15-2022 at 01:39.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
MrPickles
Senior Member
Join Date: Aug 2022
Location: Colombia
Old 11-15-2022 , 01:44   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #5

Quote:
Originally Posted by Natsheh View Post
For more information about when the frags are set to the defuser and the planter you can always relay onto the source code from

Also if you want to hook bomb explosion event you can use this hook
PHP Code:
RegisterHam(Ham_Use"func_bomb_target""fw_BombTarget_Explode_Post", .Post true); 
Or you can use csx module forwards/functions which are much simpler.
he wants to get when he defuses or plants, not when he explodes, stop confusing him

and at least if you are going to refer to a module with forwards, tell it the ones it has to use

Last edited by MrPickles; 11-15-2022 at 01:45.
MrPickles is offline
Natsheh
Veteran Member
Join Date: Sep 2012
Old 11-15-2022 , 09:04   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #6

Quote:
Originally Posted by MrPickles View Post
he wants to get when he defuses or plants, not when he explodes, stop confusing him

and at least if you are going to refer to a module with forwards, tell it the ones it has to use
He wants to give the planter frags for each one who dies from the bomb explosion, and i am not confusing anyone, the only one who is complaining is you.
__________________
@Jailbreak Main Mod v2.7.0 100%
@User Tag Prefix 100% done !
@Mystery Box 100% done !
@VIP System 100% done !


Last edited by Natsheh; 11-15-2022 at 09:06.
Natsheh is offline
Send a message via MSN to Natsheh Send a message via Skype™ to Natsheh
Old 11-15-2022, 10:29
kww
This message has been deleted by kww. Reason: sry
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-15-2022 , 12:57   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #7

I have tried so many ways for hours with no success.
I'm not sure if it is a problem with my plugin planting the bomb automatically or if it is because I'm testing with bots as the bomb is not properly removed from bots.

Anyways I think you guys missunderstood me, I'm trying to remove the +3 points that are given to the planter and defuser. In the thread I linked to in my OP they are talking about how it is hard to properly do this because if the bomb kills a CT the T still get points.

Now I've been experimenting with a lot of things, including:

PHP Code:
new g_BombCarrier;

public 
plugin_init()
{
    
register_logevent("logevent_function_p"3"2=Spawned_With_The_Bomb")
}

public 
logevent_function_p() {
    
g_BombCarrier get_loguser_index()
}

stock get_loguser_index() {
    new 
loguser[80], name[32]
    
read_logargv(0loguser79)
    
parse_loguser(logusername31)
 
    return 
get_user_index(name)


public 
newRound()
{
    
set_user_frags(g_BombCarrierget_user_frags(g_BombCarrier) - 3)

I think it works but there is no way to know when testing with bots, and my plugin swaps teams every round and points for bomb/defuse is added on next round so I think this fucks shit up.
For example sometimes when the bomb go off, me (who spawned with c4) gets +3, bot that also got bomb gets +3, and random CT gets + 3.

It's way to many things to consider because I am working with team swapping and auto bomb plant, also testing with bots does not help...

I would like to know, before I give up, if there is a proper way to compare frags from one round to another like I'm trying to do here below.

All I want is to remove 3 frags from whoever (maybe multiple) who gained 3 frags in the time between round over and round begin... Thank you!

PHP Code:
new g_playersWithFrags[33][2]

//This is called when bomb explodes:
public GetAllPlayersWithFrags()
{
    new 
iPlayers32 ] , iNum id iFrags;
    
get_players(iPlayers iNum);
    for (new 
iNum i++)
    {
        
id iPlayers[i];
        
iFrags get_user_frags(id);
        
g_playerWithFrags[id][0] = id;
        
g_playerWithFrags[id][1] = iFrags;
    }
    
set_task(6.0"RemoveThreeFrags");
}

//This is triggered by delay so someone got +3 points, who? Remove three points from whoever.
public RemoveThreeFrags()
{
    new 
iPlayers32 ] , iNum id iFrags;
    
get_players(iPlayers iNum);
    for (new 
iNum i++)
    {
        
id iPlayers[i];
        if (
get_user_frags(id) == (g_playerWithFrags[id][1] + 3)) // This only works if I remove the "+ 3"
        
{
            
ExecuteHam(Ham_AddPointsid, -3true);
        }
    }


Last edited by GoldNux; 11-15-2022 at 12:58.
GoldNux is offline
deprale
Senior Member
Join Date: Oct 2018
Location: Leeds
Old 11-23-2022 , 09:41   Re: Old problem: no points from bomb explode/defuse
Reply With Quote #8

https://forums.alliedmods.net/showthread.php?p=191011
__________________
deprale 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 00:32.


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