|
Joined: May 2008
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: May 2008
Posts: 8 |
I'm using a combat game: Everyone gets 99 hp en with attacks, u can lower your opponent's hp. However, i would like to add something. If u win, u get +1 HP the next time. I think it must be possible with variables (I put the start HP with variables), but how can you make a variable for every person? I mean, if u use something like: inc %variable and then %variable $+ it's for everyone. But only for 1 person, on IP or something. Can someone help?
|
|
|
|
Joined: May 2008
Posts: 329
Fjord artisan
|
Fjord artisan
Joined: May 2008
Posts: 329 |
It's hard to understand what you are asking due the chopiiness of how you are asking it.
If I understand you right, you want to save a variable for everyone, so that if they won a previous game they get an extra HP (whatever that is). I'd use a hash table.
Create a small hash table. For each item (username) you can set data values (total won, total lost, high win, extra points, etc.) You'd read it back in at the start of the next game and adjust it accordingly.
Basic hash table commands are:
hmake game 100 hload game game.hsh hadd game username data1 data2 data3 hdel game user hsave game game.hsh hfree game
$hget(game,username)
I registered; you should too.
|
|
|
|
Joined: May 2008
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: May 2008
Posts: 8 |
Ok, i'll specify a bit more. At the begin of the script: set %hpp1 = 99 But, if the player wins, i want to add 1 to the %hpp1 The only problem is, if i do this, everyone gets the +1 on %hpp1 Now I'm wondering if it's possible to add a nick/ip-adress to the variable 
|
|
|
|
Joined: May 2008
Posts: 329
Fjord artisan
|
Fjord artisan
Joined: May 2008
Posts: 329 |
Ok, i'll specify a bit more. At the begin of the script: set %hpp1 = 99 But, if the player wins, i want to add 1 to the %hpp1 The only problem is, if i do this, everyone gets the +1 on %hpp1 Now I'm wondering if it's possible to add a nick/ip-adress to the variable I replied to your E-mail about how to incorporate a hash table into your script.
I registered; you should too.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
As was mentioned, hash tables are a good way to handle this, however, if you want to use variables, then you need to work with dynamic variables.
A lot more information (such as how the person is notified if they win, how they go about lowering an opponents hp, how you're going to determine a person's IP, what happens if the number of hp gets to a certain level, if the information needs to be stored even if the bot is offline, and probably others) would be needed before any kind of code could be decently written
|
|
|
|
Joined: May 2008
Posts: 8
Nutrimatic drinks dispenser
|
OP
Nutrimatic drinks dispenser
Joined: May 2008
Posts: 8 |
Hm, can you post then how to do this? Or a site where i can find those information?
//edit: you posted it, thx, i try it //edit2: AWEstun, for my answer: see PM
Last edited by Unl; 28/06/08 03:58 PM.
|
|
|
|
Joined: Aug 2004
Posts: 7,252
Hoopy frood
|
Hoopy frood
Joined: Aug 2004
Posts: 7,252 |
Use a dynamic variable like set $+(%,hpp1,.,<nick>) 99 And to increase it, use inc $+(%,hpp1,.,<nick>) To decrease, use dec $+(%,hpp1,.,<nick>) Replace <nick> in each of the above examples with the variable or identifier that is being used and contains the person's nick. You could also replace it with a variable that contains the person's IP address, however, obtaining that address can be more difficult
|
|
|
|
Joined: May 2008
Posts: 329
Fjord artisan
|
Fjord artisan
Joined: May 2008
Posts: 329 |
Unl, the $+ turns $+(%,hpp1,.,<nick>) into a custom variable.
See my E-mail to you.
I registered; you should too.
|
|
|
|
|