Raised This Month: $ Target: $400
 0% 

Enable buy for both teams on maps w/o func_buyzone or info_map_parameters


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
RaZ_HU
Senior Member
Join Date: May 2015
Location: Hungary
Old 02-22-2020 , 15:40   Re: Enable buy for both teams on maps w/o func_buyzone or info_map_parameters
Reply With Quote #1

I had that in my mind too, but it is easier to create a new buyzone for only the time it is needed I think.

This is where I got so far, I'm sure there are some mistakes but it works yet

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

public plugin_init()
{
    
register_plugin"Shared Buy Zones""0.2""RaZ_HU" );
}

public 
plugin_natives()
{
    
register_native("create_fake_buyzone""native_create_fake_buyzone");
}

public 
plugin_cfg()
{
    
// Set every buyzone usable for both teams
    
new iBuyZone = -1;

    if( 
fm_find_ent_by_classiBuyZone"func_buyzone" ) )
    {
        while( ( 
iBuyZone fm_find_ent_by_classiBuyZone"func_buyzone" ) ) )
        {
            
set_peviBuyZonepev_team);
        }
    }
}

/*
* Creates a fake buyzone around the player.
* If timer is defined then remove buyzone after that in seconds.
* native create_fake_buyzone(iEnt, iTeam = 0, Float:fTimeleft = 0.0);
*/

public native_create_fake_buyzone(plugin_idparams)
{
    new 
iEnt get_param(1);

    
// Stop if entity doesn't exist
    
if( !pev_validiEnt ) )
        return 
PLUGIN_HANDLED;

    new 
iTeam get_param(2);
    new 
Float:fTimeleft get_param_f(3);
    new 
Float:iOrigin[3];

    
// Get the origin of the entity (player) where we want to create a buyzone
    
fm_get_brush_entity_originiEntiOrigin );

    new 
iZone engfuncEngFunc_CreateNamedEntityengfuncEngFunc_AllocString"func_buyzone" ) );
    if ( 
iZone )
    {
        
dllfuncDLLFunc_SpawniZone );
        
set_peviZonepev_teamiTeam );
        
engfuncEngFunc_SetSizeiZoneFloat:{-96.0, -96.0, -48.0}, Float:{96.096.048.0} );
        
engfuncEngFunc_SetOriginiZoneiOrigin );
        
// To make sure it triggers
        
dllfuncDLLFunc_TouchiEntiZone );
    }
    
// Timer option, if not supplied then it will remain until mapchange
    
if( params == )
    {
        
set_taskfTimeleft"cancelBuy"iZone );
    }

    return 
PLUGIN_CONTINUE;
}

public 
cancelBuyiEnt )
{
    
engfuncEngFunc_RemoveEntityiEnt );

The usage is this simple (in the RTD plugin in my example where players spawn at next round):
PHP Code:
create_fake_buyzone(id0get_cvar_float("mp_buytime") ); 
Map filtering (aim, fy, scout etc.) is done in the RTD plugin too, but I wouldn't put that in this plugin for no reason.
RaZ_HU is offline
Reply


Thread Tools
Display Modes

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 08:59.


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