AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Enable buy for both teams on maps w/o func_buyzone or info_map_parameters (https://forums.alliedmods.net/showthread.php?t=321646)

RaZ_HU 02-21-2020 05:51

Enable buy for both teams on maps w/o func_buyzone or info_map_parameters
 
As the title says I want to enable buy for both teams on maps like de_nuke to be able to buy if a player spawns at enemy base (rtd thing), but without making the "default buyzone around players spawn" area bigger (like VEN's plugin) or enabling anywhere buy.

On maps where func_buyzone exists I got that work successfully with
Code:

entity_set_int( i_BuyZone, EV_INT_team, 0 );
But I have no idea for de_nuke :D

Edit: I do now, create a func_buyzone somewhere on the map and use fake_touch based on mp_buytime then supercede it, even if I have this idea a small help would be cool :P

Any help appreciated and thanks in advance!

Bugsy 02-21-2020 19:23

Re: Enable buy for both teams on maps w/o func_buyzone or info_map_parameters
 
de_nuke has info_map_parameters

RaZ_HU 02-22-2020 07:32

Re: Enable buy for both teams on maps w/o func_buyzone or info_map_parameters
 
I realized that later, but it only allows/blocks the buy per team, it does not create a buyzone if a T spawns at CT for example.

Bugsy 02-22-2020 10:59

Re: Enable buy for both teams on maps w/o func_buyzone or info_map_parameters
 
What about disabling the default buy zones and create a func_buyzone at each spawn?

RaZ_HU 02-22-2020 15:40

Re: Enable buy for both teams on maps w/o func_buyzone or info_map_parameters
 
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 :D

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.


All times are GMT -4. The time now is 08:58.

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