AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Block Buyzone for specific players while they are in a Buyzone (https://forums.alliedmods.net/showthread.php?t=242464)

Kia 06-20-2014 03:20

Block Buyzone for specific players while they are in a Buyzone
 
Hello everybody,

I want to block the possibility to buy weapons for specific players using this code by now:

PHP Code:

public Message_StatusIcon(iMsgIdiMsgDestid)  
{
    if(
g_bIsZombie[id])
    {
        static 
szIcon[8];  
        
get_msg_arg_string(2szIconcharsmax(szIcon));  
        if( 
equal(szIcon"buyzone") ) 
        {  
            if( 
get_msg_arg_int(1) )  
            {  
                
set_pdata_int(id235get_pdata_int(id235) & ~(1<<0)); 
                return 
PLUGIN_HANDLED;  
            }  
        }
    }
    
    return 
PLUGIN_CONTINUE;  


This works fine, but when a Player gets infected while he is in the buyzone, he can still open the buy menu.
Any solutions for that?

NiHiLaNTh 06-20-2014 04:14

Re: Block Buyzone for specific players while they are in a Buyzone
 
I remember somewhere seeing function fm_cs_set_user_nobuy. Basically its the same as this:
Code:

set_pdata_int(id, 235, get_pdata_int(id, 235) & ~(1<<0)); 


So you need to remove buyzone from player zone bitsum on infect.

Kia 06-20-2014 04:32

Re: Block Buyzone for specific players while they are in a Buyzone
 
Does not seem to work for me, they can still buy.

r0ck 06-20-2014 06:55

Re: Block Buyzone for specific players while they are in a Buyzone
 
Working for me

PHP Code:


#include <amxmodx>
#include <fakemeta>

#define m_iMapZone 235

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

public 
Message_StatusIcon(iMsgIdMSG_DESTid)
{
    static 
szIcon[5]; get_msg_arg_string(2szIconcharsmax(szIcon))
    
    if(
szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z')
    {
        if(
get_msg_arg_int(1))
        {
            
set_pdata_int(idm_iMapZoneget_pdata_int(idm_iMapZone) & ~(1<<0))
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE



Kia 06-20-2014 07:25

Re: Block Buyzone for specific players while they are in a Buyzone
 
Quote:

Originally Posted by r0ck (Post 2154466)
Working for me

PHP Code:


#include <amxmodx>
#include <fakemeta>

#define m_iMapZone 235

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

public 
Message_StatusIcon(iMsgIdMSG_DESTid)
{
    static 
szIcon[5]; get_msg_arg_string(2szIconcharsmax(szIcon))
    
    if(
szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z')
    {
        if(
get_msg_arg_int(1))
        {
            
set_pdata_int(idm_iMapZoneget_pdata_int(idm_iMapZone) & ~(1<<0))
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE



I want to block the buyzone while the player is already in buyzone, that does not help me.

r0ck 06-20-2014 07:49

Re: Block Buyzone for specific players while they are in a Buyzone
 
Said test while in buyzone and i was not able to buy, though the status icon of buyzone was still there


PHP Code:


#include <amxmodx>
#include <fakemeta>

#define m_iMapZone 235
new disallow[33]

public 
plugin_init()
{
    
register_message(get_user_msgid("StatusIcon") , "Message_StatusIcon")
    
register_clcmd("say test""testy")
    
register_clcmd("say test1""testy1")
}

public 
testy(id)
{
    
disallow[id] = 1
    set_pdata_int
(idm_iMapZoneget_pdata_int(idm_iMapZone) & ~(1<<0))
}
    
public 
testy1(id)
{
    
disallow[id] = 0
}

public 
Message_StatusIcon(iMsgIdMSG_DESTid)
{
    if(!
disallow[id])
        return 
PLUGIN_CONTINUE
    
    
static szIcon[5]; get_msg_arg_string(2szIconcharsmax(szIcon))
    
    if(
szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z')
    {
        if(
get_msg_arg_int(1))
        {
            
set_pdata_int(idm_iMapZoneget_pdata_int(idm_iMapZone) & ~(1<<0))
            return 
PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE



Nextra 06-20-2014 08:52

Re: Block Buyzone for specific players while they are in a Buyzone
 
If you want to use the buyzone bitmask you should take a look at your zombie plugin. It probably provides a forward like "PlayerInfected" or something similar. You need to use that forward to also remove the buyzone bitflag if the player is already inside it.

The easiest way would be using CS_OnBuy from AMXX 1.8.3.

Alternatively you can use the plugin and API made by ConnorMcLeod: https://forums.alliedmods.net/showthread.php?t=149380

r0ck 06-21-2014 01:19

Re: Block Buyzone for specific players while they are in a Buyzone
 
Found a way to remove buyzone icon from screen.. hope it helps you.
PHP Code:


    message_begin
(MSG_ONEMsgStatusIcon, {0,0,0}, id)
    
write_byte(0); // status (0=hide, 1=show, 2=flash)
    
write_string("buyzone")
    
write_byte(0)
    
write_byte(0)
    
write_byte(0)
    
message_end() 

------->

PHP Code:


#include <amxmodx>
#include <fakemeta>

new disallow[33]
new 
MsgStatusIcon

public plugin_init()
{
    
MsgStatusIcon get_user_msgid("StatusIcon")
    
register_message(MsgStatusIcon "Message_StatusIcon")
    
register_clcmd("say test""testy")
    
register_clcmd("say test1""testy1")
}

public 
testy(id)
{
    
disallow[id] = 1
    set_pdata_int
(id235get_pdata_int(id235) & ~(1<<0)) // m_iMapZone 235
    
    
message_begin(MSG_ONEMsgStatusIcon, {0,0,0}, id)
    
write_byte(0); // status (0=hide, 1=show, 2=flash)
    
write_string("buyzone")
    
write_byte(0)
    
write_byte(0)
    
write_byte(0)
    
message_end()
}
    
public 
testy1(id)
{
    
disallow[id] = 0
}

public 
Message_StatusIcon(iMsgIdMSG_DESTid)
{
    if(!
disallow[id])
        return 
PLUGIN_CONTINUE
    
    
static szIcon[5]; get_msg_arg_string(2szIconcharsmax(szIcon))
    
    if(
szIcon[0] == 'b' && szIcon[2] == 'y' && szIcon[3] == 'z')
    {
        if(
get_msg_arg_int(1))
        {
            
set_pdata_int(id235get_pdata_int(id235) & ~(1<<0)) // m_iMapZone 235
            
return PLUGIN_HANDLED
        
}
    }
    return 
PLUGIN_CONTINUE



meTaLiCroSS 06-21-2014 10:28

Re: Block Buyzone for specific players while they are in a Buyzone
 
When user gets infected, use this:

PHP Code:

#define m_flNextMapZoneTime 233
#define m_fClientMapZone 235

stock UpdatePlayerMapZones(iId)
{
    
// Make PreThink call CBasePlayer::HandleSignals at the next frame
    
set_pdata_float(iIdm_flNextMapZoneTime0.0

    
// Clear mask from all MapZones, this will check it's specific huds
    // In this case we will clear the related StatusIcon message for "buyzone"
    
set_pdata_int(iIdm_fClientMapZone0)


tip: Make sure you call this on infection, and disinfection, since a player can be disinfected while on buyzone and the same behavior will occur.

2 native calls v/s a lot of message related natives, wonderful

Kia 06-22-2014 06:25

Re: Block Buyzone for specific players while they are in a Buyzone
 
Will update my plugin, thanks. :)


All times are GMT -4. The time now is 21:09.

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