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

get what each player bought...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
hoboman
Senior Member
Join Date: Jul 2007
Old 02-20-2008 , 22:04   get what each player bought...
Reply With Quote #1

I am trying to make a plugin that will count the number of nades a player has bought then prevent him from buying additional nades.

1.) is there some forward function that has been illuding me that will let me count how many weapons/nades a player has bought?

2.) is there some way that I could remove a single weapon from a player and not all of them?

3.) any other suggestions/ideas on how I could do this?

( oh and I know I can count nades thrown with grenade_throw forward but I wanna prevent ppl from buying additional nades )
__________________
hoboman is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 02-20-2008 , 22:38   Re: get what each player bought...
Reply With Quote #2

1 - http://forums.alliedmods.net/showpos...29&postcount=3
2 - http://forums.alliedmods.net/showthread.php?t=56377
__________________
Arkshine is offline
hoboman
Senior Member
Join Date: Jul 2007
Old 02-20-2008 , 22:41   Re: get what each player bought...
Reply With Quote #3

oooh....well that's embarrassing...it was on here all along

thx bud
__________________
hoboman is offline
Old 02-21-2008, 18:05
hoboman
This message has been deleted by hoboman. Reason: hax
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 02-23-2008 , 09:12   Re: get what each player bought...
Reply With Quote #4

Change
new oldNades[33][1], grenBought[33][1]
to
new oldNades[33], grenBought[33]

and all :
oldNades[id][0]
grenBought[id][0]
with
oldNades[id]
grenBought[id]


I've just written an anti grenade spam, i'll test it and may be i will release it.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Argus
Junior Member
Join Date: Oct 2007
Location: Russia
Old 02-23-2008 , 11:50   Re: get what each player bought...
Reply With Quote #5

Quote:
Originally Posted by hoboman View Post
this plugin completely doesn't work, as I get slapped everytime I buy a single nade and I cannot see what I did wrong
I fix this problem. try this:

Code:
/*http://forums.alliedmods.net/showthread.php?t=67320*/

#include <amxmodx>
#include <cstrike>

// Plugin Info
new const PLUGIN[]  = "No Extra Nades"
new const VERSION[] = "0.1"
new const AUTHOR[]  = "forums.alliedmods.net"

new oldNades[33], grenBought[33]

public plugin_init()
{
  register_plugin(PLUGIN, VERSION, AUTHOR)
  register_event("HLTV", "event_new_round", "a", "1=0", "2=0");
  register_event("Money", "event_money", "be")
  register_cvar("amx_themax","1")   
  register_cvar("amx_cthemax","1")   
    
  return PLUGIN_CONTINUE 
}

public event_new_round()
{
    new players[32], numPlayerCount, idxPlayer
    get_players(players, numPlayerCount)

    //reset the nades bought for all players to 0
    for(idxPlayer = 0; idxPlayer < numPlayerCount; idxPlayer++)
    {
        grenBought[players[idxPlayer]] = 0
    } 

    return PLUGIN_CONTINUE
}

public client_command(id)
{
    static arg[13]
    read_argv( 0, arg , 12 )
    
    if ( equal("buy", arg) || equal("autobuy", arg) || equal("rebuy", arg) ) 
    {
        oldNades[id]=cs_get_user_bpammo(id, CSW_HEGRENADE) //get current nades before player buys something
    }
    
    return PLUGIN_CONTINUE
}

public event_money(id) 
{
    new team=cs_get_user_team(id)
    new newNade=grenBought[id]
    new moneyback
    new ct_HECount_, t_HECount_
    
    //difference of nades before money event and after the money event
    grenBought[id] += ( cs_get_user_bpammo(id, CSW_HEGRENADE) - oldNades[id] )
    oldNades[id] = 0
    newNade = grenBought[id] - newNade
    t_HECount_ = get_cvar_num("amx_themax")    
    ct_HECount_ = get_cvar_num("amx_cthemax")
    
    //if a T players has bought more than x nades...
    if( ( grenBought[id] > t_HECount_ ) && team==1 && newNade>0)
    {
        //user_slap( id, 10) // bad boy!
        client_print( id ,print_chat, "You are only allowed %d HE Nades per round.", t_HECount_ )
        cs_set_user_bpammo ( id, 4, 0 )
        client_cmd(id, "lastinv")
        
        moneyback=cs_get_user_money(id)+300
        cs_set_user_money(id, moneyback) // get my money back!
    }
    
    //if a CT players has bought more than x nades...
    if( ( grenBought[id] > ct_HECount_)  && team==2 && newNade>0 )
    {
        //user_slap( id, 10) // bad boy!
        client_print( id ,print_chat, "You are only allowed %d HE Nades per round.", ct_HECount_ )
        cs_set_user_bpammo ( id, 4, 0 )
        client_cmd(id, "lastinv")
    
        moneyback=cs_get_user_money(id)+300 
        cs_set_user_money(id, moneyback)    // get my money back!
    }
    
    newNade=0
    
    return PLUGIN_CONTINUE
}
Argus 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 02:37.


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