20.09.2013, 18:27
Hola chicos estaba editando un fs de lorec_ que la verda apenas estoy iniciando en sql y bien quisiera saber como puedo add un script de autologin.
Esta parte crea la base de datos.
Y bien esta la parte donde debo de crear el autologin pero no tengo ni idea de como, intente hacer igual q y_ini, pero ni sirbio :/
en y_ini lo tengo asi pero lo logro igualarlo en sql ._., ayudenme para igualarlo en sql :/ pls
Esta parte crea la base de datos.
pawn Код:
public OnFilterScriptInit()
{
print("\nLorencRegister System ( VERSION "#FILE_VERSION" )\n");
Database = db_open("ServerDatabase.db");
db_query(Database, "CREATE TABLE IF NOT EXISTS `USERS` (`NAME`, `PASSWORD`, `IP`, `SCORE`, `CASH`, `ADMINLEVEL`)");
return 1;
}
Y bien esta la parte donde debo de crear el autologin pero no tengo ni idea de como, intente hacer igual q y_ini, pero ni sirbio :/
en y_ini lo tengo asi pero lo logro igualarlo en sql ._., ayudenme para igualarlo en sql :/ pls
pawn Код:
public OnPlayerConnect(playerid)
{
pLogged[playerid] = 0;
#if defined AUTOLOGIN
new tmpIP[16];
GetPlayerIp(playerid,tmpIP,sizeof(tmpIP)); //Getting IP
#endif
if(fexist(PlayerPath(playerid))) {
INI_ParseFile(PlayerPath(playerid), "UserDataLoad_%s", .bExtra = true, .extra = playerid); //Calling loading callback
#if defined AUTOLOGIN
if(strcmp(tmpIP,pIP[playerid],true) == 0) { //Checking if the IPs match
pLogged[playerid] = 1;
SetPlayerScore(playerid,pInfo[playerid][Score]);
GivePlayerMoney(playerid,pInfo[playerid][Cash]);
SendClientMessage(playerid,lime,"You've been auto-logged in. [IP match]");
return 1;
}
#endif
ShowPlayerDialog(playerid,DIALOG_LOGIN,DIALOG_STYLE_INPUT,"Login","Please enter your password below.","Login","Leave");
} else {
ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_INPUT,"Register","Please register by entering a password below.","Register","Leave");
}
return 1;
}
pawn Код:
public OnPlayerConnect(playerid)
{
new
Query[ 150 ],
DBResult: Result,
name[ MAX_PLAYER_NAME ]
;
GetPlayerName(playerid, name, sizeof(name));
Bit1_Set(g_PlayerLogged, playerid, false);
format(Query, sizeof(Query), "SELECT `NAME` FROM `USERS` WHERE `NAME` = '%s'", DB_Escape(name));
Result = db_query(Database, Query);
if(db_num_rows(Result))
{
format(Query, sizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're registered\n\nPlease log in by inputting your password.", name, playerid);
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "{FFFFFF}Register System", Query, "Login", "Leave");
}
else
{
format(Query, sizeof(Query), "{FFFFFF}Welcome "COL_BLUE"%s(%d){FFFFFF} to the server, you're "COL_RED"not{FFFFFF} registered\n\nPlease log in by inputting your password.", name, playerid);
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "{FFFFFF}Register System", Query, "Register", "Leave");
}
db_free_result(Result);
return 1;
}