28.02.2015, 11:22
No need to use sscanf if you just have 1 string parameter, you can just use strcmp.
Params is the text you write after the cmd, like "/meslek [params]".
So strcmp just compares the "params" with the other text we provide, like "gil", and check if it's the same.
So if "params" is "gil", then it will activate the code below that.
But if you want to have several parameters, like "/meslek [params] [more params]", then you need to use sscanf.
pawn Код:
YCMD:meslek(playerid, params[], help)
{
if(isnull(params)) return SendClientMessage(playerid, -1, "<KULLANIM> /meslek [olustur/duzenle/sil/git]");
if(!strcmp(params, "olustur", true))
{
// Code
}
else if(!strcmp(params, "duzenle", true))
{
// Code
}
else if(!strcmp(params, "sil", true))
{
// Code
}
else if(!strcmp(params, "gil", true))
{
// Code
}
return 1;
}
So strcmp just compares the "params" with the other text we provide, like "gil", and check if it's the same.
So if "params" is "gil", then it will activate the code below that.
But if you want to have several parameters, like "/meslek [params] [more params]", then you need to use sscanf.