Sub cmd sscanf -
Noliax8 - 27.12.2013
Hi,
I had a problem with sscanf, warning about optional string. It's corrected : S(No Reason)[125]
But, my script don't work.
PHP код:
YCMD:admin(playerid, params[], help)
{
new tmp[20],
nextParams[125]
;
if( sscanf(params, "s[25]S(No Reason)[125]", tmp, nextParams) )
return SendClientMessage(playerid, -1, "{9DEB00}Usage: /admin [Choix]");
else
{
if( !strcmp(tmp, "slap", true) )
{
new userid,
raison[50],
Float:POS[3]
;
if( sscanf(nextParams, "uS(No Reason)[50]", userid, raison) )
return SendClientMessage(playerid, -1, "[Commande] /admin slap [ID/Partie du Nom] [Raison (facultatif)]");
else
{
if( InvalidPlayerID(playerid, userid) ) return 1;
GetPlayerPos(userid, POS[0], POS[1], POS[2]);
SetPlayerPos(userid, POS[0], POS[1], POS[2]+5);
if( strlen(raison) > 0)
SendClientMessageToAllEx(-1, "[ADMIN] L'admin %s a slap %s. Raison: %s", returnNameEx(playerid), returnNameEx(userid), raison);
else
SendClientMessageToAllEx(-1, "[ADMIN] L'admin %s a slap %s.", returnNameEx(playerid), returnNameEx(userid));
}
}
}
return 1;
}
I write: /admin : ok : "/admin [choix]"
I write: /admin slap : not ok! : "Player not connected" (warning from InvalidPlayerID) ...
Help
Thanks
Re: Sub cmd sscanf -
Hansrutger - 27.12.2013
What is S(No Reason)? :S Actually asking, first time I see it in a sscanf :P
Re : Sub cmd sscanf -
Noliax8 - 27.12.2013
Optional string.
Juste S[150] displays warning...
Re: Sub cmd sscanf -
Hansrutger - 27.12.2013
Well use s[150]. :P
Re : Sub cmd sscanf -
Noliax8 - 27.12.2013
It's not a optional string.
But, it does not solve my problem...
I want do
/admin slap ID REASON
/admin ban ID REASON
/admin goto ....
...
Re: Sub cmd sscanf -
Hansrutger - 27.12.2013
Tried that once, didn't work that way lol. I have tried to have more sscanf's inside sscanf's like you did above but it's not the way it works sadly. :/ Not for me at least. I solved it with having one sscanf for everything like:
if(sscanf(params, "s[len]s[len]s[len]u", firstString, firstOption, secondOption, targetID))
Re : Sub cmd sscanf -
Noliax8 - 27.12.2013
On thй other solution ? I prefer do otherwise ..
Re: Re : Sub cmd sscanf -
Hansrutger - 27.12.2013
Quote:
Originally Posted by Noliax8
On thй other solution ? I prefer do otherwise ..
|
Good luck, tell me if you find a solution. I would also like to know it then haha. :P No really tell me if you get to some other conclusion!
Re : Sub cmd sscanf -
Noliax8 - 28.12.2013
It really is more practical ...
For restrictions, organization, etc. ...
Help!
Re: Sub cmd sscanf -
newbie scripter - 28.12.2013
What do u want to make?