How can I do a command with params using YCMD?
#1

Код:
YCMD:meslek(playerid, params[], help)
{
	new meslekID[3];
	if(isnull(params))
	{
		SendClientMessage(playerid, -1, "<KULLANIM> /meslek [olustur/duzenle/sil/git]");
	}
	return 1;
}
I used like this. If player types the command like "/meslek olustur" it does something but I couldn't do it. Should I use sscanf or what?
Reply
#2

yes use sscanf or strcmp
Reply
#3

Can you make an example?
Reply
#4

No need to use sscanf if you just have 1 string parameter, you can just use strcmp.
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;
}
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.
Reply
#5

Quote:
Originally Posted by CalvinC
Посмотреть сообщение
No need to use sscanf if you just have 1 string parameter, you can just use strcmp.
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;
}
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.
Thank you very much. Rep added.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)