SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 15/04/2016, 11:35 PM   #161
Celirius
Little Clucker
 
Join Date: Dec 2015
Location: Inside.
Posts: 1
Reputation: 0
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Thanks for this tutorial, it helped me a lot.
Celirius is offline   Reply With Quote
Old 26/12/2016, 07:31 PM   #162
BennyX
Little Clucker
 
Join Date: Nov 2016
Posts: 6
Reputation: 0
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

doesn't show the dialogs
BennyX is offline   Reply With Quote
Old 22/10/2019, 05:07 AM   #163
PlayHard
Huge Clucker
 
PlayHard's Avatar
 
Join Date: Nov 2011
Location: In an apartment
Posts: 216
Reputation: 22
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Quote:
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(53) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(54) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(72) : error 017: undefined symbol "cache_get_data"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(75) : error 017: undefined symbol "cache_get_field_content"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(77) : error 017: undefined symbol "cache_get_field_content_int"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(71) : warning 203: symbol is never used: "fields"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(94) : error 017: undefined symbol "cache_get_field_content_int"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(95) : error 017: undefined symbol "cache_get_field_content_int"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(96) : error 017: undefined symbol "cache_get_field_content_int"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(97) : error 017: undefined symbol "cache_get_field_content_float"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(9 : error 017: undefined symbol "cache_get_field_content_float"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(99) : error 017: undefined symbol "cache_get_field_content_float"
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(127) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(131) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(143) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(145) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(321) : warning 217: loose indentation
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(322) : warning 217: loose indentation
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(325) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(32 : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(343) : warning 217: loose indentation
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(344) : warning 217: loose indentation
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(345) : warning 213: tag mismatch
C:\Users\user\Desktop\Ehab's\03DLR1\gamemodes\MYSQ LGM.pwn(347) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase


9 Errors.
Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <a_mysql>

//Definitions:
#define host    "localhost" //MySQL Host, Default for XAMPP is localhost
#define user    "root" //MySQL Username, // // // is root
#define db      "server" //Database name
#define pass    "" //MySQL pass in XAMPP

#define dregister   6287 //Dialog Register ID
#define dlogin      6288 // ^

//Global Variables
static
	mysql, //This variable will manage our databse
	Name[MAX_PLAYERS][24], //To store a player's name
	IP[MAX_PLAYERS]
	;
//Natives
native WP_Hash(buffer[], len, const str[]); //whirlpool, for hashing our password
//Enums
enum PDATA //We name our enumerator as PDATA (which stands for PlayerDATA). You can name it however you want.
{
    ID, //Will be used later to store player's ID from database so we can use it anywhere later
    Password[129], //We will load player's password into this varible from database
    Admin, //We will load player's admin level from database into this variable so we can use it anywhere later.
    VIP, //We will load player's VIP level from database into this variable so we can use it anywhere later.
    Money, //We will load player's money from database into this variable so we can use it anywhere later.
    Float:posX, //We will load player's X position from database into this variable so we can use it anywhere later.
    Float:posY, //We will load player's Y position from database into this variable so we can use it anywhere later.
    Float:posZ //We will load player's Z from database into this variable so we can use it anywhere later.

}
new pInfo[MAX_PLAYERS][PDATA]; //Variable that stores enumerator above

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}


public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
 	//mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); //Let's enable debugging so we can detect a problem(if there is)
    mysql = mysql_connect(host, user, db, pass); //This function will connect your server to database. Remember we have defined our host, username, database and password. It's time to use it here.
    if(mysql_errno(mysql) != 0) print("Could not connect to database!"); //This will tell if your connection to database is successful or not. If it's not, check your host, username, database and password. Make sure they all right.

	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

//OnAccountCheck is a custom callback which means it has to be forwarded.
forward OnAccountCheck(playerid);

//Now once the query has been processed;
public OnAccountCheck(playerid)
{
    new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
    cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
    if(rows) //if there is row
    {//then
        cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
        //we will load player's password into pInfo[playerid][Password] to be used in logging in
        pInfo[playerid][ID] = cache_get_field_content_int(0, "ID"); //now let's load player's ID into pInfo[playerid][ID] so we can use it later
        printf("%s", pInfo[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password
        ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
    }
    else //if we didn't find any rows from the database, that means, no accounts were found
    {
        ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
        //So we show them a dialog register
    }
    return 1;
}

forward OnAccountLoad(playerid);
forward OnAccountRegister(playerid);
//let's load player's information
public OnAccountLoad(playerid)
{
    pInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
    pInfo[playerid][VIP] = cache_get_field_content_int(0, "VIP"); //Above
    pInfo[playerid][Money] = cache_get_field_content_int(0, "Money");//Above
    pInfo[playerid][posX] = cache_get_field_content_float(0, "PosX");//Above. Since player's position is a float, we use cache_get_field_content_float
    pInfo[playerid][posY] = cache_get_field_content_float(0, "PosY");//Above
    pInfo[playerid][posZ] = cache_get_field_content_float(0, "PosZ");//Above

    GivePlayerMoney(playerid, pInfo[playerid][Money]);//Let's set their money
    //For player's position, set it once they spawn(OnPlayerSpawn)
    SendClientMessage(playerid, -1, "Successfully logged in"); //tell them that they have successfully logged in
    return 1;
}

public OnAccountRegister(playerid)
{
    pInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
    printf("New account registered. ID: %d", pInfo[playerid][ID]); //just for debugging.
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
    new query[128]; //We use this variable to format our query
    GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
    GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP
    mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
    // - We use mysql_format instead of format because we can use an %e specifier. %e specifier escapes a string so we can avoid sql injection which means we don't have to use mysql_real_escape_string
    // - Formatting our query; SELECT `Password`, `ID` FROM `players` WHERE `Username`='%e' means we are selecting a Password and ID's column in the table that has player's name in Username column.
    // - LIMIT 1; we only need 1 result to be shown
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    //lets execute the formatted query and when the execution is done, a callback OnAccountCheck will be called
    //You can name the callback however you like

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new query[128], Float:pos[3]; //query[128] is for formatting our query and Float:pos[3] is for getting and saving player's position
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]); //let's get player's position when they leave your server
    mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f WHERE `ID`=%d",\
    pInfo[playerid][Admin], pInfo[playerid][VIP], pInfo[playerid][Money], pos[0], pos[1], pos[2], pInfo[playerid][ID]);
    //We update the table(`players`) by getting player's admin level, vip level, money, and positions and save them in the database
    mysql_tquery(mysql, query, "", "");
    //let's execute the query.
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posZ], pInfo[playerid][posZ]);
    //Set player's position to the last saved position.
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

