mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2005
Posts: 35
C
Crap Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Oct 2005
Posts: 35
ok what I want to do is to give the characters in my RPG session points. the points should be saved in a .ini file:
Code:
[XP]
PC1=10
PC2=12

ok, this is what I've come up with:
Code:
on *:text:!XP:#: {
  var %alreadyxp $readini(Stats.ini, XP, $2)
  set %XP = %alreadyxp + $3
  writeini Stats.ini XP $3 %XP
}

is it something with the $2 -identifier? I have tried to add a $+ -identifier. is it the $readini?

Help!


#indierpgs @ magicstar.net Your indie-rpg fix. Online.
Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Code:
on *:text:!XP [color:red]*[/color]:#: {
  var %alreadyxp [color:red]=[/color] $readini(Stats.ini, XP, $2)
  set %XP [color:red]$calc([/color]%alreadyxp + $3[color:red])[/color]
  writeini Stats.ini XP $3 %XP
}


I assume you're trying to add 3 with the %XP var so you need to use $calc. If not, then just change that part back.

Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Code:
on *:text:!XP [color:red]* *[/color]:#: {
  var %alreadyxp [color:red]=[/color] $readini(Stats.ini, XP, $2)
  [color:red]var %XP =[/color] %alreadyxp + $3
  writeini Stats.ini XP $2 %XP
}


This should work.

Joined: Oct 2005
Posts: 35
C
Crap Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Oct 2005
Posts: 35
Man!! Thanx!!! it works!

I've been working on that in like 3 weeks! thanx! [censored]... I've thought of the $calc(), but it didnt work when i tried the last time smile

Yes!!!


#indierpgs @ magicstar.net Your indie-rpg fix. Online.
Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
If I'm not mistake, the writeini on schafers will not work properly.

!XP NPC1 5
$1 == !XP
$2 == NPC1
$3 == 5

writeini Stats.ini XP $3 %XP

This will do: /writeini Stats.ini XP 5 %XP

You need to use $2.

Also, because you're using !XP *, as the match text, you're only checking to see if there is "one or more" matches. That means !XP anything, will trigger the event. When you need $3 to work. Hence the code I used.

Last edited by Rand; 22/11/05 10:58 AM.
Joined: Aug 2005
Posts: 525
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
He did no error checking in the original script so I left it as simple as possible without changing the code too much. If we really want to get technical then it should also be checking that $3 is a numerical value :tongue:

Joined: Feb 2005
Posts: 342
R
Fjord artisan
Offline
Fjord artisan
R
Joined: Feb 2005
Posts: 342
Fine frown Technical it is.

Code:
on $*:text:/^!XP ([^\s]+) ([0-9]{1,})$/Si:#: {
  var %a = $regml(1) , %b = $regml(2) , %stats = $calc( $readini(Stats.ini,XP,%a) + %b )
  writeini Stats.ini XP %a %stats
  msg # Total stats for %a $+ : %stats
}


That's about as secure as I can make it. grin Though I'm sure someone like FiberOPtics could make it a little better.

This will remove control codes, and will be case insensitive. But will only trigger if you type: !XP <whatever> <numbers_here>

Joined: Feb 2004
Posts: 2,019
Hoopy frood
Offline
Hoopy frood
Joined: Feb 2004
Posts: 2,019
It's secure enough, all I would do is clean up the regex a bit to: /^!XP (\S+) (\d+)$/S

Code:
on $*:text:/^!XP (\S+) (\d+)$/S:#:{
  var %a = $regml(1), %stats = $readini(Stats.ini,XP,%a) + $regml(2)  
  writeini Stats.ini XP %a %stats  
  msg # Total stats for %a $+ : %stats
}


To the original requester: You should set some access flags, so that not everyone can use this command. In its current state, anyone can type !xp <player> <points> and it will update them.


Gone.
Joined: Oct 2005
Posts: 35
C
Crap Offline OP
Ameglian cow
OP Offline
Ameglian cow
C
Joined: Oct 2005
Posts: 35
ergh... ok... I dont think I need it, but thanks anymay smile
well... I will use it in further script-studies laugh


#indierpgs @ magicstar.net Your indie-rpg fix. Online.

Link Copied to Clipboard