sscanf2 MATCH_NAME_PARTIAL
#1

well ok idk but how is this gonna work first how can i make it globally to 1, after that how can we make if the player types uchiha and the name is sasuke_uchiha it will work with making MATCH_NAME_PARTIAL but how to do that if there are 3 online player 1 me and other two Sasuke_uchiha and Itachi_Uchiha if i type uchiha it should say "Uchiha is found in multiple name please be more specific" and i am using specifiers "U".
And Can You make the example with this command
pawn Код:
CMD:jail(playerid,params[])
{
    new TargetID,mins,hours,reason[100], string[256];
    if(pInfo[playerid][Adminlevel] < 5) return SCM(playerid, COLOR_ERROR,""ERROR_MESSAGE"");
    if(!pInfo[playerid][LoggedInAsAdmin]) return SCM(playerid,COLOR_ERROR,""ERROR_MESSAGE"");
    if(caged[TargetID] == 1) return SCM(playerid,COLOR_ERROR,CAGED_ERROR);
    if(sscanf(params, "uI(1)I(30)S()[50]", TargetID,hours,mins,reason)) return SCM(playerid, COLOR_ERROR, "Usage: /jail (Name/ID) (Hours) (Mins) (Reason)");
    if(TargetID == INVALID_PLAYER_ID || !IsPlayerConnected(TargetID )) return SCM(playerid, COLOR_ERROR, ERROR_INVALID_PLAYER);
    if(pInfo[TargetID][Adminlevel] && TargetID != playerid) return SCM(playerid,COLOR_ERROR,"You Can't Use this Command On An Admin");
    if(pInfo[TargetID][Jailed] == 0)
    {
        pInfo[TargetID][pJailHour] =hours;
        pInfo[TargetID][pJailMinute] =mins;
        JailPlayer(TargetID);
        SetPlayerInterior(TargetID,10);
        pInfo[TargetID][Jailed] = 1;
        if(!strlen(reason)) format(string,sizeof(string),">> JAIL: "ORANGE"%s (%d)"ADMIN" (Admin Jail) No Reason Specified",pInfo[TargetID][playername],TargetID);
        else format(string,sizeof(string),">> JAIL: "ORANGE"%s (%d)"ADMIN" (Admin Jail) (reason: %s)",pInfo[TargetID][playername],TargetID,reason);
        SCMA(COLOR_ADMIN,string);
    }
    else
    {
        format(string,sizeof(string),"You have released %s (%d) form jail",pInfo[TargetID][playername],TargetID);
        SCM(playerid,COLOR_SKYBLUE,string);
        SCM(TargetID,COLOR_SKYBLUE,"You have been released from jail by an admin.");
        JailRelease(TargetID);
    }
    return 1;
}
and how can i make multiple sscanf like if we don't enter the the time and just the reason skip it if we want or we can type the time if we want some thing like
pawn Код:
if(sscanf(params, "uI(1)I(30)S()[50]", TargetID,hours,mins,reason))
how can i make that if i use this way it works and if i use this way /jail [playerid] [hour] [minute] [reason] it should work but if u i use /jail [playerid] [reason] this way should work to and here hour and minute are 1:30 (their default values)
Reply
#2

I wouldn't even suggest using the "u" specifier. I posted a help thread the other day about it because it doesn't match names properly.

I would suggest writing your own specifier with "k" instead.
Reply
#3

Quote:
Originally Posted by admiralspeedy
Посмотреть сообщение
I wouldn't even suggest using the "u" specifier. I posted a help thread the other day about it because it doesn't match names properly.

I would suggest writing your own specifier with "k" instead.
The "u" specifier works perfectly fine for me last time I checked.
Reply
#4

Quote:
Originally Posted by nmader
Посмотреть сообщение
The "u" specifier works perfectly fine for me last time I checked.
Same "u" working perfectly but i think i might change to "r" but please now on topic
Reply
#5

like this use these stocks--
pawn Код:
stock Name(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}

stock CkeckUserNum(const text[])
{
new m, i, c;
foreach(Player : i)
{
m = strfind(Name(i), text, true);
if(m != -1) c++;
}
if(m > 1)return true;//more than 1 user
return false;
}

//in the command like this

if(CheckUserNum(PART_OF_NAME_TO_SEARCH))return SendClientMessage(playerid, -1, "{ff0000}More than 1 user found please be more specific");
Reply
#6

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
like this use these stocks--
pawn Код:
stock Name(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
return name;
}

stock CkeckUserNum(const text[])
{
new m, i, c;
foreach(Player : i)
{
m = strfind(Name(i), text, true);
if(m != -1) c++;
}
if(m > 1)return true;//more than 1 user
return false;
}

//in the command like this

if(CheckUserNum(PART_OF_NAME_TO_SEARCH))return SendClientMessage(playerid, -1, "{ff0000}More than 1 user found please be more specific");
but there is feature in sscanf for it already
Reply
#7

https://github.com/Y-Less/sscanf/wiki/Users#user-lists
Reply
#8

Quote:
Originally Posted by ******
Посмотреть сообщение
The only way I can think of doing that is to call "sscanf" twice - once with two "i" specifiers, and then a second time without if the first one fails.
but how twice any example ??
Reply
#9

Quote:
Originally Posted by ******
Посмотреть сообщение
An example would be how you already call it, but do it twice not once.
what do u mean like using ||

Quote:
Originally Posted by AroseKhanNaizi
Посмотреть сообщение
after that how can we make if the player types uchiha and the name is sasuke_uchiha it will work with making MATCH_NAME_PARTIAL but how to do that if there are 3 online player 1 me and other two Sasuke_uchiha and Itachi_Uchiha if i type uchiha it should say "Uchiha is found in multiple name please be more specific"
and what about this ??
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)