Recover a value[mysql]
#3

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	new query[1024];
    switch(dialogid)
    {
        case 1: //login dialog
        {
            if(!response) Kick(playerid); //if they clicked Quit, we will kick them
            new hpass[129]; //for password hashing
            WP_Hash(hpass, 129, inputtext); //hashing inputtext
            if(!strcmp(hpass, pInfo[playerid][Password])) //remember we have loaded player's password into this variable, pInfo[playerid][Password] earlier. Now let's use it to compare the hashed password with password that we load
            { //if the hashed password matches with the loaded password from database
                mysql_format(mysql, query, sizeof(query), "SELECT * FROM `joueurs` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
                //let's format our query
                //once again, we select all rows in the table that has your name and limit the result
                mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid);
                //lets execute the formatted query and when the execution is done, a callback OnAccountLoad will be called
                //You can name the callback however you like
            }
            else //if the hashed password didn't match with the loaded password(pInfo[playerid][Password])
            {	
                //we tell them that they have inserted a wrong password
                ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Connexion", "Mot de passe ?\nMauvais Mot de passe !", "Connexion", "Quitter");
            }
        }
        case 2: //register dialog
        {
            if(!response) return Kick(playerid); //if they clicked Quit, we will kick them
            if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "S'enregistrer", "Ton mot de passe doit faire plus de 6 caractиres !", "S'enregistrer", "Quitter");
			if(strlen(inputtext) > 24) return ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "S'enregistrer", "Ton mot de passe doit faire moins de 24 caractиres !", "S'enregistrer", "Quitter");
            //strlen checks a lenght of a string. so if player types their password that is lower than 6, we tell them; Your password must be at least 6 characters long!
            WP_Hash(pInfo[playerid][Password], 129, inputtext); //hashing inputtext
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `joueurs` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Argent`, `posX` ,`posY`, `posZ`, `Interieur`, `World`, `Skin`, `Niveau`) VALUES ('%e', '%s', '%s', 0, 0, 1000, 1527.5634, -1738.9218, 13.5469, 0, 0, 26, 1)", Name[playerid], pInfo[playerid][Password], IP[playerid]);
            //Now let's create a new row and insert player's information in it
            mysql_tquery(mysql, query, "", "");
            //let's execute the query^^^^^^
			mysql_format(mysql, query, sizeof(query), "SELECT `posX`, `posY` FROM `joueurs` WHERE `posX` = '%f', `posY` = '%f'", pInfo[playerid][posX], pInfo[playerid][posY]);
			mysql_tquery(mysql, query, "", "");
			printf("%f %f %d %d", pInfo[playerid][posX], pInfo[playerid][posY]);
			SetSpawnInfo( playerid, 0, 26, 1527.5634,-1738.9218,13.5469, 0.0, 0, 0, 0, 0, 0, 0 );
			SetPlayerScore(playerid,pInfo[playerid][Niveau]);
			TogglePlayerSpectating(playerid, 0);
			SpawnPlayer(playerid);
        }
    }


	return 1;
}
If you need the entire code: http://pastebin.com/Rquj7JSf

But with the printf in my console I have "0.00000 0.00000"


It's all I have.


Could you please explain me what's "Please post the complete code where it sends the query and fetches the result with the cache_* functions. "




Thank you !
Reply


Messages In This Thread
Recover a value[mysql] - by anou1 - 13.01.2014, 17:24
Re: Recover a value[mysql] - by maddinat0r - 13.01.2014, 17:42
Re : Recover a value[mysql] - by anou1 - 13.01.2014, 17:56
Re: Recover a value[mysql] - by maddinat0r - 13.01.2014, 18:10
Re : Recover a value[mysql] - by anou1 - 13.01.2014, 18:40
Re: Recover a value[mysql] - by sammp - 13.01.2014, 22:24
Re: Recover a value[mysql] - by anou1 - 13.01.2014, 22:37
Re: Recover a value[mysql] - by anou1 - 14.01.2014, 09:46
Re: Recover a value[mysql] - by sammp - 14.01.2014, 18:10
Re : Recover a value[mysql] - by anou1 - 14.01.2014, 20:46

Forum Jump:


Users browsing this thread: 1 Guest(s)