#1

How to save IP into mysql database

I have pInfo IP. And SaveAccount function where all things are saved into mysql.
So , What should I use?
Varchar, Int ? Lengh ? %d or %s ?
Reply
#2

Quote:
Originally Posted by NewbBeginner
Посмотреть сообщение
How to save IP into mysql database

I have pInfo IP. And SaveAccount function where all things are saved into mysql.
So , What should I use?
Varchar, Int ? Lengh ? %d or %s ?
You should use a string size of 17, "varchar" in the database and '%s' for the query format. I tried using "int" and '%d', but it just doesn't work so use '%s'.
Reply
#3

Код:
new plrIP[16];
PlayerInfo[playerid][pIP] = GetPlayerIp(playerid, plrIP, sizeof(plrIP));
Код:
UPDATE blabla, IP='%s' WHERE Name='%s'",
Varchar , 17

Still doesnt save :S
Reply
#4

Help please, I must fix it.
Reply
#5

You don't get the whole "GetPlayerIp" function, do you?

pawn Код:
new Query[128], pIP[17], pName[23];
GetPlayerIp(playerid, pIP, sizeof(pIP));
GetPlayerName(playerid, pName, sizeof(pName));

format(Query, sizeof(Query), "UPDATE `Accounts` SET `PlayerIP` = '%s' WHERE `Username` = '%s'", pIP, pName);
mysql_query(Query);
Reply
#6

And now autologin function .

I started to make it, but something is wrong, please help me.

Код:
	new ConnectIP[16];
	GetPlayerIp(playerid, ConnectIP, sizeof(ConnectIP));
	
	if(ConnectIP == PlayerInfo[playerid][pIP]) {
	LoginPlayer(playerid);
	{
	else(AccountExists[playerid] == 1)
        {
	ShowPlayerDialog(playerid, LOGIND, DIALOG_STYLE_INPUT, "Login", "Please insert password to login", "Login", "Cancel");
	}
   	else
	{
	SendClientMessage(playerid, COLOR_ORANGE, "Registred");
	ShowPlayerDialog(playerid, REGISTERD, DIALOG_STYLE_INPUT, " Register", "Please insert password to register an account", "Register", "Cancel");
	}
Reply
#7

I think you messed up an else, if else, if statement.

pawn Код:
new ConnectIP[16];
GetPlayerIp(playerid, ConnectIP, sizeof(ConnectIP));
if(ConnectIP == PlayerInfo[playerid][pIP]) LoginPlayer(playerid);
else if(AccountExists[playerid] == 1) ShowPlayerDialog(playerid, LOGIND, DIALOG_STYLE_INPUT, "Login", "Please insert password to login", "Login", "Cancel");
else SendClientMessage(playerid, COLOR_ORANGE, "Registred"),
ShowPlayerDialog(playerid, REGISTERD, DIALOG_STYLE_INPUT, " Register", "Please insert password to register an account", "Register", "Cancel");
Reply
#8

Код:
(2334) : error 033: array must be indexed (variable "ConnectIP")
(2334) : warning 202: number of arguments does not match definition
(2343) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Код:
2334: if(ConnectIP == PlayerInfo[playerid][pIP]) LoginPlayer(playerid);
Код:
	ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", "Please insert password to login", "Login", "Cancel");
	{
	else // 2343
 	}
	SendClientMessage(playerid, COLOR_ORANGE, "------------------------------------------------------");
Reply
#9

Quote:
Originally Posted by NewbBeginner
Посмотреть сообщение
Код:
(2334) : error 033: array must be indexed (variable "ConnectIP")
(2334) : warning 202: number of arguments does not match definition
(2343) : error 029: invalid expression, assumed zero
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Код:
2334: if(ConnectIP == PlayerInfo[playerid][pIP]) LoginPlayer(playerid);
Код:
	ShowPlayerDialog(playerid, LOGIN, DIALOG_STYLE_INPUT, "Login", "Please insert password to login", "Login", "Cancel");
	{
	else // 2343
 	}
	SendClientMessage(playerid, COLOR_ORANGE, "------------------------------------------------------");
I believe you need to use strcmp to compare the "ConnectIP" to the players saved IP. As for the else statement, not sure...
Reply
#10

What should I do then ? Please HELP !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)