I'm trying to keep variables for various users, for example, the number of times they post. To keep a new variable for each $nick I write:
/set % $+ $nick $+ Counter 0
Which creates the variable %baseuserCounter with the value 0.
But when I try to call this up:
/describe $chan % $+ $nick $+ Counter
The output just says:
%baseuserCounter
Instead of its value, 0.
Any help?
on *:Text:*:#channel: {
inc %BaseCounter. [ $+ [ $nick ] ]
}
Thank you but that was just an example; what I'm actually doing is trying to keep a huge number of variables for each user, about 60, so instead of assigning each user who enters a number and then corresponding the individual variable to the number like:
on *:TEXT:newgame*:#chan: {
if ($nick = %user1) {
set %user1HP 10
set %user1Def 1
}
if ($nick = %user2) {
etc...
}
}
instead I want to write it:
on *:TEXT:newgame*:#chan: {
set % $+ $nick $+ HP 10
set % $+ $nick $+ Def 1
}
But this doesn't work. I need to be able to write a script where each time it calls the script up the VARIABLE that it's checking changes based on the $nick of the user who typed it.
Sorry for not being more clear.
Mmmm why don't you use /writeini for that kind of script where you can have..
$readini(game.ini,HP,$nick)
$readini(game.ini,Def,$nick)
$read(game.ini,Att,$nick)
[HP]
User1=Bob
[Def]
Bob=50
[Att]
Bob=20
etc..
Just a suggestion mate.
To retrieve the value, use
% [ $+ [ $nick ] $+ Counter ]
or
$eval($+(%,$nick,Counter),2)
or
$($+(%,$nick,Counter),2)
Your /set's are fine.
Thank you qwerty; everything works perfectly now.