sscanf special characters
#1

Since i need special characters in sscanf commands, how could I use them?
I've seen something like this.

ь = y
х = 6
ц = 8
д = 2
Reply
#2

Код:
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
Copied from here: https://sampforum.blast.hk/showthread.php?tid=120356
Reply
#3

Well, lets say I have a command /tццta, in GM it's /t88ta, but how I could use /tццta InGame?
Reply
#4

Quote:
Originally Posted by King Ace
Посмотреть сообщение
Well, lets say I have a command /tццta, in GM it's /t88ta, but how I could use /tццta InGame?
/t88ta ?
/t88ta <playerid> ?
i cant really understand. what is t88ta ? o.O
Reply
#5

As far as I know, you can't use these characters in the script, but only inside a string as a message.
Reply
#6

Quote:
Originally Posted by Devilxz97
Посмотреть сообщение
/t88ta ?
/t88ta <playerid> ?
i cant really understand. what is t88ta ? o.O
This is an example. Ingame I can use this only as /kontrolliv88d, but instead I would like to use it as /kontrollivццd. And yes, it is possible.
PHP код:
CMD:kontrolliv88d(playeridparams[])
{
    new 
otherId;
    if(
sscanf(params"u"otherId)) return SendClientMessage(playeridCOLOR_GREY"KASUTUS: /kontrollivццd [MдngijaID]");
    if(
otherId == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_GREY"Mдngijat ei ole serveris");
    if(
GetPlayerState(otherId) == PLAYER_STATE_ONFOOT) return SendClientMessage(playerid,COLOR_GREY,"See mдngija ei istu ьldse autos.");
    if(
IsACop(playerid))
    {
        if(
ProxDetectorS(9.0playeridotherId))
        {
            new 
silo[86];
            if(
KasutajaInfo[otherId][pSeatbelt]== 0)
            {
                
silo "lahti";
            }
            else if(
KasutajaInfo[otherId][pSeatbelt] == 1)
            {
                
silo "kinni";
            }
            
SFM(playeridCOLOR_GREY"%s turvavцц on %s."Nimi(otherId), silo);
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY"See mдngija ei ole su juures!");
        }
    }
    else
    {
        
SendClientMessage(playerid,COLOR_GREY"Sa ei ole Politseinik!");
    }
    return 
1;

Reply
#7

Since writing "CMD:kontrollivццd" causes compiler errors, you probably have to run a few string comparisons in the callback fired by zcmd after a command has been entered.

Simply do
pawn Код:
if(!strcmp(cmdtext, "/kontrollivццd", true))
{
    cmd_kontrolliv88d(playerid, params);
}
Lihtne

By the way, kontrollivццd means "check the belt" or in our context, "check the seatbelt".
Reply
#8

Since there are A LOT of commands like this, there needs to be an easyer way. If I'm right, should me defining something in the .inc.
Reply
#9

Perhaps go through the ZCMD topic to see if the issue about special characters has been gone over before.

If not, I could suggest another method: automatic parsing of command input so you don't need to run string comparisons for each of your commands.

1. Use the callback which is fired after the server tries to execute, but does not succeed. I think the callback should be OnPlayerCommandPerformed(playerid, cmdtext[], success).
2. See if the command was not performed successfully. If it wasn't, continue.
3. Replace all "х"-s with 8 for example using a loop.
pawn Код:
if(!success)
{
    for(new i = 0, j = strlen(cmdtext); i != j; i++)
    {
        if(cmdtext[i] == 'х') cmdtext[i] = '8';
        else if(cmdtext[i] == 'ь') cmdtext[i] = 'y';
    }
}
4. Re-run the command using CallLocalFunction similarly to the way zcmd does it.

Perhaps this would be a way to solve it in a bit better fashion rather than comparing for each command. This would probably be better at a large amount of commands performance-wise as well.

Maybe I'm overcomplicating this, though.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)