mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Aug 2014
Posts: 42
K
Ameglian cow
OP Offline
Ameglian cow
K
Joined: Aug 2014
Posts: 42
Hey,
i want to make a little game script but dont know how to start! Perhaps someone can help me. The Idea:
Someone in the Chat is starting the game with ex.: !startgame - and other ppl can join the game too with !join.

I thought about something like that:
Code:
on *:Text:!join:#: { set %player $nick }
on *:Text:!players:#: { msg $chan Players are: %player }


to put in the $nicks into a variable like %player, but its only saveing the last $nick smile i need Input and perhaps a example how to - would be so nice!


THE GENERALLY QUESTION IS:
How to make multiplayer games and save the players to the script w.o. useing a text or ini file!

Last edited by Krawalli; 06/08/14 11:03 AM.
Joined: Aug 2013
Posts: 80
I
Babel fish
Offline
Babel fish
I
Joined: Aug 2013
Posts: 80
Simply use the variable as part of the value (along with $nick of course) when setting it.

You'll also, I'm sure, want to make sure that a person doesn't join twice, so you have three two basic options:

  1. Use an if statement in conjunction with the $istok() identifier (or similar, such as $findtok(), $matchtok(), $wildtok(), or $regex()), along with an optional "you have already joined" else message:

    Code:
    on *:TEXT:!join:#:{
      if (!$istok(%player,$nick,32)) { set %player %player $nick }
      else .notice $nick You have already joined!
    }
  2. Use the $addtok() identifier to add a nick to the list of players only if it does not already exist. (Note that this method alone cannot determine whether the $nick is a player beforehand - you'll need the if statement method above for that):

    Code:
    on *:TEXT:!join:#:{ set %player $addtok(%player,$nick,32) }
  3. Click to reveal.. (I said two options!)
    Put total trust and confidence in your channelgoers that they will only join once per game: (not recommended!)

    Code:
    on *:TEXT:!join:#:{ set %player %player $nick }


Hopefully this will help you get started. If you need any more help, don't hesitate to ask.

Joined: Aug 2014
Posts: 1
I
Mostly harmless
Offline
Mostly harmless
I
Joined: Aug 2014
Posts: 1
Hello im super super new to this. And im learning slowly. but i also was interested to create a interactive game chat. I must say coding is already pretty hard for me but im learning. Is there anyway you could help me one on one? for example like if you helped me on my twitch chat. or skyped me?

Joined: Sep 2005
Posts: 2,881
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
There's nothing wrong with lire's script, but if you have a large channel or your channel grows in popularity, you will soon hit the string limit of around 4,000 characters for variables.

I think the built-in user list would be ideal for this sort of thing and wouldn't be subject to the string limit:

Code:
on game:text:!join:#channel:{
  if (!%flood) { 
    inc -u5 %flood 
    msg # $nick You have already joined!
  }
}
on *:text:!join:#channel:{ guser game $nick 2 }

on me:*:part:#channel: { rlevel game }
on me:*:quit:{ 
  if ($network == the_network) { rlevel game }
}
on *:kick:#channel:{
  if ($knick == $me) { rlevel game }
}

Joined: Aug 2013
Posts: 80
I
Babel fish
Offline
Babel fish
I
Joined: Aug 2013
Posts: 80
I considered the LLL, but I figured that there would only ever be a few players at a time and thus wouldn't matter. (a sort of "one person starts the game, a few people join, then they play till the game ends and the players list is cleared" kind of thing). Of course, I was thinking of an, er, "sessional" type of game rather than a continual one, but if it is a continual game, and the list of players is to be kept indefinitely, then the userlist is a more viable option.


Link Copied to Clipboard