mIRC Homepage
Posted By: Goku04xx Irc bets - 10/11/12 03:00 PM
Hi guys i wanted to know how to make only one bet at a time Example
If someone makes a bet and it is not finish and they try to make another bet, I want a script that cant do that only they can place one bet at a time or remove the other one how would that look
Thanks
Pastebin
Posted By: TerryG Re: Irc bets - 11/11/12 02:00 PM
maybe if you writeini to store the !bet data, then you could readini to use the data and remove the ini file or maybe clear the file at the end of the script

Im very unsure if this would work but maybe its a start
Posted By: Goku04xx Re: Irc bets - 12/11/12 10:17 PM
Can you show me how the script would look that would be much helpful and i can see what you mean
Thanks
Posted By: Riamus2 Re: Irc bets - 12/11/12 11:39 PM
You can do a variety of things in the !bet section depending on how you want to do this and how many bets you want to handle at once.

If you only want one bet per nick, you could change your variables to %whatever. $+ $nick and then to use the variable, you'd use $($+(%,whatever,$nick),2) . You can then easily unset all bets by just unsetting all matching variables... /unset %whatever*

If you want multiple bets per nick or expect to have a lot of bets rather than only a handful at a time, then you can store the bets in a file or a hash table. I'd probably recommend a hash table. Especially if you're not planning to save the bets for use later on and want it to just clear out each time you start mIRC. If you do a hash table, you can do the same kind of thing for storing the data. First, create the table /hmake bets . Then, when bets are done, add the bets to the table. If you only want one bet per nick, you can add them as //hadd bets $nick %roller1 %roller2 %bet . If you want multiple bets from the same person, you can use something other than the nick for the bet name (it's up to you) and then include the $nick as part of the data value. Then just use $hget() and $gettok() to retrieve the data.

You can use /help on any of the commands for more details and examples. That should get you a good start on what you need.
Posted By: Goku04xx Re: Irc bets - 12/11/12 11:47 PM
yes per host that makes the bet the only do !bet user user NUMBER they cant do it while they have another bet in place
And can you show me where to put that in my script the first part you said i want that
Posted By: Riamus2 Re: Irc bets - 13/11/12 01:41 AM
I'd really recommend just using a hash table.

Here is the first part. You'll still have to update the second part, but I don't have time right now to do it. You'll want to do a search on the table to find which bet the nick is in and store the rolls in the table. When both rolls are done, display the results and /hdel the bet.

Maybe someone can finish that part for you.

*Note for anyone trying to make use of this... the /hadd command adds roller1, roller2, rollerpot, and then 0 and 0 to the table with item name of $nick. The 2 zeros are the roll placeholders. To know if the roll has been completed, check to see if it's > 0. If both are > 0, then the bet is finished and you can do the display and remove it. You'll probably also want to add protection so someone doesn't roll again if they've already rolled. After adding that kind of protection, a nick could be a roller in multiple bets, but will only be able to roll on the first matching bet until that one completes. You could change how that works as well if you want.

Anyhow, this is just one option to handle this. Maybe someone has another option they want to suggest for you.

Code:
on *:TEXT:!bet*:#msl.test,#Goku04xx,#Epic_Dice: {
  if ($4 && !$nick(#Epic_Dice,$nick,ohv)) {
    notice $nick 12You must be a channel (half)operator to use this command.
    return
  }

  if (!$hget(bets)) { hmake bets }
  if ($hget(bets,$nick) {
    msg # You've already placed a bet.
    return
  }
  var %potamount = $calc($4 *1.8) 
  if ($4 && $nick(#Epic_Dice,$nick,ohv)) {
    hadd bets $nick $2-4 0 0
    msg # 7[ $nick ] 12 $+ $2 1vs 12 $3  - 12 $4 $+ M    - 1 Roll em!
  }
}
on *:TEXT:!remove*:#msl.test,#Goku04xx,#Epic_Dice: {
  if ($hget($2))
  {
    msg # 4Wager between  $gettok($hget(bets,$2),1,32) and $gettok($hget(bets,$2),2,32) has been removed!
    hdel bets $2
  }
  else if ($hget($nick)) {
    msg # 4Wager between  $gettok($hget(bets,$nick),1,32) and $gettok($hget(bets,$nick),2,32) has been removed!
    hdel bets $nick
  }
  else {
    msg # No matching bets to remove.
  }
}
Posted By: KindOne Re: Irc bets - 13/11/12 11:28 AM
Two Syntax issues.

Line 8: Missing ")".
Code:
if ($hget(bets,$nick) {

Should be:
Code:
if ($hget(bets,$nick)) {


Line 19/20: You can't have "{" starting at the next line.
Code:
  if ($hget($2))
  {

Should be:
Code:
  if ($hget($2)) {
Posted By: Riamus2 Re: Irc bets - 13/11/12 11:56 PM
Heh, thanks. I was rushed so missed the parentheses and I've been programming in c# for so long lately that I'm in the habit of putting the { down a line. smile
Posted By: Goku04xx Re: Irc bets - 14/11/12 10:32 PM
Ok i updated the script to what rambus said can you finish it it works but when i place a bet i cant remove it or i get this.
[16:26:05] <@Goku04xx> !bet Goku04xx abc 100
[16:26:06] <@Epic_Dice|Bot> [ Goku04xx ] Goku04xx vs abc - 100M - Roll em!
[16:26:36] <@Goku04xx> !remove
[16:26:36] <@Epic_Dice|Bot> No matching bets to remove.

[16:26:45] <@Goku04xx> !remove Goku04xx abc 100
[16:26:46] <@Epic_Dice|Bot> No matching bets to remove.
New updated
Also having some other problems i cant roll and my pot is not right it should be like Example.
!bet Goku04xx Abc 100
[17:21:28] <@Epic_Dice|Bot> [ Goku04xx|Bot ] Goku04xx vs abc - 180M - Roll em!
Posted By: Goku04xx Re: Irc bets - 14/11/12 11:52 PM
How would i add that also
You'll probably also want to add protection so someone doesn't roll again if they've already rolled. After adding that kind of protection, a nick could be a roller in multiple bets, but will only be able to roll on the first matching bet until that one completes. You could change how that works as well if you want.
Posted By: Goku04xx Re: Irc bets - 15/11/12 12:27 AM
But what about my roll part of my script do i still need those variables and that script
Posted By: Goku04xx Re: Irc bets - 16/11/12 11:25 PM
Originally Posted By: Goku04xx
Ok i updated the script to what rambus said can you finish it it works but when i place a bet i cant remove it or i get this.
[16:26:05] <@Goku04xx> !bet Goku04xx abc 100
[16:26:06] <@Epic_Dice|Bot> [ Goku04xx ] Goku04xx vs abc - 100M - Roll em!
[16:26:36] <@Goku04xx> !remove
[16:26:36] <@Epic_Dice|Bot> No matching bets to remove.

[16:26:45] <@Goku04xx> !remove Goku04xx abc 100


[16:26:46] <@Epic_Dice|Bot> No matching bets to remove.
New updated
Also having some other problems i cant roll and my pot is not right it should be like Example.
!bet Goku04xx Abc 100
[17:21:28] <@Epic_Dice|Bot> [ Goku04xx|Bot ] Goku04xx vs abc - 180M - Roll em!


The remove part has been solved i just need my roll script back do i need the same roll script i had before or what
© mIRC Discussion Forums