When to use %s, %f or %d?
#1

Hi.

Here, I would like the difference between %s - %f and %d, and most importantly, know when to use which.

Bye
Reply
#2

%s = printing out the name
%d = printing out the numbers
%f = float... printing out float..


%s you can use like in example to print out players name
%d you can use for example to print out phone number
%f you can use for example to print our what is player coordinates !
Reply
#3

I use %d for save the the age of the players, no error in the mysql_log, but in the database it puts the age 0.
But, if I use %s in the database that will be the right age, but in the mysql_log it will say `Age`= no to the number ... help?
Reply
#4

So show me your saving enum.. and show the dialog where do you put in it.
Reply
#5

It's in a update account:
pawn Код:
new Requete[1024];
        format(Requete, sizeof(Requete), "UPDATE lsrp_comptes SET `Age`=%d, `Sex`=%x, `Aspi`=%d, `Skin`=%d, `Cash`=%d WHERE ID=%d",
        Player_infos[playerid][p_Age],
        Player_infos[playerid][p_Sex],
        Player_infos[playerid][p_Aspi],
        Player_infos[playerid][p_Skin],
        Player_infos[playerid][p_Cash],
        Player_infos[playerid][p_Sql_Id]);
        mysql_query(Requete);
        mysql_debug_save(Requete);
And the dialog:

pawn Код:
else if(Player_inscription_etape[playerid] == 3)
        {
            if(strlen(inputtext) == 0)
            {
                ShowPlayerDialog(playerid, PLAYER_DIALOG_INSCRIPTION, DIALOG_STYLE_INPUT, "Choix de l'вge du personnage.", "Entrez l'вge de votre personnage:", "Continuer", "");
                return 1;
            }
            if(strval(inputtext) < 13)
            {
                ShowPlayerDialog(playerid, PLAYER_DIALOG_INSCRIPTION, DIALOG_STYLE_INPUT, "Choix de l'вge du personnage.", "L'вge de votre personnage doit кtre de 13 ans minimum:", "Continuer", "");
                return 1;
            }
            if(strval(inputtext) > 80)
            {
                ShowPlayerDialog(playerid, PLAYER_DIALOG_INSCRIPTION, DIALOG_STYLE_INPUT, "Choix de l'вge du personnage.", "L'вge de votre personnage doit кtre de 80 ans au maximum:", "Continuer", "");
                return 1;
            }
            Player_inscription_age[playerid] = strval(inputtext);
            ShowPlayerDialog(playerid, PLAYER_DIALOG_INSCRIPTION, DIALOG_STYLE_LIST, "Choix du sexe du personnage.", "Homme.\nFemme.", "Continuer", "");
            Player_inscription_etape[playerid] = 5;
        }
Reply
#6

This looks good..How did you set a mysql data base?
Reply
#7

I'm not english, reformulate please?
Reply
#8

Try this:
pawn Код:
Player_infos[playerid][p_Age] = strval(inputtext);
Reply
#9

%s = string
%f = float (0.000 for example)
%d & %i = integer (or whole numbers)
Reply
#10

pawn Код:
new Requete[1024];
        format(Requete, sizeof(Requete), "UPDATE lsrp_comptes SET `Age`=%d, `Sex`=%d, `Aspi`=%d, `Skin`=%d, `Cash`=%d WHERE ID=%d",
        Player_infos[playerid][p_Age] = strval(inputtext),
        Player_infos[playerid][p_Sex] = strval(inputtext),
        Player_infos[playerid][p_Aspi] = strval(inputtext),
        Player_infos[playerid][p_Skin] = strval(inputtext),
        Player_infos[playerid][p_Cash] = strval(inputtext),
        Player_infos[playerid][p_Sql_Id]) = strval(inputtext);
        mysql_query(Requete);
        mysql_debug_save(Requete);
like that?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)