AlliedModders

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

Unidentified 12-24-2005 20:56

Money system
 
How would you code a money system? In a way, such as If when you kill someone, you will recieve a dollar or something. Also, using that to buy specials, such as low gravity for example.

Peli 12-24-2005 21:36

Use the deathmsg event and give the killer set the killers money to the killers money + 1 dollar.

Later on... make a menu with the reward options, and check if the player has enough money for each reward.

Unidentified 12-24-2005 23:01

Quote:

Originally Posted by Peli
Use the deathmsg event and give the killer set the killers money to the killers money + 1 dollar.

Later on... make a menu with the reward options, and check if the player has enough money for each reward.

My thoughts precisely. But I am wondering how.

teame06 12-24-2005 23:28

Quote:

cs_get_user_money
cs_set_user_money
register_event use the DeathMsg event.
to start you off you use those functions

Unidentified 12-25-2005 00:13

It Isn't going to be for Counter-Strike.

Peli 12-25-2005 01:50

Well I don't see any other money functions... so what you could also do is make it up.

Code:
new money = x // what you want it set at
Code:
// on menus... case 0: {    // code...    money-- // decrement }

Correct me if I'm thinking of an invalid way.

VEN 12-25-2005 11:41

You need an array: new money[maxplayers] or new money[maxplayers + 1]

Unidentified 12-25-2005 11:48

Um, I'm still kinda lost. :shock:

Peli 12-25-2005 16:27

Quote:

Originally Posted by VEN
You need an array: new money[maxplayers] or new money[maxplayers + 1]

Yea that's what I was thinking, you could also do...
Code:
// global new Money[33]

Quote:

Originally Posted by Unidentified
Um, I'm still kinda lost. :Shocked:

We mean you can do it in many ways, but your easiest option is...

1. Make a deathmsg event to catch whenever the killer (read_data(1)) kills the victim (read_data(2)) and give him a money reward, like this:
Code:
money[id]+5

2. Then you can make a menu that is accessed by a client command registered in your public plugin_init(), the easist way to make a menu, I'd say is, follow this: XeroBlood's Menu Tutorial

And in your menu code for the cases, (using case 0 (the first one as an example)) you can do the code like this:
Code:
case 0: {    // code for that option, example giving hp: set_user_health()    money[id]-5    // take away 5 dollars after the use... }

Unidentified 12-26-2005 23:19

Ahh. That helps. But how would I detect If a player killed a player? Also a way to tell the player how much money they have. Also, I'm not familiar with deathmsg.


All times are GMT -4. The time now is 16:12.

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