zcmd 2 string parameters issue, +rep for helpers. -
Lirbo - 14.03.2018
PHP код:
CMD:clan(playerid, params[])
{
new tmp[12], tmp2[24];
if(!sscanf(params, "s", tmp, tmp2))
{
if(!strcmp(tmp, "create", true))
{
if(sscanf(params, "ss", tmp, tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
}
}
else return Message(playerid, TYPE_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
Re: zcmd 2 string parameters issue, +rep for helpers. -
rolex - 14.03.2018
try it
PHP код:
CMD:clan(playerid, params[])
{
new tmp[12], tmp2[24];
if(!sscanf(params, "s[12]s[24]", tmp, tmp2)) return Message(playerid, TYPE_USAGE, "/clan [create/invite/join/leave]");
{
if(!strcmp(tmp, "create", true))
{
// create clan code with tmp2 var.
}
}
return 1;
}
Re: zcmd 2 string parameters issue, +rep for helpers. -
Maximun - 14.03.2018
Can you try this ?
PHP код:
CMD:clan(playerid, params[])
{
new tmp[12], tmp2[24];
if(!sscanf(params, "s[12]s[24]", tmp, tmp2))
{
if(!strcmp(tmp, "create", true))
{
if(sscanf(params, "s[12]s[24]", tmp, tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
}
}
else return Message(playerid, TYPE_USAGE, "/clan [create/invite/join/leave]");
}
Re: zcmd 2 string parameters issue, +rep for helpers. -
Lirbo - 14.03.2018
Quote:
Originally Posted by rolex
try it
PHP код:
CMD:clan(playerid, params[])
{
new tmp[12], tmp2[24];
if(!sscanf(params, "s[12]s[24]", tmp, tmp2)) return Message(playerid, TYPE_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(playerid, params[])
{
new tmp[12], tmp2[24];
if(!sscanf(params, "s[12]s[24]", tmp, tmp2))
{
if(!strcmp(tmp, "create", true))
{
if(sscanf(params, "s[12]s[24]", tmp, tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
}
}
else return Message(playerid, TYPE_USAGE, "/clan [create/invite/join/leave]");
}
|
this one is not detecting what i type on the tmp2
Re: zcmd 2 string parameters issue, +rep for helpers. -
Maximun - 14.03.2018
PHP код:
CMD:clan(playerid, params[])
{
new tmp[12], tmp2[24];
if(sscanf(params, "s[12]", tmp))
{
Message(playerid, TYPE_USAGE, "/clan create [clan name]");
return 1;
}
if(!strcmp(tmp, "create", true))
{
if(sscanf(params, "s[12]s[24]", tmp, tmp2))
{
//Put your code here
return 1;
}
}
return 1;
}
Re: zcmd 2 string parameters issue, +rep for helpers. -
Lirbo - 14.03.2018
Quote:
Originally Posted by Maximun
PHP код:
CMD:clan(playerid, params[])
{
new tmp[12], tmp2[24];
if(sscanf(params, "s[12]", tmp))
{
Message(playerid, TYPE_USAGE, "/clan create [clan name]");
return 1;
}
if(!strcmp(tmp, "create", true))
{
if(sscanf(params, "s[12]s[24]", tmp, tmp2))
{
//Put your code here
return 1;
}
}
return 1;
}
|
no matter what you type it returns /clan create [clan name] when i use this code.
Re: zcmd 2 string parameters issue, +rep for helpers. -
jlalt - 15.03.2018
Try dis
PHP код:
if(sscanf(params, "ss", tmp, tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
Becomes
PHP код:
if(sscanf(params[7], "s", tmp2)) return Message(playerid, TYPE_USAGE, "/clan create [clan name]");
Re: zcmd 2 string parameters issue, +rep for helpers. -
Sew_Sumi - 15.03.2018
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.
Re: zcmd 2 string parameters issue, +rep for helpers. -
RoboN1X - 15.03.2018
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.
Re: zcmd 2 string parameters issue, +rep for helpers. -
Lirbo - 15.03.2018
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]"