mIRC Home    About    Download    Register    News    Help

Print Thread
#201440 28/06/08 01:20 PM
Joined: May 2008
Posts: 8
U
Unl Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
U
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?

Unl #201442 28/06/08 01:46 PM
Joined: May 2008
Posts: 329
A
Fjord artisan
Offline
Fjord artisan
A
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.
Unl #201443 28/06/08 02:08 PM
Joined: May 2008
Posts: 8
U
Unl Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
U
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 wink

Unl #201444 28/06/08 03:21 PM
Joined: May 2008
Posts: 329
A
Fjord artisan
Offline
Fjord artisan
A
Joined: May 2008
Posts: 329
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.


I registered; you should too.
Unl #201445 28/06/08 03:52 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
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


RusselB #201446 28/06/08 03:57 PM
Joined: May 2008
Posts: 8
U
Unl Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
U
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.
Unl #201447 28/06/08 03:57 PM
Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
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

RusselB #201462 28/06/08 11:03 PM
Joined: May 2008
Posts: 329
A
Fjord artisan
Offline
Fjord artisan
A
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.

Link Copied to Clipboard