mIRC Homepage
Posted By: gamblebills Need help with Scripting. - 07/12/11 12:56 PM
Hello guys,
this is my first time here so i may post this in wrong section.

I need some help with scripting.
This is what i need, when a HalfOP+ enter's a command like this:

!dd (user name 1) (user name 2) 5m

as example:

!dd Gangster1 Master2 5m

than the bot has to say:

Dyce duel Between Gangster1 and Master2 has begun.
Roll now.

and after they have to do !roll
(already had the script.)

and than like
gangster rolled a 4
and master a 2
than the bot has to say the results from both.
like

gangster won the 5m pot with a 4-2

if people dont understand this than im albe to teamview what i mean.



GambleBills
Posted By: Riamus2 Re: Need help with Scripting. - 07/12/11 03:23 PM
All scripting questions should be in the scripting forum. smile

Code:
on *:text:!dd *:#yourchannel: {
  ; You can remove the first two IF lines if you don't care about checking if the nicks are on the channel.
  if ($2 !ison $chan) { msg $chan $2 is not a valid nick. | halt }
  if ($3 !ison $chan) { msg $chan $3 is not a valid nick. | halt }
  if (!$4) { msg $chan Invalid format.  Use: !dd nick1 nick2 reward | halt }
  set %dd $2 $3 $4
  msg $chan Dice duel between $2 and $3 has begun.
}
on *:text:!roll:#yourchannel: {
  if (!%dd) { msg $chan No duel in progress. | halt }
  var %r1 = $rand(1,6), %r2 = $rand(1,6), %d1 = $gettok(%dd,1,32), %d2 = $gettok(%dd,2,32), %p = $gettok(%dd,3,32)
  msg $chan %d1 rolled a %r1 $+ .
  msg $chan %d2 rolled a %r2 $+ .
  if (%r1 > %r2) { msg $chan %d1 won the %p pot with a %r1 $+ - $+ %r2 $+ . }
  elseif (%r2 > %r1) { msg $chan %d2 won the %p pot with a %r1 $+ - $+ %r2 $+ . }
  else { msg $chan %d1 and %d2 tied with a %r1 $+ - $+ %r2 $+ . }
  unset %dd
}


That's a basic script for you. I could have set more than one global variable in the !dd section instead of using one global and then a lot of local variables in the !roll section, but I prefer avoiding global variables unless needed.

I didn't add any flood protection. You can add any generic flood protection you like or just mIRC's flood protection if you think there is a need.
Posted By: gamblebills Re: Need help with Scripting. - 07/12/11 08:52 PM
Originally Posted By: Riamus2
All scripting questions should be in the scripting forum. smile

Code:
on *:text:!dd *:#yourchannel: {
  ; You can remove the first two IF lines if you don't care about checking if the nicks are on the channel.
  if ($2 !ison $chan) { msg $chan $2 is not a valid nick. | halt }
  if ($3 !ison $chan) { msg $chan $3 is not a valid nick. | halt }
  if (!$4) { msg $chan Invalid format.  Use: !dd nick1 nick2 reward | halt }
  set %dd $2 $3 $4
  msg $chan Dice duel between $2 and $3 has begun.
}
on *:text:!roll:#yourchannel: {
  if (!%dd) { msg $chan No duel in progress. | halt }
  var %r1 = $rand(1,6), %r2 = $rand(1,6), %d1 = $gettok(%dd,1,32), %d2 = $gettok(%dd,2,32), %p = $gettok(%dd,3,32)
  msg $chan %d1 rolled a %r1 $+ .
  msg $chan %d2 rolled a %r2 $+ .
  if (%r1 > %r2) { msg $chan %d1 won the %p pot with a %r1 $+ - $+ %r2 $+ . }
  elseif (%r2 > %r1) { msg $chan %d2 won the %p pot with a %r1 $+ - $+ %r2 $+ . }
  else { msg $chan %d1 and %d2 tied with a %r1 $+ - $+ %r2 $+ . }
  unset %dd
}


That's a basic script for you. I could have set more than one global variable in the !dd section instead of using one global and then a lot of local variables in the !roll section, but I prefer avoiding global variables unless needed.

I didn't add any flood protection. You can add any generic flood protection you like or just mIRC's flood protection if you think there is a need.