//Now let's response to the login and register dialog
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case dlogin: //login dialog
        {
            if(!response) Kick(playerid); //if they clicked Quit, we will kick them
            new hpass[129]; //for password hashing
        new query[100]; // for formatting our query.
            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 `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
                //let's format our query
                //We select all rows in the table that has your name and limit the result to 1
                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, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login\nWrong password!", "Login", "Quit");
            }
        }
        case dregister: //register dialog
        {
            if(!response) return Kick(playerid); //if they clicked Quit, we will kick them
            if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
            //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!
                new query[300];
            WP_Hash(pInfo[playerid][Password], 129, inputtext); //hashing inputtext
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0)", 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, "OnAccountRegister", "i", playerid);
            //let's execute the query
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
PlayHard is offline   Reply With Quote
Old 22/10/2019, 05:54 AM   #164
SiaReyes
Huge Clucker
 
SiaReyes's Avatar
 
Join Date: Mar 2019
Location: Coordinates X,Y,Z
Posts: 323
Reputation: 22
Default Re: MySQL Registration System [Threaded Queries(R33+) + Whirlpool]

Quote:
Originally Posted by PlayHard View Post
Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>
#include <a_mysql>

//Definitions:
#define host    "localhost" //MySQL Host, Default for XAMPP is localhost
#define user    "root" //MySQL Username, // // // is root
#define db      "server" //Database name
#define pass    "" //MySQL pass in XAMPP

#define dregister   6287 //Dialog Register ID
#define dlogin      6288 // ^

//Global Variables
static
	mysql, //This variable will manage our databse
	Name[MAX_PLAYERS][24], //To store a player's name
	IP[MAX_PLAYERS]
	;
//Natives
native WP_Hash(buffer[], len, const str[]); //whirlpool, for hashing our password
//Enums
enum PDATA //We name our enumerator as PDATA (which stands for PlayerDATA). You can name it however you want.
{
    ID, //Will be used later to store player's ID from database so we can use it anywhere later
    Password[129], //We will load player's password into this varible from database
    Admin, //We will load player's admin level from database into this variable so we can use it anywhere later.
    VIP, //We will load player's VIP level from database into this variable so we can use it anywhere later.
    Money, //We will load player's money from database into this variable so we can use it anywhere later.
    Float:posX, //We will load player's X position from database into this variable so we can use it anywhere later.
    Float:posY, //We will load player's Y position from database into this variable so we can use it anywhere later.
    Float:posZ //We will load player's Z from database into this variable so we can use it anywhere later.

}
new pInfo[MAX_PLAYERS][PDATA]; //Variable that stores enumerator above

main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}


public OnGameModeInit()
{
	// Don't use these lines if it's a filterscript
	SetGameModeText("Blank Script");
 	//mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); //Let's enable debugging so we can detect a problem(if there is)
    mysql = mysql_connect(host, user, db, pass); //This function will connect your server to database. Remember we have defined our host, username, database and password. It's time to use it here.
    if(mysql_errno(mysql) != 0) print("Could not connect to database!"); //This will tell if your connection to database is successful or not. If it's not, check your host, username, database and password. Make sure they all right.

	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnGameModeExit()
{
	return 1;
}

//OnAccountCheck is a custom callback which means it has to be forwarded.
forward OnAccountCheck(playerid);

//Now once the query has been processed;
public OnAccountCheck(playerid)
{
    new rows, fields; //a variable that will be used to retrieve rows and fields in the database.
    cache_get_data(rows, fields, mysql);//let's get the rows and fields from the database.
    if(rows) //if there is row
    {//then
        cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
        //we will load player's password into pInfo[playerid][Password] to be used in logging in
        pInfo[playerid][ID] = cache_get_field_content_int(0, "ID"); //now let's load player's ID into pInfo[playerid][ID] so we can use it later
        printf("%s", pInfo[playerid][Password]); //OPTIONAL: Just for debugging. If it didn't show your password, then there must be something wrong while getting player's password
        ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit"); //And since we found a result from the database, which means, there is an account; we will show a login dialog
    }
    else //if we didn't find any rows from the database, that means, no accounts were found
    {
        ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
        //So we show them a dialog register
    }
    return 1;
}

forward OnAccountLoad(playerid);
forward OnAccountRegister(playerid);
//let's load player's information
public OnAccountLoad(playerid)
{
    pInfo[playerid][Admin] = cache_get_field_content_int(0, "Admin"); //we're getting a field 4 from row 0. And since it's an integer, we use cache_get_row_int
    pInfo[playerid][VIP] = cache_get_field_content_int(0, "VIP"); //Above
    pInfo[playerid][Money] = cache_get_field_content_int(0, "Money");//Above
    pInfo[playerid][posX] = cache_get_field_content_float(0, "PosX");//Above. Since player's position is a float, we use cache_get_field_content_float
    pInfo[playerid][posY] = cache_get_field_content_float(0, "PosY");//Above
    pInfo[playerid][posZ] = cache_get_field_content_float(0, "PosZ");//Above

    GivePlayerMoney(playerid, pInfo[playerid][Money]);//Let's set their money
    //For player's position, set it once they spawn(OnPlayerSpawn)
    SendClientMessage(playerid, -1, "Successfully logged in"); //tell them that they have successfully logged in
    return 1;
}

public OnAccountRegister(playerid)
{
    pInfo[playerid][ID] = cache_insert_id(); //loads the ID of the player in the variable once they registered.
    printf("New account registered. ID: %d", pInfo[playerid][ID]); //just for debugging.
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerConnect(playerid)
{
    new query[128]; //We use this variable to format our query
    GetPlayerName(playerid, Name[playerid], 24); //Getting player's name
    GetPlayerIp(playerid, IP[playerid], 16); //Getting layer's IP
    mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
    // - We use mysql_format instead of format because we can use an %e specifier. %e specifier escapes a string so we can avoid sql injection which means we don't have to use mysql_real_escape_string
    // - Formatting our query; SELECT `Password`, `ID` FROM `players` WHERE `Username`='%e' means we are selecting a Password and ID's column in the table that has player's name in Username column.
    // - LIMIT 1; we only need 1 result to be shown
    mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
    //lets execute the formatted query and when the execution is done, a callback OnAccountCheck will be called
    //You can name the callback however you like

    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    new query[128], Float:pos[3]; //query[128] is for formatting our query and Float:pos[3] is for getting and saving player's position
    GetPlayerPos(playerid, pos[0], pos[1], pos[2]); //let's get player's position when they leave your server
    mysql_format(mysql, query, sizeof(query), "UPDATE `players` SET `Admin`=%d, `VIP`=%d, `Money`=%d, `posX`=%f, `posY`=%f, `posZ`=%f WHERE `ID`=%d",\
    pInfo[playerid][Admin], pInfo[playerid][VIP], pInfo[playerid][Money], pos[0], pos[1], pos[2], pInfo[playerid][ID]);
    //We update the table(`players`) by getting player's admin level, vip level, money, and positions and save them in the database
    mysql_tquery(mysql, query, "", "");
    //let's execute the query.
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, pInfo[playerid][posX], pInfo[playerid][posZ], pInfo[playerid][posZ]);
    //Set player's position to the last saved position.
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
	return 1;
}

public OnVehicleSpawn(vehicleid)
{
	return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
	return 1;
}

public OnPlayerText(playerid, text[])
{
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if (strcmp("/mycommand", cmdtext, true, 10) == 0)
	{
		// Do something here
		return 1;
	}
	return 0;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
	return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
	return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
	return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
	return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
	return 1;
}

public OnRconCommand(cmd[])
{
	return 1;
}

public OnPlayerRequestSpawn(playerid)
{
	return 1;
}

public OnObjectMoved(objectid)
{
	return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
	return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
	return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
	return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
	return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
	return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
	return 1;
}

public OnPlayerExitedMenu(playerid)
{
	return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
	return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
	return 1;
}

public OnPlayerUpdate(playerid)
{
	return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
	return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
	return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
	return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
	return 1;
}

//Now let's response to the login and register dialog
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    switch(dialogid)
    {
        case dlogin: //login dialog
        {
            if(!response) Kick(playerid); //if they clicked Quit, we will kick them
            new hpass[129]; //for password hashing
        new query[100]; // for formatting our query.
            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 `players` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
                //let's format our query
                //We select all rows in the table that has your name and limit the result to 1
                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, dlogin, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login\nWrong password!", "Login", "Quit");
            }
        }
        case dregister: //register dialog
        {
            if(!response) return Kick(playerid); //if they clicked Quit, we will kick them
            if(strlen(inputtext) < 6) return ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.\nYour password must be at least 6 characters long!", "Register", "Quit");
            //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!
                new query[300];
            WP_Hash(pInfo[playerid][Password], 129, inputtext); //hashing inputtext
            mysql_format(mysql, query, sizeof(query), "INSERT INTO `players` (`Username`, `Password`, `IP`, `Admin`, `VIP`, `Money`, `PosX` ,`PosY`, `PosZ`) VALUES ('%e', '%s', '%s', 0, 0, 0, 0.0, 0.0, 0.0)", 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, "OnAccountRegister", "i", playerid);
            //let's execute the query
        }
    }
    return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
	return 1;
}
It's a old script dude, better use newer versions script (https://forum.sa-mp.com/showthread.php?t=627520)
__________________
Offshowtime Fuck It!

Quote:
Originally Posted by Toroi View Post
blackmail people that join your server using their ip address as hostage

or get a job and play sa-mp for fun
SiaReyes is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Baffled - mySQL Vehicle Loading (threaded queries) Moglizorz. Server Support 0 18/05/2013 02:14 AM
Comparing password [MySQL Threaded queries] emokidx Scripting Help 3 02/04/2013 01:07 PM
MySQL Threaded Queries CONTROLA Scripting Help 4 25/11/2012 04:02 PM
Threaded Queries - BlueG's MYSQL Plugin R7 Ballu Miaa Scripting Help 3 05/11/2012 06:36 PM
[Help] BlueG's MySQL Plugin R7 - Threaded Queries Maxips2 Scripting Help 4 19/10/2012 10:35 AM


All times are GMT. The time now is 06:52 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.