mIRC Home    About    Download    Register    News    Help

Print Thread
#251610 26/02/15 04:22 AM
Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
Hey, Yes I know there are tons of topics out there for this, but I tried making my own twitch point system and I am stuck on something, and I don't know the problem.

Here is my full code:
Click to reveal..
Code:
on *:JOIN:#: { 
  var %user = $nick
  var %val = $readini( rxcoin.ini, #michaelukz, %user, coins )
  writeini -n rxcoin.ini #michaelukz $nick coins calc(%val)
}

on *:TEXT:!balbusers *:#: { 
  var %user = $nick
  var %val = $readini( rxcoin.ini, #michaelukz, %user, coins )
  if ($nick isop #michaelukz) {
    if ($2 == null) {
      msg $chan /me >: Please supply a name to read.
    }
    msg $chan /me >: $2 has %val credits.
  }
}

on *:TEXT:!balance:#: { 
  var %user = $nick
  var %val = $readini( rxcoin.ini, #michaelukz, %user, coins )
  if (%val == $null) { 
    msg $chan /me >: You have no credits, $nick
  }
  msg $chan /me >: $nick has %val credits.
}

on *:TEXT:!givecreds *:#: { 
  var %user = $nick
  var %val = $readini( rxcoin.ini, #michaelukz, %user, coins )
  if ($nick isop #michaelukz) {
    if ($2 == $null) { 
      msg $chan /me >: Please enter a name to give credits too.
    }
    if ($3 == $null) { 
      msg $chan /me >: Please enter the number of credits to give.
    }
    msg $chan $2 has been given $3 credits
    set %money.add $calc( $readini( rxcoin.ini, #michaelukz, %user, coins ) + $3 )
    writeini -n rxcoin.ini #michaelukz %user coins %money.add
    unset %money.add
  }
}

on *:TEXT:!dcreds *:#: { 
  var %user = $nick
  var %val = $readini( rxcoin.ini, #michaelukz, %user, coins )
  if ($2 == $null) { 
    msg $chan /me >: Please insert a name to send credits too.
  }
  if ($3 == $null) { 
    msg $chan /me >: Please enter the number of credits  to give.
  }
  if (%val == $null) { 
    msg $chan /me >: You have no credits to give!
  }
  if (%val == 0) { 
    msg $chan /me >: You have no credits to give!
  }
  msg $chan /me >: $2 has been given $3 tokens by $nick
  set %money.add $calc( $readini( rxcoin.ini, #michaelukz, $2, coins ) + $3 )
  set %money.withdraw $calc( $readini( rxcoin.ini, #michaelukz, %user, coins) - $3 )
  writeini -n rxcoin.ini #michaelukz %user coins %money.withdraw
  writeini -n rxcoin.ini #michaelukz $2 coins %money.add
  unset %money.add
  unset %money.withdraw
}


I have a couple issues, I will try and screenshot all (If I remember as I have to go back and forth)

sidenote: I know my code is dodgy but it's my code if you are so kind as to supply helping code to fix it, don't fix anything else(I want it to be as much mine as possible if that makes sense)

> !balance issue
screen cap : http://gyazo.com/d8a8fd437e493bb8aa67110783063f7b

Issue 1: Despite it said to read the .ini file, it doesn't and skips out completely on the part "%val".

Issue 2: It says both you have no credits and what should be how many credits you have, I didn't think I would have to use an else statement for this as I just want it to test if you have none.

!Balbusers issue
Screen cap: http://gyazo.com/fb7381f002e6ffd06cc25d356a94751b

Issue 1: If you do not type anything other than !balbusers ie with no name, it will not say you haven't specified a name.

Issue 2: Same as with the !balance it skips the "%val" variable.

!givecreds issue:
Screen cap: http://gyazo.com/83fc4d957d23f9d8c638886d442c737f

Issue: Instead of adding on any points, It replaces your point amount.

!dcreds issue:
Screen cap: http://gyazo.com/89e3480f4e9eca44acd89c817c9b0867

Issue 1: It ignores if you have no credits and just makes it negative numbers though I wish it to stop at 0 and not let it go less than.

Issue 2: It gives the other person points even if you have none.


I know this is a tall order, But I am really stuck here, Any help even for just 1 segment would be appreciated.

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Why do you have %calc(%val)? Are you trying to add a point everytime they join? if you are do %calc(%val + 1). Otherwise, you have to differentiate whether a person has already been added.

Code:
if ($readini(rxcoin.ini,#michaelukz,%user,coins) != $null) { return }
else {
   writeini -n rxcoin.ini #michaelukz $nick coins 1
}



You're second problem is spaces on your readini. Trying this instead

Code:
$readini(rxcoin.ini,#michaelukz,%user,coins)

Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
Thanks for the quick response, However, It did not fix it unfortunately: http://gyazo.com/155127e9fbacdc157a02c5fc884a2716

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Hm... try removing the = between the variables

Code:

var %user $nick



Also, on the on *:JOIN: add a msg that states you're earning coins and how many you're earning.

Code:
on *:JOIN:#: {
  var %user $nick
  writeini -n rxcoin.ini #michaelukz $nick coins $calc($readini(rxcoin.ini,3michaelukz,%user,coins) + 1)
  var %var $readini(rxcoin.ini,3michaelukz,%user,coins)
  msg # You are now earning coins, you have %var coins
}


Oh, that's your problem, you forgot to include a $ before the calc.

Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
Still no, It's just skipping the "%val" statement

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Code:
on *:JOIN:#: {
  var %user $nick
  if ($readini(rxcoin.ini,3michaelukz,%user,coins) != $null) {
    writeini -n rxcoin.ini #michaelukz $nick coins $calc($readini(rxcoin.ini,3michaelukz,%user,coins) + 1)
    var %var $readini(rxcoin.ini,3michaelukz,%user,coins)
    msg # Welcome back %user, you have earned another coin and now have %var coins. 
  }
  else {
    writeini -n rxcoin.ini #michaelukz $nick coins 1
    var %coin $readini(rxcoin.ini,3michaelukz,%user,coins)
    msg # Hello! And welcome you now have %var coin!
  }
}


Sorry, forgot that it would the coins would just be nulled. Hopefully this will work, although make sure you turn off the bot and then activate it again. Otherwise it won't act as joining.

Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
I think somewhere I miss understood, I thought you meant second issue as in the !balance command, but as I have been reading it seems it's the join you are saying about, the !balance is the main issue, It just keeps saying > http://gyazo.com/40aad280c4a2f0efd392c96e7cb206de

Instead of one or the other.

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Check your ini file because I don't think its writing down anything on it. That's why you can't read the ini file because there is no information to read.

Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
It is, but it's skipping the if statement and just saying you have no coins and you do have coins but instead of saying "you have 2 coins" it says "you have coins"

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
That's why, because it returns a null, or 0. Pretty much the value doesn't exist which is why its skipping it. If you go through

Desktop -> PC name -> AppData -> Roaming -> mIRC

you should be able to find your rxcoin.ini file. Click on it and see if it has a value. It should look something like this.

#michaelukz
$nick=coins 1

Where if 1 is not present then the ini file has no value.

Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
It does, Here I will post file text (just 2 names)

[#michaelukz]
michaelukz=coins 1
ukzbot=coins 1

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Mind posting your code? If its updated of course.

Last edited by Newbie; 26/02/15 06:29 AM.
Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
It's only very slightly updated

Click to reveal..
Code:
on *:JOIN:#: {
  var %user $nick
  if ($readini(rxcoin.ini,#michaelukz,%user,coins) != $null) {
    writeini -n rxcoin.ini #michaelukz $nick coins $calc($readini(rxcoin.ini,#michaelukz,%user,coins) + 0)
    var %var $readini(rxcoin.ini,#michaelukz,%user,coins)
  }
  else {
    writeini -n rxcoin.ini #michaelukz $nick coins 1
    var %coin $readini(rxcoin.ini,#michaelukz,%user,coins)
  }
}

on *:TEXT:!balbusers *:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,#michaelukz,%user,coins)
  if ($nick isop #michaelukz) {
    if ($2 == null) {
      msg $chan /me >: Please supply a name to read.
    }
    msg $chan /me >: $2 has %val credits.
  }
}

on *:TEXT:!balance:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,#michaelukz,%user,coins)
  if (%val == $null) { 
    msg $chan /me >: You have no credits, $nick
  }
  msg $chan /me >: $nick has %val credits.
}

on *:TEXT:!givecreds *:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,#michaelukz,%user,coins)
  if ($nick isop #michaelukz) {
    if ($2 == $null) { 
      msg $chan /me >: Please enter a name to give credits too.
    }
    if ($3 == $null) { 
      msg $chan /me >: Please enter the number of credits to give.
    }
    msg $chan $2 has been given $3 credits
    set %money.add $calc( $readini(rxcoin.ini,#michaelukz,%user,coins) + $3 )
    writeini -n rxcoin.ini #michaelukz %user coins %money.add
    unset %money.add
  }
}

on *:TEXT:!dcreds *:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,#michaelukz,%user,coins)
  if ($2 == $null) { 
    msg $chan /me >: Please insert a name to send credits too.
  }
  if ($3 == $null) { 
    msg $chan /me >: Please enter the number of credits  to give.
  }
  if (%val == $null) { 
    msg $chan /me >: You have no credits to give!
  }
  if (%val == 0) { 
    msg $chan /me >: You have no credits to give!
  }
  msg $chan /me >: $2 has been given $3 tokens by $nick
  set %money.add $calc( $readini(rxcoin.ini,#michaelukz,$2,coins ) + $3 )
  set %money.withdraw $calc( $readini( rxcoin.ini,#michaelukz,%user,coins) - $3 )
  writeini -n rxcoin.ini #michaelukz %user coins %money.withdraw
  writeini -n rxcoin.ini #michaelukz $2 coins %money.add
  unset %money.add
  unset %money.withdraw
}

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
This worked for me

Code:
on *:JOIN:#: {
  var %user $nick
  if ($readini(rxcoin.ini,#michaelukz,%user,coins) != $null) {
    writeini -n rxcoin.ini %user coins $calc($readini(rxcoin.ini,%user,coins) + 1)
    var %var $readini(rxcoin.ini,%user,coins)
  }
  else {
    writeini -n rxcoin.ini %user coins 1
    var %coin $readini(rxcoin.ini,%user,coins)
  }
}

on *:TEXT:!balbusers *:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,%user,coins)
  if ($nick isop #michaelukz) {
    if ($2 == null) {
      msg $chan /me >: Please supply a name to read.
    }
    else {
      msg $chan /me >: $2 has %val credits.
    }
  }
}

on *:TEXT:!balance:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,%user,coins)
  if (%val == $null) {
    msg $chan /me >: You have no coins
  }
  else {
    msg $chan /me >: $nick has %val credits.
  }
}

on *:TEXT:!givecreds *:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,%user,coins)
  if ($nick isop #michaelukz) {
    if ($2 == $null) { 
      msg $chan /me >: Please enter a name to give credits too.
    }
    if ($3 == $null) { 
      msg $chan /me >: Please enter the number of credits to give.
    }
    msg $chan $2 has been given $3 credits
    set %money.add $calc($readini(rxcoin.ini,%user,coins) + $3 )
    writeini -n rxcoin.ini %user coins %money.add
    unset %money.add
  }
}

on *:TEXT:!dcreds *:#: { 
  var %user $nick
  var %val $readini(rxcoin.ini,%user,coins)
  if ($2 == $null) { 
    msg $chan /me >: Please insert a name to send credits too.
  }
  if ($3 == $null) { 
    msg $chan /me >: Please enter the number of credits  to give.
  }
  if (%val == $null) { 
    msg $chan /me >: You have no credits to give!
  }
  if (%val == 0) { 
    msg $chan /me >: You have no credits to give!
  }
  msg $chan /me >: $2 has been given $3 tokens by $nick
  var %money.add $calc($readini(rxcoin.ini,$2,coins) + $3 )
  var %money.withdraw $calc($readini(rxcoin.ini,%user,coins) - $3)
  writeini -n rxcoin.ini %user coins %money.withdraw
  writeini -n rxcoin.ini $2 coins %money.add
  unset %money.add
  unset %money.withdraw
}


So the problem seems to be you were using to many things for writeini, so when readini wanted to read a value it read a blank space. Technically you can keep your old format just change it to

$readini($readini(rxcoin.ini,#michaelukz,%user)

It will then reply with "$nick has coins 1 credits". So I think the code was counting "coins 1" as one piece instead of two different entities.

Also, just as a few side notes you can use # instead of typing out #michaeluks. It can cut down on the typing also if someone wants to use your script they don't have to go in there and change every line. Lastly, try not setting variables unless you need them in another command. Again its your choice how you code, just some advice I have.

Joined: Dec 2014
Posts: 68
M
Babel fish
OP Offline
Babel fish
M
Joined: Dec 2014
Posts: 68
Thank you! Also as for the #michaelukz, its just personal preference-- Plus I have a button on my mouse that types it out laugh

Joined: Nov 2014
Posts: 79
N
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
Did it work?


Link Copied to Clipboard