Tysm, but i mean they need to roll at their own, like u vs me, so i have to roll and you have to roll. and at the scores when its about who won, it shows just who is noticed first, like i won a 4-6 it should show 6-4 i would really appriciate if you could help me more.
Posted By: Riamus2 Re: Need help with Scripting. - 07/12/11 10:34 PM
Code:
on *:text:!dd *:#yourchannel: {
  ; You can remove the first two IF lines if you don't care about checking if the nicks are on the channel.
  if ($2 !ison $chan) { msg $chan $2 is not a valid nick. | halt }
  if ($3 !ison $chan) { msg $chan $3 is not a valid nick. | halt }
  if (!$4) { msg $chan Invalid format.  Use: !dd nick1 nick2 reward | halt }
  set %dd $2 $3 $4
  msg $chan Dice duel between $2 and $3 has begun.
  .timerDD 1 300 EndDD
}
on *:text:!roll:#yourchannel: {
  if (!%dd) { msg $chan No duel in progress. | halt }
  if (!$istok(%dd,$nick,32)) { msg $chan You are not one of the duelists. | halt }
  if ($($+(%,ddr.,$nick),2)) { msg $chan You have already rolled. | halt }
  var %r = $rand(1,6), %d1 = $gettok(%dd,1,32), %d2 = $gettok(%dd,2,32), %p = $gettok(%dd,3,32)
  set %ddr. $+ $nick %r
  msg $chan $nick rolled a %r $+ .
  var %r1 = $($+(%,ddr.,$gettok(%dd,1,32)),2), %r2 = $($+(%,ddr.,$gettok(%dd,2,32)),2)
  if (%r1 && %r2) {
    if (%r1 > %r2) { msg $chan %d1 won the %p pot with a %r1 $+ - $+ %r2 $+ . }
    elseif (%r2 > %r1) { msg $chan %d2 won the %p pot with a %r2 $+ - $+ %r1 $+ . }
    else { msg $chan %d1 and %d2 tied with a %r1 $+ - $+ %r2 $+ . }
    unset %dd
    unset %ddr.*
    .timerDD off
  }
}
alias EndDD {
  msg $chan The duel ran out of time and has been ended.
  unset %dd
  unset %ddr.*
}


Ok, this should do what you asked. It will also automatically end the duel after 5 minutes (300 seconds) in case one person never rolls. If you want to adjust that time, change the 300 in the timer to something else.
Posted By: gamblebills Re: Need help with Scripting. - 09/12/11 04:11 PM
Originally Posted By: Riamus2
Code:
on *:text:!dd *:#yourchannel: {
  ; You can remove the first two IF lines if you don't care about checking if the nicks are on the channel.
  if ($2 !ison $chan) { msg $chan $2 is not a valid nick. | halt }
  if ($3 !ison $chan) { msg $chan $3 is not a valid nick. | halt }
  if (!$4) { msg $chan Invalid format.  Use: !dd nick1 nick2 reward | halt }
  set %dd $2 $3 $4
  msg $chan Dice duel between $2 and $3 has begun.
  .timerDD 1 300 EndDD
}
on *:text:!roll:#yourchannel: {
  if (!%dd) { msg $chan No duel in progress. | halt }
  if (!$istok(%dd,$nick,32)) { msg $chan You are not one of the duelists. | halt }
  if ($($+(%,ddr.,$nick),2)) { msg $chan You have already rolled. | halt }
  var %r = $rand(1,6), %d1 = $gettok(%dd,1,32), %d2 = $gettok(%dd,2,32), %p = $gettok(%dd,3,32)
  set %ddr. $+ $nick %r
  msg $chan $nick rolled a %r $+ .
  var %r1 = $($+(%,ddr.,$gettok(%dd,1,32)),2), %r2 = $($+(%,ddr.,$gettok(%dd,2,32)),2)
  if (%r1 && %r2) {
    if (%r1 > %r2) { msg $chan %d1 won the %p pot with a %r1 $+ - $+ %r2 $+ . }
    elseif (%r2 > %r1) { msg $chan %d2 won the %p pot with a %r2 $+ - $+ %r1 $+ . }
    else { msg $chan %d1 and %d2 tied with a %r1 $+ - $+ %r2 $+ . }
    unset %dd
    unset %ddr.*
    .timerDD off
  }
}
alias EndDD {
  msg $chan The duel ran out of time and has been ended.
  unset %dd
  unset %ddr.*
}


Ok, this should do what you asked. It will also automatically end the duel after 5 minutes (300 seconds) in case one person never rolls. If you want to adjust that time, change the 300 in the timer to something else.

what will happen when they tie? can you do it so they have to re roll? and can you make it avaible for multiple duels? and Halfop+? i might pay you for this if you want. i really need this.
Posted By: Riamus2 Re: Need help with Scripting. - 09/12/11 09:06 PM
If they tie, it ends like any other time. They do !dd again if they want another duel or they can stop. If you want this only for halfops+, then just throw in an IF at the beginning of the !dd event where the other IFs are:

