AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Money Check (https://forums.alliedmods.net/showthread.php?t=24439)

Dizzy 02-23-2006 00:11

Money Check
 
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 :(

v3x 02-23-2006 00:45

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);

Dizzy 02-23-2006 00:46

Exactly, Thanks v3x :)

Dizzy 02-23-2006 00:56

Ahhh, I get 2 errors

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

v3x 02-23-2006 01:08

Umm - show me the function that you used it in. That would help.

Dizzy 02-23-2006 01:20

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 } //---------------------------------------------

v3x 02-23-2006 01:32

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 }

Dizzy 02-23-2006 02:11

I see, thanks very much...

v3x 02-23-2006 05:58

One more thing, don't use the whole "#pragma tabsize 0" thing, just learn how to indent properly. It's not that hard, really.

Xanimos 02-23-2006 07:28

your problem is you dont have the return PLUGIN_HANDLED indented.


All times are GMT -4. The time now is 20:27.

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