sscanf(2.0) and IRC command
#1

More sscanf 2.0 dilemmas!

I'm rewriting my IRC script, I'm trying to add this command but I got to a certain point and got stuck... how would I do it so you can enter a password parameter and it'll use it but if you don't enter a password parameter it'll just join the channel without. I'm tired right now I can't think properly .. any help is appreciated, etc.

Also, note that the parameters will be strings, right? The usage format'd be like:
pawn Код:
!join #channel passwordhere
- with password

or it can also be used without

pawn Код:
!join #channel
pawn Код:
IRCCMD:join(botid, channel[], user[], host[], params[])
{
    if(IRC_IsOp(botid, channel, user))
    {
      if(!isnull(params))
      {
            new channel, msg[128], pass;
            if(sscanf(params, "s[100]z[100]", channel, pass))
            {
                IRC_JoinChannel(gBotID[0], channel
Reply
#2

Man, it's pretty simple:

pawn Код:
// Let's make a 3 parameters exaple

new
  a[10],
  b[10],
  c[10];

#define Z 8 // sizeof

if(sscanf(string, "s["#Z"]", a))
{
  // the stuff to join the channel
}
else if(sscanf(string, "s["#Z"]s["#Z"]", a, b))
{
  // this is what happens if he typed the first param but not the second
}
else if(sscanf(string, "s["#Z"]s["#Z"]s["#Z"]", a, b, c))
{
  // this is what happens if he types the first and the second but not the third
}
else
{
  // this is what happens if he typed all the params
}
Reply
#3

That helped a great deal .. but, does that actually work? Why didn't I think of that?! lol :P
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)