Code:
if ($nick isvoice || $nick isreg) { msg $chan Only halfop or higher can start a duel. | halt }
Posted By: rossy319 Re: Need help with Scripting. - 16/01/12 07:13 AM
How do you make it re-roll and make it so only voiced members + can use the command !dd user1 user2 200m ?
Posted By: johnnygold2 Re: Need help with Scripting. - 14/02/12 01:13 AM
since i want to start a dicing clan, i tried it. but every time i add someone to a dice duel and they roll it says that their is no duel in progress. am i typing in the wrong command or is their something else im forgetting. i just copied and pasted the script in. changed nothing else.
Posted By: Riamus2 Re: Need help with Scripting. - 14/02/12 02:46 AM
You have 5 minutes after typing !dd nick nick reward to use !roll or the duel ends. As long as you type the right !dd command and you !roll in time, you shouldn't get that message. If you do, then your variable is being unset by something -- perhaps another script.
Posted By: johnnygold2 Re: Need help with Scripting. - 14/02/12 07:50 PM
i just pasted it into the remote section in the scripts editor. is that all i need to do?
Posted By: Riamus2 Re: Need help with Scripting. - 14/02/12 08:07 PM
Yes. As long as it's a blank script file, it should work fine. If you have other scripts, there's the possibility one is conflicting with it and removing the variable.
Posted By: johnnygold2 Re: Need help with Scripting. - 14/02/12 08:40 PM
it wont work. ill type ex. !dd ham turky 1m and when they do !roll it says that their is no duel in progress
Posted By: Riamus2 Re: Need help with Scripting. - 14/02/12 09:24 PM
Not really sure what to tell you. The variable that gives that message is set when doing %dd and not unset for 5 minutes. As long as it is set, it won't display that message. You'd have to do some troubleshooting to find out why the variable is being unset or not being set.

You *do* have the message saying the duel is started, right? If not, then the first part of the script isn't triggering for whatever reason. If that's the case, you have another script causing a problem or you're using colors when typing !dd or something like that.
Posted By: sparta Re: Need help with Scripting. - 14/02/12 11:03 PM
You dont try to type !dd your self? if so you need to use :input: instead of :text:
Posted By: johnnygold2 Re: Need help with Scripting. - 14/02/12 11:15 PM
i dont have the message that the duel is starting. what should i do troubleshoot? im not good with this scripting stuff and the variables i have are....


%dice_Port 6667
%dice_Channel #privvy
%dice_useHotbits 0
%dice_useColors 1
%dice_prefix $player
%dice_echoExpression 1
%dice_echoDescription 1
%dice_echoRolls 1
%dice_clrPrefix 4,1
%dice_clrExpression 7,1
%dice_clrDescription 4,1
%dice_clrRollList 10,1
%dice_clrTotal 8,1


which ones should i remove?

Posted By: Riamus2 Re: Need help with Scripting. - 15/02/12 03:09 AM
You don't remove any of those variables. But the fact that you have dice variables says you have some other dice script and it may interfere. Also, as sparta said, if you are running the script on the same client you're trying to type !dd from, then it won't work. It was written to act as a bot where the !dd command is done by someone else.
Posted By: johnnygold2 Re: Need help with Scripting. - 15/02/12 07:56 PM
ok well i deleted the other dice script. now i dont get the message saying that theirs not dice duel in progress when someone types !roll but it wont roll and it still doesnt show that the duel has been started. i still have the variables and do i need to add any commands?
Posted By: Riamus2 Re: Need help with Scripting. - 16/02/12 12:09 PM
All I can suggest is to make sure the script is in a new file (not underneath any other script) and that you don't try triggering it yourself. Beyond that, you'd have to troubleshoot why it's not working because it should work fine.
Posted By: johnnygold2 Re: Need help with Scripting. - 16/02/12 07:40 PM
what you mean by being in a new file?
Posted By: Riamus2 Re: Need help with Scripting. - 16/02/12 08:56 PM
Alt-R > File > New and then paste. If you already have it as part of another script (same file), then delete it from there first. Then do File > New and paste. Any time someone gives you a script, you should place it in its own file and not put it in the same file as another script to avoid possible problems.
Posted By: johnnygold2 Re: Need help with Scripting. - 16/02/12 09:30 PM
ok got it to work. how can i make it so only ops can host? and when i try to op someone then the chanserv automatically deops them. and is their any way to change it so the rolls come up in colors. like blue or red? also what can i do so that if two people roll the name number it says "tie please reroll" and could it say "reroll for jackpot" if someone were to roll a 12
© mIRC Discussion Forums