zcmd 2 string parameters issue, +rep for helpers.
#1

PHP код:
CMD:clan(playeridparams[])
{
    new 
tmp[12], tmp2[24];
    if(!
sscanf(params"s"tmptmp2))
    {
        if(!
strcmp(tmp"create"true))
        {
            if(
sscanf(params"ss"tmptmp2)) return Message(playeridTYPE_USAGE"/clan create [clan name]");
        }
    }
    else return 
Message(playeridTYPE_USAGE"/clan [create/invite/join/leave]");

I tried any possible way to make this work, it's really easy to solve I just could not find the way,

what I tried to do is:
/clan = error message "/clan [create/invite/join/leave]"
/clan create = error message "/clan create [clan name]"

I didn't post the whole code because it doesn't matter, I just need to understand how to do what i stated above
Reply
#2

try it

PHP код:
CMD:clan(playeridparams[])
{
    new 
tmp[12], tmp2[24];
    if(!
sscanf(params"s[12]s[24]"tmptmp2)) return Message(playeridTYPE_USAGE"/clan [create/invite/join/leave]");
    {
        if(!
strcmp(tmp"create"true))
        {
            
// create clan code with tmp2 var.
        
}
    }
    return 
1;

Reply
#3

Can you try this ?

PHP код:
CMD:clan(playeridparams[]) 

    new 
tmp[12], tmp2[24]; 
    if(!
sscanf(params"s[12]s[24]"tmptmp2)) 
    { 
        if(!
strcmp(tmp"create"true)) 
        { 
            if(
sscanf(params"s[12]s[24]"tmptmp2)) return Message(playeridTYPE_USAGE"/clan create [clan name]"); 
        } 
    } 
    else return 
Message(playeridTYPE_USAGE"/clan [create/invite/join/leave]"); 

Reply
#4

Quote:
Originally Posted by rolex
Посмотреть сообщение
try it

PHP код:
CMD:clan(playeridparams[])
{
    new 
tmp[12], tmp2[24];
    if(!
sscanf(params"s[12]s[24]"tmptmp2)) return Message(playeridTYPE_USAGE"/clan [create/invite/join/leave]");
    {
        if(!
strcmp(tmp"create"true))
        {
            
// create clan code with tmp2 var.
        
}
    }
    return 
1;

this one is just making the /clan create [name] message appear no matter what I do

Quote:
Originally Posted by Maximun
Посмотреть сообщение
Can you try this ?

PHP код:
CMD:clan(playeridparams[]) 

    new 
tmp[12], tmp2[24]; 
    if(!
sscanf(params"s[12]s[24]"tmptmp2)) 
    { 
        if(!
strcmp(tmp"create"true)) 
        { 
            if(
sscanf(params"s[12]s[24]"tmptmp2)) return Message(playeridTYPE_USAGE"/clan create [clan name]"); 
        } 
    } 
    else return 
Message(playeridTYPE_USAGE"/clan [create/invite/join/leave]"); 

this one is not detecting what i type on the tmp2
Reply
#5

PHP код:
CMD:clan(playeridparams[])  
{  
    new 
tmp[12], tmp2[24];  
    if(
sscanf(params"s[12]"tmp)) 
     {
        
Message(playeridTYPE_USAGE"/clan create [clan name]");  
        return 
1;
    }    
    if(!
strcmp(tmp"create"true))
    {
        if(
sscanf(params"s[12]s[24]"tmptmp2))
        {
            
//Put your code here
            
return 1;
        }
    }  
    return 
1;

Reply
#6

Quote:
Originally Posted by Maximun
Посмотреть сообщение
PHP код:
CMD:clan(playeridparams[])  
{  
    new 
tmp[12], tmp2[24];  
    if(
sscanf(params"s[12]"tmp)) 
     {
        
Message(playeridTYPE_USAGE"/clan create [clan name]");  
        return 
1;
    }    
    if(!
strcmp(tmp"create"true))
    {
        if(
sscanf(params"s[12]s[24]"tmptmp2))
        {
            
//Put your code here
            
return 1;
        }
    }  
    return 
1;

no matter what you type it returns /clan create [clan name] when i use this code.
Reply
#7

Try dis
PHP код:
if(sscanf(params"ss"tmptmp2)) return Message(playeridTYPE_USAGE"/clan create [clan name]"); 
Becomes
PHP код:
if(sscanf(params[7], "s"tmp2)) return Message(playeridTYPE_USAGE"/clan create [clan name]"); 
Reply
#8

Why s[12] though, and why not return the strings to the chat window so you can see what it's picking up.


I'd be looking at s[6]s for params... as create delete and invite are all 6 chars long.
Reply
#9

pawn Код:
CMD:clan(playerid, params[])
{
    new tmp[7], tmp2[24];
    if(!sscanf(params, "s[7]S()[24]", tmp, tmp2))
    {
        if(!strcmp(tmp, "create", true))
        {
            if(isnull(tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
            // CREATE
            return 1;
        }
        // if invite...
    }
    return Message(playerid, TYPE_USAGE, "/clan [create/invite/join/leave]");
}
I don't even think the sscanf is needed at first place, could use strcmp on params (>= 0 ?), in case you are going to use sscanf the tmp2 again for invite player name.
Reply
#10

Quote:
Originally Posted by RoboN1X
Посмотреть сообщение
pawn Код:
CMD:clan(playerid, params[])
{
    new tmp[7], tmp2[24];
    if(!sscanf(params, "s[7]S()[24]", tmp, tmp2))
    {
        if(!strcmp(tmp, "create", true))
        {
            if(isnull(tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
            // CREATE
            return 1;
        }
        // if invite...
    }
    return Message(playerid, TYPE_USAGE, "/clan [create/invite/join/leave]");
}
I don't even think the sscanf is needed at first place, could use strcmp on params (>= 0 ?), in case you are going to use sscanf the tmp2 again for invite player name.
your code results:

/clan = Message "/clan [create/invite/join/leave]"
/clan create [null tmp2] = Message "/clan [create/invite/join/leave]"
/clan create TestClan = Message "/clan create [clan name]"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)