[HELP] As these commands to make the dialogue
#1

Hello, this is my commands:

Код:
CMD:register(playerid, params[])
{
	if(GetPVarInt(playerid, "Logged")) return SendClientMessage(playerid, COLOR_ORANGE, "[*] You're already logged in!");
	if(isnull(params)) return SendClientMessage(playerid, COLOR_ORANGE, "[*] Usage: /register [pass]");
	new Query[320], pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	mysql_real_escape_string(pName, pName);
	format(Query, sizeof Query, "SELECT * FROM `accounts` WHERE `Name` = '%s' LIMIT 1", pName);
	mysql_query(Query);
	mysql_store_result();
	if(mysql_num_rows())
	{
		SendClientMessage(playerid, COLOR_ORANGE, "[*] An account already exists under that name! Use \"/login\" to log in!");
		mysql_free_result();
		return 1;
	}
	mysql_free_result();
	WP_Hash(Query, 129, params);
	new IP[16];
	GetPlayerIp(playerid, IP, 16);
	format(Query, sizeof Query, "INSERT INTO `accounts` (Name, Password, IP, Admin, Money, Score, Kills, Deaths) VALUES ('%s', '%s', '%s', %i, %i, %i, %i, %i)",
	    pName,
	    Query,
	    IP,
	    GetPVarInt(playerid, "Admin"),
	    GetPlayerMoney(playerid),
	    GetPlayerScore(playerid),
	    GetPVarInt(playerid, "Kills"),
	    GetPVarInt(playerid, "Deaths"));
	mysql_query(Query);
	SetPVarInt(playerid, "Logged", 1);
	SendClientMessage(playerid, COLOR_LIMEGREEN, "[*] Succesfully registered and automatically logged in!");
	return 1;
}

CMD:login(playerid, params[])
{
	if(GetPVarInt(playerid, "Logged")) return SendClientMessage(playerid, COLOR_ORANGE, "[*] You're already logged in!");
	if(isnull(params)) return SendClientMessage(playerid, COLOR_ORANGE, "[*] Usage: /login [pass]");
	new Query[256], pName[MAX_PLAYER_NAME];
	GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
	mysql_real_escape_string(pName, pName);
	format(Query, sizeof Query, "SELECT * FROM `accounts` WHERE `Name` = '%s' LIMIT 1", pName);
	mysql_query(Query);
	mysql_store_result();
	if(!mysql_num_rows())
	{
		SendClientMessage(playerid, COLOR_ORANGE, "[*] You're not registered! Use \"/register\" to register an account!");
		mysql_free_result();
		return 1;
	}
	mysql_free_result();
	WP_Hash(Query, 129, params);
	format(Query, sizeof Query, "SELECT * FROM `accounts` WHERE `Name` = '%s' AND `Password` = '%s' LIMIT 1", pName, Query);
	mysql_query(Query);
	mysql_store_result();
	if(!mysql_num_rows())
	{
	    SetPVarInt(playerid, "LoginWarns", GetPVarInt(playerid, "LoginWarns") + 1);
	    if(GetPVarInt(playerid, "LoginWarns") == 3)
	    {
			format(Query, sizeof Query, "[*] %s has been kicked for 3 wrong login attempts!", pName);
			SendClientMessageToAll(COLOR_ROYALBLUE, Query);
			Kick(playerid);
		}
			else
		{
		    format(Query, sizeof Query, "[*] Wrong password! Attempt %i out of 3.", GetPVarInt(playerid, "LoginWarns"));
		    SendClientMessage(playerid, COLOR_ORANGE, Query);
		}
	    return 1;
	}
	mysql_fetch_row(Query);
	new values[5];
	sscanf(Query, "p<|>{s[24]s[129]s[16]}a<i>[5]", values); //Enjoy editing.
	SetPVarInt(playerid, "Admin", values[0]);
	GivePlayerMoney(playerid, values[1]);
	SetPlayerScore(playerid, values[2]);
	SetPVarInt(playerid, "Kills", values[3]);
	SetPVarInt(playerid, "Deaths", values[4]);
	mysql_free_result();
	SetPVarInt(playerid, "Logged", 1);
	SendClientMessage(playerid, COLOR_LIMEGREEN, "[*] Succesfully logged in!");

	    //Ip setting
	GetPlayerIp(playerid, Query, 16);
	format(Query, sizeof Query, "UPDATE `accounts` SET `IP` = '%s' WHERE `Name` = '%s' LIMIT 1", Query, pName);
	mysql_query(Query);
	return 1;
}
how to make this commands dialog based ?
Reply
#2

please help!
Reply
#3

bump! help meeeee please
Reply
#4

I don't know a lot about mysql so, I can't help.. sorry.. I replied bcs no one else does.. xD
I Hope someone can help you..
Reply
#5

Quote:
Originally Posted by [SFA]SpiRRiT
Посмотреть сообщение
I don't know a lot about mysql so, I can't help.. sorry.. I replied bcs no one else does.. xD
I Hope someone can help you..
What does this have to do with Mysql?

@ mariomako learn how to use dialogs first.
Then heres a tip: Cut the code (or most of it) out of the commands, and replace it with showing an input dialog. Paste the code you cut from the command in the respective dialog response block.

EDIT: I know this might not seem usefull to you but, if you learn how to use dialogs you wouldn't even need help.
Reply
#6

Quote:
Originally Posted by iggy1
Посмотреть сообщение
What does this have to do with Mysql?

@ mariomako learn how to use dialogs first.
Then heres a tip: Cut the code (or most of it) out of the commands, and replace it with showing an input dialog. Paste the code you cut from the command in the respective dialog response block.

EDIT: I know this might not seem usefull to you but, if you learn how to use dialogs you wouldn't even need help.
However I need this urgent, please god as you do this: (: (
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)