AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   terrorist can defuse (https://forums.alliedmods.net/showthread.php?t=129476)

ÜnLoCo 06-13-2010 09:09

terrorist can defuse
 
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!

bibu 01-31-2011 16:38

Re: terrorist can defuse
 
bump for this.

Lulu the hero 01-31-2011 20:42

Re: terrorist can defuse
 
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! :mrgreen:

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

ConnorMcLeod 02-01-2011 01:54

Re: terrorist can defuse
 
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 )



Arkshine 02-01-2011 05:56

Re: terrorist can defuse
 
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.

bibu 02-02-2011 12:43

Re: terrorist can defuse
 
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 ?

Arkshine 02-02-2011 12:51

Re: terrorist can defuse
 
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.

bibu 02-02-2011 14:28

Re: terrorist can defuse
 
Oh thanks, and how is get_pdata_int, I mean with cstrike you make == CS_TEAM_*

Arkshine 02-02-2011 14:36

Re: terrorist can defuse
 
I don't understand what you ask.

bibu 02-02-2011 14:55

Re: terrorist can defuse
 
I mean with cstrike, you get team by, cs_get_user_team(id) == CS_TEAM_* and with connors method I don't see how he can get the terror team.


All times are GMT -4. The time now is 14:47.

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