Raised This Month: $ Target: $400
 0% 

Money Spent


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-31-2017 , 20:01   Money Spent
Reply With Quote #1

Dudes, I'm trying to pick the money spent from a player.
Thats the code:

PHP Code:
new MoneySpent[33]

public 
plugin_init()
{
    
register_message(get_user_msgid("Money"), "Message_Money")
}
public 
Message_Money(iMsgIdiMsgDestid)
{
    new 
iMsgArgInt get_msg_arg_int(1)
    new 
PlayerMoneySpent = (DefaultMoneyStart iMsgArgInt)
    
    
MoneySpent[id] = PlayerMoneySpent
    
    
new userName[32]
    
get_user_name(iduserName31)
    
console_print(0,"Player Spenting: %s, Money Spent: %d",userNamePlayerMoneySpent)

But it returns the money adding up the equipment you own, not the money spent at the beginning of the round.

Output in the first round:

Code:
Player spenting: EFFx, Money spent: 7975 ( AWP+FULL AMMO, DEAGLE+FULL AMMO, VESTHELM AND ALL GRENADES
But when the round ends and start again, appear 7675 in the console, because I threw a HE Grenade. And if I don't threw any grenade and buy an AK in the round, it shows 14075.

What I want know is any other method to return the money spent at the beginning of the round.


And ahh, i'm reseting it with Ham_Spawn and it doesn't fix the issue.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 01-31-2017 at 20:12.
EFFx is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-31-2017 , 21:44   Re: Money Spent
Reply With Quote #2

Done -

PHP Code:
#include <amxmodx>
#include <cl_buy>

#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"

enum WeaponsSettings
{
    
WeaponIndex,
    
WeaponPrice
}
new const 
WeaponsIndex[][WeaponsSettings] =
{
    {
1600},
    {
22200},
    {
3275},
    {
4300},
    {
53000},
    {
60},
    {
71400},
    {
83500},
    {
9300},
    {
10800},
    {
11750},
    {
121700},
    {
134200},
    {
142000},
    {
152250},
    {
16500},
    {
17400},
    {
184750},
    {
191500},
    {
205750},
    {
211700},
    {
223100},
    {
231250},
    {
24500},
    {
25200},
    {
26650},
    {
273500},
    {
282500},
    {
290},
    {
302350},
    {
31650},
    {
321000}
}

new 
MoneySpent[33]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
register_logevent("Round_Start",2"1=Round_Start")
}

public 
Round_Start()
{
    for(new 
1;get_maxplayers();i++)
        
MoneySpent[i] = 0
}
public 
client_buy(idiItem)
{
    if(
isUnavaliableItem(iItem))
    {
        
console_print(id"%d"iItem)
        
        if(!
user_has_weapon(idiItem))
        {
            
MoneySpent[id] += WeaponsIndex[iItem 1][WeaponPrice]
        }
        
console_print(id,"Money Spent: %d"MoneySpent[id])
    }
}
isUnavaliableItem(const iItem)
{
    return (
iItem 32) ? false true

__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
yas17sin
Veteran Member
Join Date: Oct 2016
Location: Morocco/Sale
Old 01-31-2017 , 22:11   Re: Money Spent
Reply With Quote #3

i didn't understand the propose of this plugin you made. :/
yas17sin is offline
Send a message via ICQ to yas17sin
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 01-31-2017 , 22:19   Re: Money Spent
Reply With Quote #4

Show how much money a player has spent.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-31-2017 , 22:41   Re: Money Spent
Reply With Quote #5

There is no weapon index 2 and you can accomplish this using a single dimension array by putting in a placeholder. This makes the weapon index the index of the weapon price.
PHP Code:
new const WeaponsIndex[][WeaponsSettings] =
{
    {
1600},
    {
22200},
    {
3275},
    {
4300},
    {
53000},
    {
60},
    {
71400},
    {
83500},
    {
9300},
    {
10800},
    {
11750},
    {
121700}
}

//to

new const WeaponPrices[] =
{
    
0,
    
600,
    
0,
    
275,
    
300,
    
3000,
    
0,
    
1400,
    
3500,
    
300,
    
800,
    
750,
    
1700

__________________

Last edited by Bugsy; 01-31-2017 at 22:42.
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-01-2017 , 00:00   Re: Money Spent
Reply With Quote #6

Should be like this:

PHP Code:
new const WeaponsPrices[] =
{
    
0,
    
600,
    
275,
    
300,
    
3000,
    
0,
    
1400,
    
3500,
    
300,
    
800,
    
750,
    
1700,
    
4200,
    
2000,
    
2250,
    
500,
    
400,
    
4750,
    
1500,
    
5750,
    
1700,
    
3100,
    
1250,
    
500,
    
20,
    
650,
    
3500,
    
2500,
    
0,
    
2350,
    
650,
    
1000

And

PHP Code:
MoneySpent[id] += WeaponsIndex[iItem 1
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 02-01-2017 at 00:16.
EFFx is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-01-2017 , 05:54   Re: Money Spent
Reply With Quote #7

No, you should not do '-1'. What I gave you will directly take the CSW_ weapon index.

Example using P228, weapon index 1, which is $600.

With what I told you:
PHP Code:
new const WeaponPrices[] =
{
    
0,
    
600,  <- Array index 1 Access with WeaponPricesCSW_P228 
What you claim (which is wrong):
PHP Code:
new const WeaponPrices[] =
{
    
0,     <- Array index 0 Access with WeaponPricesCSW_P228 ]
    
600
What I gave you is the purpose of padding the array with a 0 in slot 0 so you do not need to use '-1' every time you want the price. Your statement would be valid with an array not padded with 0 in index 0:
PHP Code:
new const WeaponsPrices[] =
{
    
600,  <- Array index 0 Access with WeaponPricesCSW_P228 ]
    
275
__________________

Last edited by Bugsy; 02-01-2017 at 06:00.
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-01-2017 , 15:41   Re: Money Spent
Reply With Quote #8

Yea, its showing a debug with index out of bounds. It works only with -1.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo

Last edited by EFFx; 02-01-2017 at 15:45.
EFFx is offline
Old 02-01-2017, 15:44
EFFx
This message has been deleted by EFFx. Reason: nvm
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-01-2017 , 16:49   Re: Money Spent
Reply With Quote #9

I'm assuming you're using the full sized array and not just the sample I posted.

If you are, which weapon throws that error?
__________________

Last edited by Bugsy; 02-01-2017 at 16:51.
Bugsy is offline
EFFx
Veteran Member
Join Date: Feb 2016
Location: São Paulo, Brasil
Old 02-01-2017 , 16:54   Re: Money Spent
Reply With Quote #10

I was picking all the weapons's price, not only until the ump45.
Vesthelm 1 and 2. All others weapon's index more than the ump45.
__________________
• Ranking System • AutoMix 5vs5 System
• Web Ban System • Plugins for free

____________________________________________
For private works:
• Discord: EFFEXo#8850 • Steam: EFFEXo
EFFx 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 20:41.


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