Raised This Month: $ Target: $400
 0% 

[REQ] Buy Unlimited Ammo


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
st[]rm
Junior Member
Join Date: Jun 2010
Old 07-01-2010 , 04:05   [REQ] Buy Unlimited Ammo
Reply With Quote #1

Hello everyone!
Can someone help me to make buyable unlimited ammo plugin?
Example:
Write /buyammo (cost $xxxx)
Thanks in advance!
st[]rm is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 07-01-2010 , 05:01   Re: [REQ] Buy Unlimited Ammo
Reply With Quote #2

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

#define PLUGIN "Buy Unlimited Ammo"
#define VERSION "1.0"
#define AUTHOR "RedRobster"

#define fm_find_ent_by_class(%1,%2) engfunc(EngFunc_FindEntityByString, %1, "classname", %2)

new bool:g_HasAmmo[33]
new 
pcvarCost

new gReloadTime[33]

public 
plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_event("CurWeapon""changeWeapon""be""1=1")
    
register_logevent("Round_Start"2"1=Round_Start")
    
    
register_clcmd("say /buyammo""buyUnammo")
    
register_clcmd("say_team /buybammo""buyUnammo")
    
    
pcvarCost register_cvar("unammo_cost""10000")
}

public 
Round_Start()
{
    new 
iPlayers[32], iNum
    get_players
(iPlayersiNum)
    
    for(new 
iiNumi++)
    {
        
g_HasAmmo[iPlayers[i]] = false
    
}
}

public 
client_disconnect(id)
{
    
g_HasAmmo[id] = false
}

public 
buyUnammo(id)
{
    new 
cost get_pcvar_num(pcvarCost)
    
    if(
g_HasAmmo[id])
    {
        
client_print(idprint_chat"You already have unlimited ammo.")
        return 
PLUGIN_HANDLED
    
}
    
    new 
money cs_get_user_money(id)
    
    if(
money cost)
    {
        
client_print(idprint_chat"You don't have enough money to buy unlimited ammo.")
        return 
PLUGIN_HANDLED
    
}
    
    
g_HasAmmo[id] = true
    client_print
(idprint_chat"You have just purchased unlimited ammo.")
    
    
cs_set_user_money(id, (money-cost) )
    
    return 
PLUGIN_HANDLED
}

