Raised This Month: $51 Target: $400
 12% 

getting weapons


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 04-22-2007 , 07:32   getting weapons
Reply With Quote #1

PHP Code:
if ( !get_pcvar_num g_switch ) )
        return 
PLUGIN_HANDLED
    
    
if ( !get_pcvar_num g_grenade ) )  
    {
        
client_printid print_chat "[AmxX] Currently unable to purchase grenades." )
    }
    
    if ( !
is_user_alive (id) || !is_user_connected (id) ) 
    {  
        
client_print (id print_chat "[AmxX] Unable to buy HE-Grenade due to your status (Dead)." )  
    }
    
    new 
money cs_get_user_money (id)
    new 
clip ammo weapon get_user_weapon id clip ammo )
    
    new 
multi get_pcvar_num g_multi )
    
    if ( 
weapon == CSW_HEGRENADE )
    {
        
client_print id print_chat "[AmxX] You already own one," )
    }
    else if ( 
money < ( multi g_he_nade ) )
    {
        
client_print id print_chat "[AmxX] You do not have enough money." )
    }
    else
    {
        
give_item (id "weapon_hegrenade" )
        
cs_set_user_money id money - ( multi g_he_nade ) )
        
client_print id print_chat ,  "[AmxX] Thank you for using Emergency Ammo!" )
    }
    
    return 
PLUGIN_HANDLED

I'm trying to check if the player has a HE or not. The problem is that get_user_weapon only works if the player is actually holding a HE in his hands.

For eg
I try to buy a HE buy with the script above (type /ammoh) and I'm holding a USP but I already have a HE. It still gives me a HE even though I'm maxed out on it. I want something to check the whole player if he has a weapon or not CARRYING it not currently HOLDING it.
__________________
It's a mystery.
Mini_Midget is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-22-2007 , 08:00   Re: getting weapons
Reply With Quote #2

I think you might find what you searching for here: http://www.amxmodx.org/doc/source/fu...er_weapons.htm
;)

greetz regalis
__________________
regalis is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 04-22-2007 , 08:10   Re: getting weapons
Reply With Quote #3

Oh cheers!

Never used that function before.

Can you show me how to use it with the example above?
__________________
It's a mystery.
Mini_Midget is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-22-2007 , 08:22   Re: getting weapons
Reply With Quote #4

I never used it too

But maybe something like this:
Code:
new Weapons[32]
new numWeapons, i, weapon
get_user_weapons(id, Weapons, numWeapons)
for (i=0; i<numWeapns; i++)
{
   weapon = Weapons[i]
   if ( weapon == CSW_HEGRENADE )
    {
        client_print ( id , print_chat , "[AmxX] You already own one," )
    }
    else if ( money < ( multi * g_he_nade ) )
    {
        new bool:noMoney = true
    }
    else
    {
        new bool:giveGrenade = true
    }
}
if(noMoney)    client_print(id , print_chat, "[AmxX] You do not have enough money." )

if(giveGrenade)
{
    give_item (id , "weapon_hegrenade" )
  cs_set_user_money ( id , money - ( multi * g_he_nade ) )
  client_print ( id , print_chat ,  "[AmxX] Thank you for using Emergency Ammo!" )
}
return PLUGIN_HANDLED
greetz regalis

PS: thx 4 karma
__________________
regalis is offline
Mini_Midget
Veteran Member
Join Date: Jan 2006
Location: It's a mystery.
Old 04-22-2007 , 08:59   Re: getting weapons
Reply With Quote #5

PHP Code:
public cmd_ammoh (id)
{
    if ( !
get_pcvar_num g_switch ) )
        return 
PLUGIN_HANDLED
    
    
if ( !get_pcvar_num g_grenade ) )  
    {
        
client_printid print_chat "[AmxX] Currently unable to purchase grenades." )
    }
    
    if ( !
is_user_alive (id) || !is_user_connected (id) ) 
    {  
        
client_print (id print_chat "[AmxX] Unable to buy HE-Grenade due to your status (Dead)." )  
    }
    
    new 
money cs_get_user_money (id)
    new 
multi get_pcvar_num g_multi )
    
    new 
weapons[32
    new 
numweapon
    
    get_user_weapons
(idweaponsnum)
    for(new 
0numi++)
    {
        
weapon weapons[i];
        
        if ( 
weapon == CSW_HEGRENADE )
        {
            
client_print id print_chat "[AmxX] You already own one," )
        }
    }
    if ( 
money < ( multi g_he_nade ) )
    {
        
client_print id print_chat "[AmxX] You do not have enough money." )
    }
    else
    {
        
give_item (id "weapon_hegrenade" )
        
cs_set_user_money id money - ( multi g_he_nade ) )
        
client_print id print_chat ,  "[AmxX] Thank you for using Emergency Ammo!" )
    }
    
    return 
PLUGIN_HANDLED

I'm trying to use this but it has this bug in it.

When I have a HE already. (Doesn't matter if I have it in my hands or not) and I type the command to buy. These 2 messages display.
[AmxX] You already own one!
[AmxX] Thank you for using Emergency Ammo!

AND it still charges me money even though I have one.
__________________
It's a mystery.
Mini_Midget is offline
regalis
Veteran Member
Join Date: Jan 2007
Location: F*cking Germany
Old 04-22-2007 , 09:08   Re: getting weapons
Reply With Quote #6

I think you should use a bool with that you can trace if the player have already a nade ;)

try this:
Code:
public cmd_ammoh (id)
{
    if ( !get_pcvar_num ( g_switch ) )
        return PLUGIN_HANDLED
    
    if ( !get_pcvar_num ( g_grenade ) )  
    {
        client_print( id , print_chat , "[AmxX] Currently unable to purchase grenades." )
    }
    
    if ( !is_user_alive (id) || !is_user_connected (id) ) 
    {  
        client_print (id , print_chat , "[AmxX] Unable to buy HE-Grenade due to your status (Dead)." )  
    }
    
    new money = cs_get_user_money (id)
    new multi = get_pcvar_num ( g_multi )
    new bool:haveOne

    new weapons[32] 
    new num, weapon
    
    get_user_weapons(id, weapons, num)
    for(new i = 0; i < num; i++)
    {
        weapon = weapons[i];
        
        if ( weapon == CSW_HEGRENADE )
        {
            client_print ( id , print_chat , "[AmxX] You already own one," )
            haveOne = true
        }
    }
    if ((money < ( multi * g_he_nade )) && (!haveOne))
    {
        client_print ( id , print_chat , "[AmxX] You do not have enough money." )
    }
    else if(!haveOne)
    {
        give_item (id , "weapon_hegrenade" )
        cs_set_user_money ( id , money - ( multi * g_he_nade ) )
        client_print ( id , print_chat ,  "[AmxX] Thank you for using Emergency Ammo!" )
    }
    
    return PLUGIN_HANDLED
}
__________________
regalis is offline
Ryu2877
Member
Join Date: Sep 2006
Location: China
Old 04-23-2007 , 01:47   Re: getting weapons
Reply With Quote #7

For this case, My juvenile idea of checking user has especial weapon:
PHP Code:
stock bool:bHasWeapon(iUserIDiWeaponID)
{
    if ( 
is_user_alive(iUserID) && pev(iUserIDpev_weapons) & (1<<iWeaponID) )
        return 
true
    
return false

"iWeaponID" is "CSW_*"
Ryu2877 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 13:13.


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