Raised This Month: $51 Target: $400
 12% 

Bomb Pickup Event


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
avenger_ansh
Junior Member
Join Date: Dec 2006
Old 08-15-2008 , 14:47   Bomb Pickup Event
Reply With Quote #1

Hi,

I want to disable planting if a specific task exists but only when the bomb is picked up but cs_set_user_plant doesnt seem to be working in the following code:

PHP Code:
    register_event("TextMsg","event_bomb_pickup","bc","2&#Got_bomb")

public 
event_bomb_pickup(id)
{
    if(
task_exists(TASK_ID))
    {
        
client_print(idprint_chat"Planting Disabled")
        
cs_set_user_plant(id00)
    }

I can see the Planting Disabled message when i pick up the bomb but I can still plant the bomb

cs_set_user_plant works with the following but these events r also fired when the round starts:

PHP Code:
register_event("StatusIcon""event_bomb_pickup""be""1=1""1=2""2=c4"
PHP Code:
register_event("WeapPickup""event_bomb_pickup""be""1=6"
avenger_ansh is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 08-15-2008 , 14:50   Re: Bomb Pickup Event
Reply With Quote #2

How is set the the set_task() ?
__________________
Arkshine is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-15-2008 , 14:55   Re: Bomb Pickup Event
Reply With Quote #3

You can use HamSandwich and hook AddPlayerItem. Not tested:
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
    RegisterHam(Ham_AddPlayerItem,"fwAddPlayerItem")

public fwAddPlayerItem(player,item)
{
    static classname[32]
    pev(item,pev_classname,classname,charsmax(classname))
    
    if(equali(classname,"weapon_c4"))
        client_print(player,print_center,"BOMB PICKUP EVENT")
    
    return HAM_IGNORED
}
danielkza is offline
zwfgdlc
Senior Member
Join Date: May 2006
Old 08-15-2008 , 16:25   Re: Bomb Pickup Event
Reply With Quote #4

PHP Code:
public event_bomb_pickup(id)
{
    if(
task_exists(TASK_ID))
    {
        
client_print(idprint_chat"Planting Disabled")
        
cs_set_user_plant(id00)
    }

change to
PHP Code:
public event_bomb_pickup(id)
{
    if(
task_exists(TASK_ID))
    {
        
client_print(idprint_chat"Planting Disabled")
        
cs_set_user_bpammo(id,CSW_C4,0)
        
cs_set_user_plant(id00)
    } 
}
zwfgdlc is offline
avenger_ansh
Junior Member
Join Date: Dec 2006
Old 08-15-2008 , 22:37   Re: Bomb Pickup Event
Reply With Quote #5

Quote:
Originally Posted by arkshine View Post
How is set the the set_task() ?
player_id[0] = TASK_ID
set_task(get_pcvar_float(g_c4Wait), "plant_enable", TASK_ID, player_id, 1)

Quote:
Originally Posted by danielkza View Post
You can use HamSandwich and hook. AddPlayerItem
error 088: number of arguments does not match definition

PHP Code:
RegisterHam(Ham_AddPlayerItem,"fwAddPlayerItem"
Quote:
Originally Posted by zwfgdlc View Post
PHP Code:
public event_bomb_pickup(id)
{
    if(
task_exists(TASK_ID))
    {
        
client_print(idprint_chat"Planting Disabled")
        
cs_set_user_bpammo(id,CSW_C4,0)
        
cs_set_user_plant(id00)
    } 
}
Didnt work
avenger_ansh is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-15-2008 , 23:57   Re: Bomb Pickup Event
Reply With Quote #6

Quote:
Originally Posted by avenger_ansh View Post
player_id[0] = TASK_ID
set_task(get_pcvar_float(g_c4Wait), "plant_enable", TASK_ID, player_id, 1)



error 088: number of arguments does not match definition

PHP Code:
RegisterHam(Ham_AddPlayerItem,"fwAddPlayerItem"
Didnt work
I told you i did not test it. Just looking at the HamSandwich include would show you what I forgot.Tested and working:
Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

public plugin_init()
    RegisterHam(Ham_AddPlayerItem,"player","fwAddPlayerItem")

public fwAddPlayerItem(player,item)
{
    static classname[32]
    pev(item,pev_classname,classname,charsmax(classname))
    
    if(equali(classname,"weapon_c4"))
        client_print(player,print_center,"BOMB PICKUP EVENT")
    
    return HAM_IGNORED
}
danielkza is offline
avenger_ansh
Junior Member
Join Date: Dec 2006
Old 08-16-2008 , 08:00   Re: Bomb Pickup Event
Reply With Quote #7

The forward also occurs at round start
avenger_ansh is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 08-16-2008 , 13:07   Re: Bomb Pickup Event
Reply With Quote #8

Quote:
Originally Posted by avenger_ansh View Post
The forward also occurs at round start
There is no way to avoid catching round-start without setting a flag or a task yourself. The bomb IS actually picked up at round start,so you must work around this.
danielkza is offline
avenger_ansh
Junior Member
Join Date: Dec 2006
Old 08-16-2008 , 20:49   Re: Bomb Pickup Event
Reply With Quote #9

Ok I fixed it by setting flags on restart and round start and using "WeapPickup" event and everything is working now but i still dont understand why cs_set_user_plant doesnt work with "TextMsg" event.
avenger_ansh is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 08-17-2008 , 03:09   Re: Bomb Pickup Event
Reply With Quote #10

This is how if prevent players from planting the bomb in my c4 management plugin :

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

#define OFFSET_MAPZONE            235
#define PLAYER_IN_BOMB_TARGET        (1<<1)

public plugin_init()
{
    
register_message(get_user_msgid("StatusIcon"), "msg_StatusIcon")
}

public 
msg_StatusIcon(msg_idmsg_destid) {
    if( 
get_msg_args() != )
        return 
PLUGIN_CONTINUE

    
new icon[3]
    
get_msg_arg_string(2icon2)
    if( !(
icon[0] == 'c' && icon[1] == '4') )
        return 
PLUGIN_CONTINUE

    
if(get_msg_arg_int(1) != 2)
        return 
PLUGIN_CONTINUE

    
new mapzones get_pdata_int(idOFFSET_MAPZONE)
    if(
mapzones PLAYER_IN_BOMB_TARGET)
    {
        
mapzones &= ~PLAYER_IN_BOMB_TARGET
        set_pdata_int
(idOFFSET_MAPZONEmapzones)
    }
    
set_msg_arg_int(1ARG_BYTE1)
    return 
PLUGIN_CONTINUE

Also, some additional info (not related with your problem) : http://forums.alliedmods.net/showthread.php?t=44593
__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 08-17-2008 at 03:13.
ConnorMcLeod 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 23:49.


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