mIRC Homepage
Posted By: Unl Variable? - 28/06/08 01:20 PM
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?
Posted By: AWEstun Re: Variable? - 28/06/08 01:46 PM
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)
Posted By: Unl Re: Variable? - 28/06/08 02:08 PM
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 wink
Posted By: AWEstun Re: Variable? - 28/06/08 03:21 PM
Originally Posted By: Unl
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 wink


I replied to your E-mail about how to incorporate a hash table into your script.
Posted By: RusselB Re: Variable? - 28/06/08 03:52 PM
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

Posted By: Unl Re: Variable? - 28/06/08 03:57 PM
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
Posted By: RusselB Re: Variable? - 28/06/08 03:57 PM
Use a dynamic variable like
Code:
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
Posted By: AWEstun Re: Variable? - 28/06/08 11:03 PM
Unl, the $+ turns $+(%,hpp1,.,<nick>) into a custom variable.

See my E-mail to you.
© mIRC Discussion Forums