Problem with this command
#1

I wanna make command for myself setting prefix.
There is the command
Код:
CMD:hellixpower(playerid, params[])
{
        new playerName[MAX_PLAYER_NAME];
		GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
        if(!strcmp(playerName, "[mW]HellixBG", true, 12))
        {
    	new prefix[16];
        if ( sscanf ( params, "us", prefix)) return SendClientMessage(playerid, 0xFF0000FF, "Използвай: /hellixpower [текст]");
        new Name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
        dini_Set(LOCAL_TAGCONF, Name, prefix);
        }
        else return SCM(playerid, 0xFF0000FF, "ERROR: Грешна команда, моля проверете командите /cmds.");
        return 1;
}
And it says Unknown command
Help me
Код:
#define MAX_CHAR 50
#define LOCAL_TAGCONF "Tags/config.ini"
CheckPrefix(playerid)
{
        new pref[16], Name[MAX_PLAYER_NAME];
        GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
        format ( pref, sizeof ( pref ), dini_Get(LOCAL_TAGCONF, Name));
        return pref;
}

OnGameModeInit             if ( !fexist(LOCAL_TAGCONF))
        {
                dini_Create(LOCAL_TAGCONF);
                if ( !fexist(LOCAL_TAGCONF))
                {
                        print("Config.ini nao pode ser criado. ( Diretorio Inexistente )");
                        print("No diretorio scriptfiles crie uma pasta: TAGS");
                        return 1;
                }
        }
OnPlayerText
        if ( strcmp(CheckPrefix(playerid), "None", false))
        {
                new Str[128], Name[MAX_PLAYER_NAME];
                GetPlayerName(playerid, Name, MAX_PLAYER_NAME);
                format ( Str, sizeof ( Str ), "{FF0000}[{FFFFFF}%s{FF0000}%s: %s", CheckPrefix(playerid), Name, text);
                SendClientMessageToAll(-1, Str);
                return 0;
        }
Reply
#2

I fixed it but now says only this thing Използвай: /hellixpower [текст]
Reply
#3

Quote:
Originally Posted by HellixBG
Посмотреть сообщение
I fixed it but now says only this thing Използвай: /hellixpower [текст]
Код:
 if ( sscanf ( params, "us", prefix)) return SendClientMessage(playerid, 0xFF0000FF, "Използвай: /hellixpower [текст]");
You are using two specifiers (a string (s) and a playerid/part of name (u)) while your usage says you should be using one. so figure it to your need
Reply
#4

Quote:
Originally Posted by FailerZ
Посмотреть сообщение
Код:
 if ( sscanf ( params, "us", prefix)) return SendClientMessage(playerid, 0xFF0000FF, "Използвай: /hellixpower [текст]");
You are using two specifiers (a string (s) and a playerid/part of name (u)) while your usage says you should be using one. so figure it to your need
So I must change it to just "s" not "us"?
Reply
#5

The specifier of 's' is obviously a string, however the specifier of 'u' is part of name or playerid, then you have 'i', 'd' etc...for other types of variables

I would suggest you to use the specifier of 'u' as it allows players to enter part of a players name and it'll still work.
Код:
Specifier(s)			Name				Example values
	i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42
Reference:
Reply
#6

Quote:
Originally Posted by HellixBG
Посмотреть сообщение
So I must change it to just "s" not "us"?
It is most likely a string tho, But also don't forget to set the cells size near the string in sscanf

Try this:
Код:
if ( sscanf ( params, "s[16]", prefix)) return SendClientMessage(playerid, 0xFF0000FF, "Използвай: /hellixpower [текст]");
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)