Raised This Month: $ Target: $400
 0% 

Stop players from buying but not from picking.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-25-2011 , 10:19   Stop players from buying but not from picking.
Reply With Quote #1

I want to know what to do that this code would be only that players who don't have ADMIN_LEVEL_H coudn't buy awp, sg550, g3sg1. But they could pick it up if someone drop it.
PHP Code:
public event_CurSnipers(id)
    {    
    
get_mapnamemapnamecharsmax(mapname) );
    if ( 
equali(mapname"awp_india") || equali(mapname"awp_dust") || equali(mapname"cs_deagle5") )
        return 
PLUGIN_CONTINUE;
        
    if(
read_data(2) == CSW_G3SG1)
    {
        if(!(
get_user_flags(id) & ADMIN_LEVEL_H))
        {
        
client_print(idprint_center"Sniper's only for VIP's")
        
client_cmd(id"drop")
        }
    }
    if(
read_data(2) == CSW_SG550)
    {
        if(!(
get_user_flags(id) & ADMIN_LEVEL_H))
        {
            
client_print(idprint_center"Sniper's only for VIP's")
            
client_cmd(id"drop")
        }
    }
    if(
read_data(2) == CSW_AWP)
    {
        if(!(
get_user_flags(id) & ADMIN_LEVEL_H))
        {
        
client_print(idprint_center"Sniper's only for VIP's")
        
client_cmd(id"drop")
        }
    }
    return 
PLUGIN_HANDLED

__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-25-2011 at 10:23.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-25-2011 , 23:36   Re: Stop players from buying but not from picking.
Reply With Quote #2

I have a better/cleaner idea in mind, I'll redo it when I get a chance. The annoying thing with my current method is the player drops his current weapon when he attempts to buy a restricted weapon and the restricted weapon gets dropped/deleted and the player gets his money back. It would be cleaner if these things were not visible to they player.
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new const Version[] = "0.1";

const 
OFFSET_CSMONEY 115;
const 
NO_BUY_WEAPONS = ( ( << CSW_AWP ) | ( << CSW_G3SG1 ) | ( << CSW_SG550 ) );
const 
ADMIN_FLAG ADMIN_LEVEL_H;

new 
g_iMoney33 ] , g_Weapons33 ] , HamHook:g_HamSpawn;

public 
plugin_init() 
{
    
register_plugin"Pickup-Only Weapons" Version "bugsy" );
    
    
register_messageget_user_msgid"Money" ) , "MessageMoney" );
    
RegisterHamHam_AddPlayerItem "player" "fw_HamAddPlayerItem" );
}

public 
MessageMoneymsgid dest id )
{
    if ( 
get_user_flagsid ) & ADMIN_FLAG )
        return;

    new 
iNewWeapon = ( pevid pev_weapons ) & ~g_Weaponsid ] ) & NO_BUY_WEAPONS;
    new 
iSpent g_iMoneyid ] - ( g_iMoneyid ] = get_msg_arg_int) );
    new 
iNewMoney g_iMoneyid ];
    
    if ( 
iNewWeapon )
    {
        
set_pdata_intid OFFSET_CSMONEY iNewMoney iSpent );
        
set_msg_arg_intARG_LONG iNewMoney iSpent );
        
g_iMoneyid ] += iSpent;
        
        new 
szWeapon20 ];
        
get_weaponnameGetBitiNewWeapon ) , szWeapon charsmaxszWeapon ) );
        
g_HamSpawn RegisterHamHam_Spawn "weaponbox" "fw_HamSpawn_Weaponbox" );
        
engclient_cmdid "drop" szWeapon );

        
ucfirstszWeapon] );
        
client_printid print_center "You Cannot Purchase The %s" szWeapon] );
    }
}

public 
fw_HamAddPlayerItemiPlayer )
{
    
g_WeaponsiPlayer ] = peviPlayer pev_weapons );
}

public 
fw_HamSpawn_WeaponboxiEntity )
{
    
set_peviEntity pev_flags FL_KILLME );
    
dllfuncDLLFunc_Think iEntity );
    
DisableHamForwardg_HamSpawn );
}

