Raised This Month: $ Target: $400
 0% 

Money Check


Post New Thread Closed Thread   
 
Thread Tools Display Modes
Author Message
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-23-2006 , 00:11   Money Check
#1

How would you make a plugin check the see how much money a player has and if the player doesn't have enough money...

I want them to purchase something for 10,000

If you have 800 it sets it to 9200 and it buys it...

RAWR
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-23-2006 , 00:45  
#2

Code:
new money = cs_get_user_money(id); new cost = 10000; if(money - cost <= 0) {   // they don't have enough   return PLUGIN_HANDLED; } cs_set_user_money(id , money - cost , 1);
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-23-2006 , 00:46  
#3

Exactly, Thanks v3x
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-23-2006 , 00:56  
#4

Ahhh, I get 2 errors

"id" is undefined and it was a constant exprssions; assumed zero...
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-23-2006 , 01:08  
#5

Umm - show me the function that you used it in. That would help.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-23-2006 , 01:20  
#6

Code:
#pragma tabsize 0 ///////////////////////////// //AMXMOD[X]                // //Purchase Mod v0.1        // //By: Dizzy                // //(©)All rights reserved   // //                         // //Cvars:                   // //  amx_pmod (0|1) (off|on)// //                         // //Client Commands:         // //  pmodhelp               // //  buygravity             // //  buyspeed               // //                         // //Description:             // //                         // //You can buy powers using // //the above commands.      // ///////////////////////////// #include <amxmodx> #include <cstrike> #include <engine> #include <fun> new powerpur[33] new money = cs_get_user_money(id); new cost = 10000; public plugin_init() {     register_plugin("Purchase Mod","0.1","Dizzy")     register_cvar("amx_pmod","1")     register_clcmd("say pmodhelp","help")     register_clcmd("say buygravity","grav")     register_clcmd("say buyspeed","speed")     register_event("ResetHUD","roundchange","b") } //--------------------------------------------- //HELP //--------------------------------------------- public help(id) {     if(get_cvar_num("amx_pmod")== 0)     {         client_print(0, print_chat, "[Purchase Mod]: The plugin is off!")         return PLUGIN_HANDLED     }     client_print(0, print_chat, "[Purchase Mod]: Type either buygravity or buyspeed to buy them for $10,000!")     return PLUGIN_HANDLED } //--------------------------------------------- //GRAVITY //--------------------------------------------- public grav(id) {     if(get_cvar_num("amx_pmod")== 0 || powerpur[id] == 0 || money - cost <= 0)     {         client_print(0, print_chat, "[Purchase Mod]: You already purchased an ability, don't have enough money, or the plugin is off!")         return PLUGIN_HANDLED     }     else if(get_cvar_num("amx_pmod")== 1 || powerpur[id] == 1)     {     set_user_gravity(id, 0.25)     powerpur[id] = 0     cs_set_user_money(id , money - cost , 1);     } return PLUGIN_HANDLED } //--------------------------------------------- //SPEED //--------------------------------------------- public speed(id) {     if(get_cvar_num("amx_pmod")== 0 || powerpur[id] == 0 || money - cost <= 0)     {         client_print(0, print_chat, "[Purchase Mod]: You already purchased an ability, don't have enough money, or the plugin is off!")         return PLUGIN_HANDLED     }     else if(get_cvar_num("amx_pmod")== 1 || powerpur[id] == 1)     {     set_user_maxspeed(id, -2.0)     powerpur[id] = 0     cs_set_user_money(id , money - cost , 1);     } return PLUGIN_HANDLED } //--------------------------------------------- //ROUND CHANGE //--------------------------------------------- public roundchange(id) {     powerpur[id] = 1     set_user_gravity(0, 1.0)     set_user_maxspeed(id, -1.0)     return PLUGIN_HANDLED } //---------------------------------------------
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-23-2006 , 01:32  
#7

You cannot use functions globally. They must be inside of a function like so:
Code:
public grav(id) {     new money = cs_get_user_money(id);     new cost = 10000;     if(get_cvar_num("amx_pmod") == 0)     {         client_print(id, print_chat, "[Purchase Mod]: The plugin is off!")         return PLUGIN_HANDLED     }     if(powerpur[id] == 0)     {         client_print(id, print_chat, "[Purchase Mod]: You already purchased an ability!")         return PLUGIN_HANDLED     }     if(money - cost <= 0)     {         client_print(id, print_chat, "[Purchase Mod]: You don't have enough money!")         return PLUGIN_HANDLED     }     set_user_gravity(id, 0.25)     powerpur[id] = 0     cs_set_user_money(id , money - cost , 1);     return PLUGIN_HANDLED }
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Dizzy
Veteran Member
Join Date: Jun 2004
Location: Massachusetts
Old 02-23-2006 , 02:11  
#8

I see, thanks very much...
__________________
My Plugins

Purchase Mod - Stable
Type Sounds - Stable
Monster Spawner - Stable
Nade Giver - Maintenance
Dizzy is offline
Send a message via AIM to Dizzy
v3x
Veteran Member
Join Date: Oct 2004
Location: US
Old 02-23-2006 , 05:58  
#9

One more thing, don't use the whole "#pragma tabsize 0" thing, just learn how to indent properly. It's not that hard, really.
__________________
What am I doing these days? Well, I run my own Rust server. It's heavily modded. If you'd like to join, the ip is 167.114.101.67:28116

I also created a website called Rust Tools. It will calculate and tell you the raw amounts of resources needed to craft items.
v3x is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-23-2006 , 07:28  
#10

your problem is you dont have the return PLUGIN_HANDLED indented.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Closed Thread



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:27.


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