AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Bomb Pickup Event (https://forums.alliedmods.net/showthread.php?t=75944)

avenger_ansh 08-15-2008 14:47

Bomb Pickup Event
 
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"


Arkshine 08-15-2008 14:50

Re: Bomb Pickup Event
 
How is set the the set_task() ?

danielkza 08-15-2008 14:55

Re: Bomb Pickup Event
 
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
}


zwfgdlc 08-15-2008 16:25

Re: Bomb Pickup Event
 
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)
    } 

}

avenger_ansh 08-15-2008 22:37

Re: Bomb Pickup Event
 
Quote:

Originally Posted by arkshine (Post 670091)
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 (Post 670097)
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 (Post 670153)
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

danielkza 08-15-2008 23:57

Re: Bomb Pickup Event
 
Quote:

Originally Posted by avenger_ansh (Post 670292)
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
}


avenger_ansh 08-16-2008 08:00

Re: Bomb Pickup Event
 
The forward also occurs at round start

danielkza 08-16-2008 13:07

Re: Bomb Pickup Event
 
Quote:

Originally Posted by avenger_ansh (Post 670479)
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.

avenger_ansh 08-16-2008 20:49

Re: Bomb Pickup Event
 
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.

ConnorMcLeod 08-17-2008 03:09

Re: Bomb Pickup Event
 
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


All times are GMT -4. The time now is 03:15.

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