SA-MP Forums Archive
sscanf "u" specifier problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: sscanf "u" specifier problem (/showthread.php?tid=427164)



[SOLVED] sscanf "u" specifier problem - SexTourist - 31.03.2013

Hello,

I'm having a problem with sscanf "u" specifier. I did a search before posting this and couldn't find any solutions.

So basically my problem is that I want to use any part of player name to teleport player to me, but I can only use full or first part of the name. For example - I want to use Morgan part of Dexter_Morgan name to teleport him to me, but I can only use Dexter or Dexter_Morgan. What am I doing wrong?

pawn Код:
CMD:get(playerid,params[])
{
    if ( GetPVarInt( playerid, "Level" ) < 1 )
    return SendClientMessage( playerid, -1, "Turite bыti bent "#Level1", kad galлtumлte naudotis рia komanda.");
    new targetid, Float:x, Float:y, Float:z;
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Naudojimas: /get <id/dalis vardo>");
    if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, ""RAUDONA"Юaidлjas neprisijungжs arba vardа raрлte ne nuo priekio.");
    GetPlayerPos(playerid, x, y, z);
    SetPlayerPos(targetid, x, y+0.5, z+0.5);
    return 1;
}
Or isn't specifier "u" the one I need to use?

Any help is appreciated.


Re: sscanf "u" specifier problem - Windrush - 31.03.2013

Use "r" specifier


Re: sscanf "u" specifier problem - SexTourist - 31.03.2013

Thank you for such a quick reply, but that didn't fix the problem.


EDIT:
BTW, this applies to other commands too. For example this:

pawn Код:
CMD:pm(playerid, params[])
{
    new id, string[2][128], message[128];
    if(sscanf(params,"us[128]",id,message)) return SendClientMessage(playerid, -1, "Naudojimas: /pm <id/dalis vardo> <юinutл>");'message'
    if(id == playerid) return SendClientMessage(playerid, -1, "Negalite siшsti юinutж sau.");
    if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, ""RAUDONA"Юaidлjas neprisijungжs arba vardа raрлte ne nuo priekio.");// If the id of the player you want to pm is not connect send a message
    format(string[0], 128, "* PM nusiшsta %s: %s", PlayerName(id), message);
    format(string[1], 128, "* PM gauta iр %s: %s", PlayerName(playerid), message);
    SendClientMessage(playerid, -1, string[0]);
    SendClientMessage(id, -1, string[1]);
    LastPm[id] = playerid;
    return 1;
}



Re: sscanf "u" specifier problem - Dj_maryo1993 - 31.03.2013

pawn Код:
if ( GetPVarInt( playerid, "Level" ) > 1 )
{
        new targetid, Float:x, Float:y, Float:z;
        if(!sscanf(params, "u", targetid))
    {
            if(IsPlayerConnected(targetid))
        {  
            GetPlayerPos(playerid, x, y, z);
                SetPlayerPos(targetid, x, y+0.5, z+0.5);
                return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, ""RAUDONA"Юaidлjas neprisijungжs arba vardа raрлte ne nuo priekio.");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "Naudojimas: /get <id/dalis vardo>");
    }
}
else
{
    SendClientMessage( playerid, -1, "Turite bыti bent "#Level1", kad galлtumлte naudotis рia komanda.");
   
}
Call me old fashion but this looks way better


Re: sscanf "u" specifier problem - SilverKiller - 31.03.2013

Never mind this won't work..


Re: sscanf "u" specifier problem - Babul - 31.03.2013

pawn Код:
SSCANF_Option(MATCH_NAME_PARTIAL, 0);//hm.. not 0, but 1. oops.
...you know where to paste it? ^^


Re: sscanf "u" specifier problem - [ABK]Antonio - 31.03.2013

Quote:
Originally Posted by Dj_maryo1993
Посмотреть сообщение
pawn Код:
if ( GetPVarInt( playerid, "Level" ) > 1 )
{
        new targetid, Float:x, Float:y, Float:z;
        if(!sscanf(params, "u", targetid))
    {
            if(IsPlayerConnected(targetid))
        {  
            GetPlayerPos(playerid, x, y, z);
                SetPlayerPos(targetid, x, y+0.5, z+0.5);
                return 1;
        }
        else
        {
            SendClientMessage(playerid, COLOR_WHITE, ""RAUDONA"Юaidлjas neprisijungжs arba vardа raрлte ne nuo priekio.");
        }
    }
    else
    {
        SendClientMessage(playerid, COLOR_WHITE, "Naudojimas: /get <id/dalis vardo>");
    }
}
else
{
    SendClientMessage( playerid, -1, "Turite bыti bent "#Level1", kad galлtumлte naudotis рia komanda.");
   
}
Call me old fashion but this looks way better
What's old fashion about that?
Tbh, it just looks like extra whitespace & lines to me


Re: sscanf "u" specifier problem - SexTourist - 31.03.2013

Quote:
Originally Posted by Babul
Посмотреть сообщение
pawn Код:
SSCANF_Option(MATCH_NAME_PARTIAL, 0);
...you know where to paste it? ^^
Well... no...
I looked where should I put it, but I guess I'm just too stupid to figure it out by myself.


Re: sscanf "u" specifier problem - Babul - 31.03.2013

it belongs into the OnGameModeInit() or OnFilterScriptInit().
i suggest to use it in the gamemode only. sscanf may handle the settings global i assume - i really should read the whole topic again hehe
add: oh, and put a 1, not a 0. i edited it after you quoted me, so play with the parameters. or best, click this: https://sampforum.blast.hk/showthread.php?tid=120356 and scroll down to the Options-section...


Re: sscanf "u" specifier problem - SexTourist - 31.03.2013

Thank you very much and everyone else who tried to help.

After your post I spent 20 minutes looking where to add that line. Checked that thread and ysi wiki, but no luck, so replied here.