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

[CSGO] How to reset a player's cash immediately after he bought something?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-25-2017 , 18:18   [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #1

Hello everyone,

As the title already says I'm looking for a solution for keeping a player's money always at the maximum amount possible so that he could buy an unlimited amount of things.
Does anybody have a solution for that?

Thank you very much,
KarlmitC
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 03-25-2017 , 18:28   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #2

Maybe you can sdkhook post weapon equip and then check if it's still in buy time / player is in buy zone. If so, add some money.
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
Bulletford
Junior Member
Join Date: Apr 2015
Old 03-25-2017 , 19:50   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #3

Code:
#include <sourcemod>
#include <cstrike>

public Action:CS_OnBuyCommand(int client, const char[] weapon)
{
   SetEntProp(client, Prop_Send, "m_iAccount", 16000);
}
Haven't tested this, you may need to delay it with a timer.

Last edited by Bulletford; 03-25-2017 at 19:52.
Bulletford is offline
KissLick
Veteran Member
Join Date: Nov 2012
Location: void
Old 03-26-2017 , 07:17   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #4

Quote:
Originally Posted by Bulletford View Post
Code:
#include <sourcemod>
#include <cstrike>

public Action:CS_OnBuyCommand(int client, const char[] weapon)
{
   SetEntProp(client, Prop_Send, "m_iAccount", 16000);
}
+1 (but this might wrongly give money if the player tries to buy some restricted weapon - like awp on many servers)
Quote:
Originally Posted by Bulletford View Post
you may need to delay it with a timer.
Better to use FrameRequest
__________________
Plugins: TeamGames
Includes: Menu stocks, ColorVariables, DownloadTableConfig

> No help through PM, make a topic.
KissLick is offline
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-26-2017 , 08:54   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #5

Quote:
Originally Posted by KissLick View Post
+1 (but this might wrongly give money if the player tries to buy some restricted weapon - like awp on many servers)

Better to use FrameRequest
Thanks, but since I only want to run this during warmup that shouldn't be the problem.
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-26-2017 , 09:00   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #6

Code:
#include <sourcemod>
#include <cstrike>

public Action:CS_OnBuyCommand(int client, const char[] weapon)
{
   RequestFrame(SetEntProp(client, Prop_Send, "m_iAccount", 16000));
}
Would that work or do I have to hook the buy event and then trigger that a seperate function?
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 03-26-2017 , 14:24   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #7

For what it's worth, I found it better to simply change the price of all the purchases to $0.
PHP Code:
#include <cstrike> 

public Action CS_OnGetWeaponPrice(int client, const char[] weaponint &price)

    
price 0
    return 
Plugin_Changed

This way you can disable money being shown on the HUD to clear up some space.
Code:
mp_afterroundmoney "0"
mp_playercashawards "0"
mp_teamcashawards "0"
Maxximou5 is offline
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-26-2017 , 15:45   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #8

Quote:
Originally Posted by Maxximou5 View Post
For what it's worth, I found it better to simply change the price of all the purchases to $0.
PHP Code:
#include <cstrike> 

public Action CS_OnGetWeaponPrice(int client, const char[] weaponint &price)

    
price 0
    return 
Plugin_Changed

This way you can disable money being shown on the HUD to clear up some space.
Code:
mp_afterroundmoney "0"
mp_playercashawards "0"
mp_teamcashawards "0"
Just that confirm that I got this right, that code basically sets all weapon prices to 0 and that combination of cvars hides all the money references in the hud?
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery
carlS is offline
Maxximou5
AlliedModders Donor
Join Date: Feb 2013
Old 03-26-2017 , 16:03   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #9

Exactly as such, and doesn't display money in chat because there's nothing to reward players over.
It's my typical setup for trade servers, buy all the weapons you want at the price you want and no useless HUD.
Maxximou5 is offline
carlS
AlliedModders Donor
Join Date: Dec 2015
Location: Germany
Old 03-26-2017 , 18:13   Re: [CSGO] How to reset a player's cash immediately after he bought something?
Reply With Quote #10

Since I'm totally new to sourcemod scripting and such would that work:

Code:
#pragma semicolon 1

#include <sourcemod>
#include <cstrike>  

ConVar g_cEnablePlugin = null;

public Plugin:myinfo = 
{
	name        = "FreeWeapons",
	author      = "KarlmitC",
	description = "Sets all weapon prices to 0",
	version     = "1.0",
	url         = "https://respawn-gaming.com"
};

public OnPluginStart()
{
    g_cEnablePlugin = CreateConVar("freeweapons_enable", "1", "Enable / Disalbe FreeWeapons Plugin", _, true, 0.0, true, 1.0);
}

public Action CS_OnGetWeaponPrice(int client, const char[] weapon, int &price) 
{  
	if (g_cEnablePlugin.BoolValue) {
   		price = 0;  
	}
    return Plugin_Changed;  
}
__________________
Respawn-Gaming: respawn-gaming.com

"Only the unknown frightens men. But once a man has faced the unknown, that terror becomes the known."
- Antoine de Saint-Exupery

Last edited by carlS; 03-26-2017 at 18:28.
carlS 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 03:02.


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