sscanf problem
#1

Hello,

I've a problem with sscanf, on my dialog I've to type my number with a "." or that d'ont work

pawn Код:
Dialog:Register2(playerid, response, listitem, inputtext[])
{

    if(!response) {
        return Kick(playerid);
    }
    if(isnull(inputtext)) {
        return ShowDialog(playerid, Show:Register2, DIALOG_STYLE_INPUT, "{1564F5}Enregistrement - Вge", "Veuillez entrer l'вge de votre personnage.\n (Entre 13 et 99 ans)", "Valider", "Quitter");
    }
    new str[128];
    if(sscanf(inputtext, "i", str)) {
        PlayerInfo[playerid][pAge] = strval(inputtext);
        printf("%d", PlayerInfo[playerid][pAge]);
        return ShowDialog(playerid, Show:Register3, DIALOG_STYLE_MSGBOX, "{1564F5}Enregistrement - Sexe", "Veuillez choisir le sexe de votre personnage", "Homme", "Femme");
    }
    return ShowDialog(playerid, Show:Register2, DIALOG_STYLE_INPUT, "{1564F5}Enregistrement - Вge", "Veuillez entrer l'вge de votre personnage.\n (Entre 13 et 99 ans)", "Valider", "Quitter");
}

I've an other question, can I limit my integer between 13 and 99 with sscanf ?

Thanks
Reply
#2

i is for integer, and you are trying to capture it in a string. Strval is not neccessary if you use i or d. Also sscanf returns 0 on success, and other values on error. So

pawn Код:
new
    age;
if(!sscanf(inputtext, "i", age)) {
    if(13 <= age <= 99) return SendClientMessage(playerid, -1, "You dun goof'd, age between 13 and 99 must be, Yoda said so");
    PlayerInfo[playerid][pAge] = age;
Reply
#3

Thanks a lot man
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)