Raised This Month: $ Target: $400
 0% 

Block Buyzone for specific players while they are in a Buyzone


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 06-20-2014 , 03:20   Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #1

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?
__________________
Kia is offline
NiHiLaNTh
Way Past Expiration
Join Date: May 2009
Location: Latvia
Old 06-20-2014 , 04:14   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #2

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.
__________________

NiHiLaNTh is offline
Send a message via Skype™ to NiHiLaNTh
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 06-20-2014 , 04:32   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #3

Does not seem to work for me, they can still buy.
__________________
Kia is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 06-20-2014 , 06:55   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #4

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

__________________
Preparing to release my plugins..
r0ck is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 06-20-2014 , 07:25   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #5

Quote:
Originally Posted by r0ck View Post
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.
__________________
Kia is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 06-20-2014 , 07:49   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #6

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

__________________
Preparing to release my plugins..

Last edited by r0ck; 06-20-2014 at 07:57.
r0ck is offline
Nextra
Veteran Member
Join Date: Apr 2008
Location: Germany
Old 06-20-2014 , 08:52   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #7

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
__________________
In Flames we trust!
Nextra is offline
r0ck
Senior Member
Join Date: Jun 2011
Location: India
Old 06-21-2014 , 01:19   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #8

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

__________________
Preparing to release my plugins..
r0ck is offline
meTaLiCroSS
Gaze Upon My Hat
Join Date: Feb 2009
Location: Viņa del Mar, Chile
Old 06-21-2014 , 10:28   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #9

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
__________________
Quote:
Originally Posted by joropito View Post
You're right Metalicross

Last edited by meTaLiCroSS; 06-21-2014 at 10:32.
meTaLiCroSS is offline
Kia
AlliedModders Donor
Join Date: Apr 2010
Location: In a world of madness
Old 06-22-2014 , 06:25   Re: Block Buyzone for specific players while they are in a Buyzone
Reply With Quote #10

Will update my plugin, thanks.
__________________
Kia 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 06:45.


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