Raised This Month: $ Target: $400
 0% 

terrorist can defuse


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ÜnLoCo
Member
Join Date: Dec 2009
Location: 35.77N, 10.82E
Old 06-13-2010 , 09:09   terrorist can defuse
Reply With Quote #1

hello
let's say i gave a terrorist a defuser kit
PHP Code:
cs_set_user_defuse(id
and then
PHP Code:
RegisterHam(Ham_Use"grenade""C4Used"
what should i write after i know that the defuser is a terrorist

PHP Code:
public C4Used(iC4ididactivatoruse_typeFloat:value)
{
    if(
use_type == && value == 1.0 && get_user_team(id) == 1){
        
//plz help .. i want this terro to be able to defuse now. !
    
}

i'm writing this plugin so that a ct can pick up the dropped bomb and plant it.
then terrorists have to defuse it.
i have been able to prevent ct from defusing
PHP Code:
if(use_type == && value == 1.0 && get_user_team(id) == 2){
return         
HAM_SUPERCEED

but it got trickier when i wanted to allow a terrorist to defuse that c4 bomb.

help!
__________________
ÜnLoCo is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 01-31-2011 , 16:38   Re: terrorist can defuse
Reply With Quote #2

bump for this.
bibu is offline
Lulu the hero
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
Old 01-31-2011 , 20:42   Re: terrorist can defuse
Reply With Quote #3

Quite a crazy idea. Wouldn't it be easier if you would switch all players team quietly with cs_set_user_team, while not changing their model? That way the cts could plant, and the ts could defuse.

Seriously try go around it. Check if the user, who wants to defuse is pressing the USE key( check in player pre think ) and pointing against the planted bomb entity( use get_user_aiming, because you can set the distance here ). If so, then start a "defuse progress" animation( you can find a good example for that in the zp_extra_lasermine plugin ). If the progress finished, then remove the bomb entity and force a round end, plus display a message in the center.
Simple!

Edit:
Never mind the player pre think - pointing - using part. Your Ham function is better.

Last edited by Lulu the hero; 01-31-2011 at 20:46.
Lulu the hero is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-01-2011 , 01:54   Re: terrorist can defuse
Reply With Quote #4

Tested and works.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN "Terrorists Can Defuse"

new HamHook:g_ihHC4UsePost

#define XO_PLAYER 5
#define m_iTeam 114
#define TEAM_T 1
#define TEAM_CT 2

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")
    
RegisterHam(Ham_Use"grenade""C4_Use")
    
DisableHamForwardg_ihHC4UsePost RegisterHam(Ham_Use"grenade""C4_Use_Post"1) )
}

public 
C4_Use(iC4idiActivatoruse_typeFloat:value)
{
    if( 
use_type == && value == 1.0 && get_pdata_int(idm_iTeamXO_PLAYER) == TEAM_T )
    {
        
set_pdata_int(idm_iTeamTEAM_CTXO_PLAYER)
        
EnableHamForwardg_ihHC4UsePost )
        return 
HAM_HANDLED
    
}
    return 
HAM_IGNORED
}

public 
C4_Use_Post(iC4id)
{
    
set_pdata_int(idm_iTeamTEAM_TXO_PLAYER)
    
DisableHamForwardg_ihHC4UsePost )

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-01-2011 , 05:56   Re: terrorist can defuse
Reply With Quote #5

There is only 2 ways for that, either changing the team in pre/post like connor above, or blocking use as pre and rewrite all the code. Though changing the team all the time is really ugly.
__________________
Arkshine is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 02-02-2011 , 12:43   Re: terrorist can defuse
Reply With Quote #6

Thanks connor, works perfectly, I just wanted to know what these stuff do:

get_pdata_int(id, m_iTeam, XO_PLAYER)
set_pdata_int(id, m_iTeam, TEAM_CT, XO_PLAYER)
set_pdata_int(id, m_iTeam, TEAM_T, XO_PLAYER)

I would say, it gets team, and the other both sets team. In this case, tell me if I am wrong, what's with cs_s(g)et_user_team ?
bibu is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-02-2011 , 12:51   Re: terrorist can defuse
Reply With Quote #7

Both does the same, it uses a player's offset. Though, there is a difference about cs_set_user_team(), it set the team + send ClientUserInfoChanged + send TeamInfo message + pass the team name by reference.

In CC4::Use(), there is a check with the team offset to make sure you are in the CT team. So, all you need here is to set the offset with the CT team value (2), as pre, and restore as post. It does the trick. You don't need all the stuffs that does the cstrike native, that's why using the offset is enough.
__________________
Arkshine is offline
bibu
Veteran Member
Join Date: Sep 2010
Old 02-02-2011 , 14:28   Re: terrorist can defuse
Reply With Quote #8

Oh thanks, and how is get_pdata_int, I mean with cstrike you make == CS_TEAM_*
bibu is offline
Lulu the hero
Senior Member
Join Date: Oct 2009
Location: Budapest, Hungary
Old 02-02-2011 , 20:24   Re: terrorist can defuse
Reply With Quote #9

Quote:
Originally Posted by bibu View Post
Oh thanks, and how is get_pdata_int, I mean with cstrike you make == CS_TEAM_*
The offset is 114 for teams.

From ConnorMcLeod's get_user_team fix:
PHP Code:
new team get_pdata_int(id1145); 
Where 5 is the linux offset difference.
Lulu the hero is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-02-2011 , 14:36   Re: terrorist can defuse
Reply With Quote #10

I don't understand what you ask.
__________________
Arkshine is offline
Reply



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 14:47.


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