SA-MP Forums Archive
Mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Mysql (/showthread.php?tid=191280)



Mysql - NewbBeginner - 18.11.2010

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 ?


Re: Mysql - Scenario - 18.11.2010

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'.


Re: Mysql - NewbBeginner - 18.11.2010

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

Still doesnt save :S


Re: Mysql - NewbBeginner - 18.11.2010

Help please, I must fix it.


Re: Mysql - Scenario - 18.11.2010

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);



Re: Mysql - NewbBeginner - 18.11.2010

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");
	}



Re: Mysql - Scenario - 18.11.2010

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");



Re: Mysql - NewbBeginner - 18.11.2010

Код:
(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, "------------------------------------------------------");



Re: Mysql - Scenario - 18.11.2010

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...


Re: Mysql - NewbBeginner - 18.11.2010

What should I do then ? Please HELP !