PDA

View Full Version : Problem with this command


HellixBG
16/07/2017, 04:25 PM
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;
}

HellixBG
16/07/2017, 04:34 PM
I fixed it but now says only this thing Използвай: /hellixpower [текст]

FailerZ
16/07/2017, 07:40 PM
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

HellixBG
17/07/2017, 10:53 AM
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"?

Tass007
17/07/2017, 11:08 AM
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: (http://forum.sa-mp.com/showthread.php?t=570927)

FailerZ
17/07/2017, 12:12 PM
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 [текст]");