SA-MP Forums Archive
sscanf 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 problem (/showthread.php?tid=462322)



sscanf problem - PakPak - 06.09.2013

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


Re: sscanf problem - Misiur - 06.09.2013

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;



Re: sscanf problem - PakPak - 06.09.2013

Thanks a lot man