//Unlimited Ammo Code from Amx Super which is from Superhero Punisher by {HOJ} Batman
public changeWeapon(id)
{
    if(
g_HasAmmo[id])
    {
        new 
wpnid read_data(2);
        new 
clip read_data(3);
    
        if (
wpnid == CSW_C4 || wpnid == CSW_KNIFE) return;
        if (
wpnid == CSW_HEGRENADE || wpnid == CSW_SMOKEGRENADE || wpnid == CSW_FLASHBANG) return;
    
        if (
clip == 0reloadAmmo(id);
    }
}

public 
reloadAmmo(id)
{
    if (!
is_user_connected(id)) return;

    if (
gReloadTime[id] >= get_systime() - 1) return;
    
gReloadTime[id] = get_systime();

    new 
clipammowpn[32];
    new 
wpnid get_user_weapon(idclipammo);

    if (
wpnid == CSW_C4 || wpnid == CSW_KNIFE || wpnid == 0) return;
    if (
wpnid == CSW_HEGRENADE || wpnid == CSW_SMOKEGRENADE || wpnid == CSW_FLASHBANG) return;

    if (
clip == 0)
    {
        
get_weaponname(wpnid,wpn,31);
        new 
iWPNidx = -1;
        while((
iWPNidx fm_find_ent_by_class(iWPNidxwpn)) != 0)
        {
            if(
id == pev(iWPNidxpev_owner))
            {
                
cs_set_weapon_ammo(iWPNidxgetMaxClipAmmo(wpnid));
                break;
            }
        }
    }
}

stock getMaxClipAmmo(wpnid)
{
    new 
clipammo 0;
    switch (
wpnid)
    {
        case 
CSW_P228 clipammo 13;
        case 
CSW_SCOUT clipammo 10;
        case 
CSW_HEGRENADE clipammo 0;
        case 
CSW_XM1014 clipammo 7;
        case 
CSW_C4 clipammo 0;
        case 
CSW_MAC10 clipammo 30;
        case 
CSW_AUG clipammo 30;
        case 
CSW_SMOKEGRENADE clipammo 0;
        case 
CSW_ELITE clipammo 15;
        case 
CSW_FIVESEVEN clipammo 20;
        case 
CSW_UMP45 clipammo 25;
        case 
CSW_SG550 clipammo 30;
        case 
CSW_GALI clipammo 35;
        case 
CSW_FAMAS clipammo 25;
        case 
CSW_USP clipammo 12;
        case 
CSW_GLOCK18 clipammo 20;
        case 
CSW_AWP clipammo 10;
        case 
CSW_MP5NAVY clipammo 30;
        case 
CSW_M249 clipammo 100;
        case 
CSW_M3 clipammo 8;
        case 
CSW_M4A1 clipammo 30;
        case 
CSW_TMP clipammo 30;
        case 
CSW_G3SG1 clipammo 20;
        case 
CSW_FLASHBANG clipammo 0;
        case 
CSW_DEAGLE clipammo 7;
        case 
CSW_SG552 clipammo 30;
        case 
CSW_AK47 clipammo 30;
        case 
CSW_KNIFE clipammo 0;
        case 
CSW_P90 clipammo 50;
    }
    return 
clipammo;

To change the cost, just change the cvar in this code:
PHP Code:
pcvarCost register_cvar("unammo_cost""10000"
Just change the 10000 to whatever you want the cost to be. Or, you can just change the cvar in game or whatever. Your choice.

Last edited by RedRobster; 07-01-2010 at 05:04.
RedRobster is offline
st[]rm
Junior Member
Join Date: Jun 2010
Old 07-01-2010 , 06:06   Re: [REQ] Buy Unlimited Ammo
Reply With Quote #3

many 10x man!
Have a nice day!
st[]rm is offline
st[]rm
Junior Member
Join Date: Jun 2010
Old 09-05-2010 , 04:02   Re: [REQ] Buy Unlimited Ammo
Reply With Quote #4

Hello again!
I'll write here.
Can someone make menu for this plugin (up)?
Example:
Write /menu, it show's menu and choose option.
Thanks!
st[]rm is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-05-2010 , 20:38   Re: [REQ] Buy Unlimited Ammo
Reply With Quote #5

What other menu options would you want besides buy?

Command
ua_buymenu - Display menu to buy unlimited ammo

CVars
ua_price - Price of unlimited ammo
ua_ammochange - Controls whether or not the HUD displays a change in ammo (from Max->1 then refill back to Max). Set to 0, the HUD will always show max ammo, set to 1 the ammo value will change.

PHP Code:
#include <amxmodx>
#include <cstrike>
#include <fakemeta>
#include <hamsandwich>

new const Version[] = "0.1";

const 
MaxPlayers 32;

const 
m_pActiveItem 373;

const 
NoAmmoWeapons = ( ( << CSW_HEGRENADE ) | ( << CSW_SMOKEGRENADE ) |( << CSW_FLASHBANG ) | ( << CSW_KNIFE ) | ( << CSW_C4 ) );

new const 
g_MaxClipAmmo[] = 
{
    
0,
    
13
    
0,
    
10,  
    
0
    
7,  
    
0,  
    
30
    
30,  
    
0
    
15
    
20,  
    
25
    
30,  
    
35,  
    
25,  
    
12
    
20
    
10,  
    
30
    
100
    
8,   
    
30
    
30
    
20,  
    
0,  
    
7
    
30
    
30
    
0
    
50 
}

new const 
g_szAmmoSound[] = "items/9mmclip1.wav";

new 
bool:g_bUnlimitedAmmoMaxPlayers ];
new 
g_pPrice;
new 
g_pShowAmmoChange;

public 
plugin_init() 
{
    
register_plugin"Unlimited Ammo" Version "bugsy" );
        
    
register_concmd"ua_buymenu" "ShowMenu" );
    
    
g_pPrice register_cvar"ua_price" "2000" );
    
g_pShowAmmoChange register_cvar"ua_ammochange" "0" );
    
    if ( 
get_pcvar_numg_pShowAmmoChange ) )
        
register_event"CurWeapon" "Ev_CurWeapon" "be" "1=1" "3=1" );
    else
        
register_event"CurWeapon" "Ev_CurWeapon" "be" "1=1" );
}

public 
plugin_precache()
{
    
precache_soundg_szAmmoSound );
}

public 
client_disconnectid )
{
    
g_bUnlimitedAmmoid ] = false;
}

public 
ShowMenuid )
{
    new 
szMenuItem20 ];
    new 
iMenu menu_create"Unlimited Ammo" "MenuHandler" );
    
    
formatexszMenuItem charsmaxszMenuItem ) , "Purchase ($%d)" get_pcvar_numg_pPrice ) );
    
menu_additemiMenu szMenuItem );
    
menu_displayid iMenu );
    
    return 
PLUGIN_HANDLED;
}

public 
MenuHandlerid iMenu iItem )
{
    new 
iMoney iPrice;
    
    if ( 
iItem == )
    {
        if ( 
g_bUnlimitedAmmoid ] == true )
        {
            
client_printid print_center "* You already have unlimited ammo!" );
        }
        else
        {
            
iMoney cs_get_user_moneyid );
            
iPrice get_pcvar_numg_pPrice );
            
            if ( 
iMoney >= iPrice )
            {
                
emit_soundid CHAN_AUTO g_szAmmoSound 1.0 ATTN_NORM PITCH_NORM );
                
cs_set_user_moneyid iMoney iPrice  );
                
                
g_bUnlimitedAmmoid ] = true;
            }
            else
            {
                
client_printid print_center "* You do not have enough money!" );
            }
        }
    }
    
    
menu_destroyiMenu );
    
    return 
PLUGIN_HANDLED;
}  

public 
Ev_CurWeaponid )
{
    static 
iWeaponiWeapon read_data);
    
    if( 
g_bUnlimitedAmmoid ] && !( NoAmmoWeapons & ( << iWeapon ) ) )
        
cs_set_weapon_ammoget_pdata_cbaseid m_pActiveItem ) , g_MaxClipAmmoiWeapon ] + );

__________________
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 08:52.


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