GetBitiValue )
{
    new 
iBit = -1;
    
    for ( new 
32 i++ )
    {
        if ( 
iValue & ( << ) )
        {
            
iBit i;
            break;
        }
    }
    
    return 
iBit;

__________________

Last edited by Bugsy; 10-26-2011 at 00:11.
Bugsy is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 10-26-2011 , 01:27   Re: Stop players from buying but not from picking.
Reply With Quote #3

When you remove a weaponbox at spawn it's too early so weapons are not removed as well.
I think this way is cleaner : http://forums.alliedmods.net/showthread.php?t=149380

And anyway, i think such plugins already exist.

Edit : Best way is "info_map_parameters" way !!!
Simple and efficient :
PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"
#define PLUGIN "No Buy"

public plugin_init()
{
    
register_plugin(PLUGINVERSION"ConnorMcLeod")

    
register_clcmd("buy""ClientCommand_Buy")
    
register_clcmd("bUy""ClientCommand_Buy")
    
register_clcmd("buY""ClientCommand_Buy")
    
register_clcmd("bUY""ClientCommand_Buy")
    
register_clcmd("Buy""ClientCommand_Buy")
    
register_clcmd("BUy""ClientCommand_Buy")
    
register_clcmd("BuY""ClientCommand_Buy")
    
register_clcmd("BUY""ClientCommand_Buy")
}

public 
plugin_precache()
{
    
#define CMapInfo_Linux_XOff    5
    #define m_iBuyingStatus 34
    
new iEnt engfunc(EngFunc_CreateNamedEntityengfunc(EngFunc_AllocString,"info_map_parameters"))
    
set_pdata_int(iEntm_iBuyingStatus3CMapInfo_Linux_XOff)
    
dllfunc(DLLFunc_SpawniEnt)
    
engfunc(EngFunc_RemoveEntityiEnt)

    
server_cmd("sv_restartround 1")
}

public 
ClientCommand_Buy/* id */ )
{
    return 
PLUGIN_HANDLED_MAIN

__________________
- tired and retired -

- my plugins -

Last edited by ConnorMcLeod; 10-26-2011 at 01:36.
ConnorMcLeod is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-26-2011 , 01:41   Re: Stop players from buying but not from picking.
Reply With Quote #4

Ok. I don't understand your codes at all. Can you explaine me this?
PHP Code:
if(read_data(2) == CSW_AWP
Its reads if player tries to buy and if player has AWP?
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-26-2011 at 01:41.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Old 10-26-2011, 05:50
Evaldas.Grigas
This message has been deleted by Evaldas.Grigas.
drekes
Veteran Member
Join Date: Jul 2009
Location: Vault 11
Old 10-26-2011 , 05:55   Re: Stop players from buying but not from picking.
Reply With Quote #5

Bacause client_buy is a forward.
It's used like this:
PHP Code:
public client_buy(idiItem)
{
    if(
iItem == CSW_G3SG1)
    {
        
// id attemps to buy g3sg1
    
}

__________________

Quote:
Originally Posted by nikhilgupta345 View Post
You're retarded.

Last edited by drekes; 10-26-2011 at 05:55.
drekes is offline
Send a message via MSN to drekes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-26-2011 , 08:15   Re: Stop players from buying but not from picking.
Reply With Quote #6

Connor, this is the second time I forgot about your client_buy() forward and wasted time doing something another less desirable way. This is not the other method I had in mind, I was thinking what you did here which also worked cleanly but the method below is obviously much easier\appropriate.

The below plugin requires that you install ConnorMcLeods client_buy forward:
1. Download cl_buy.inc, put in include folder
2. Download and compile client_buy.sma. Place in plugins folder.
3. Add to plugins.ini client_buy.amxx

If you want it to display the weapon name when a buy attempt is made just let me know or you may be able to figure it out.
PHP Code:
#include <amxmodx>
#include <cl_buy>

new const Version[] = "0.2";

const 
NO_BUY_WEAPONS = ( ( << CSW_AWP ) | ( << CSW_G3SG1 ) | ( << CSW_SG550 ) );
const 
ADMIN_FLAG ADMIN_LEVEL_H;

public 
plugin_init() 
{
    
register_plugin"No-Buy Weapons" Version "bugsy" );
}

public 
client_buyid iItem )
{
    if ( ( ( 
<< iItem ) & NO_BUY_WEAPONS ) && !( get_user_flagsid ) & ADMIN_LEVEL_H ) && !user_has_weaponid iItem ) )
    {
        
client_printid print_center "You cannot buy that" );
        return 
PLUGIN_HANDLED;
    }
    return 
PLUGIN_CONTINUE;

__________________

Last edited by Bugsy; 10-26-2011 at 09:09.
Bugsy is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-26-2011 , 11:09   Re: Stop players from buying but not from picking.
Reply With Quote #7

Why this doesn't work? Still normal player can buy sg550. I want it to stop them from buying.
PHP Code:
public event_CurSnipers(idi Item)
{
    if(
iItem == CSW_SG550)
    {
        if(!(
get_user_flags(id) & ADMIN_LEVEL_H))
        {
            
client_print(idprint_center"Sniper's only for VIP's")
            
client_cmd(id"drop")
        }
    }

__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-26-2011 at 11:10.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-26-2011 , 11:17   Re: Stop players from buying but not from picking.
Reply With Quote #8

I wrote two plugins for you, why are you still trying to use your code which is wrong and doesn't work? Use the plugin in my above post.
__________________
Bugsy is offline
Evaldas.Grigas
Senior Member
Join Date: Sep 2011
Location: Lithuania
Old 10-26-2011 , 11:20   Re: Stop players from buying but not from picking.
Reply With Quote #9

I'll test it.
EDIT: Doesn't work. Why do you need this? const ADMIN_FLAG = ADMIN_LEVEL_H;
__________________
Please enter this website everyday: http://forums.alliedmods.net/showthread.php?t=169067

Last edited by Evaldas.Grigas; 10-26-2011 at 11:27.
Evaldas.Grigas is offline
Send a message via Skype™ to Evaldas.Grigas
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-26-2011 , 11:29   Re: Stop players from buying but not from picking.
Reply With Quote #10

If a player has that flag he can buy those rifles...like you asked for.
__________________
Bugsy 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 14:15.


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