Raised This Month: $51 Target: $400
 12% 

I have a problem with my login/register system.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StanCatalin
New Member
Join Date: Apr 2019
Old 04-24-2019 , 15:40   I have a problem with my login/register system.
Reply With Quote #1

Exactly text-boxes won't show.
// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT
#include <a_samp>
#include <a_mysql>
#include <easyDialog>
#define host "localhost"
#define db "samp"
#define user "root"
#define pass ""
enum
{
DIALOG_LOGIN,
DIALOG_REGISTER
};
enum pinfo
{
id,
passw[129],
name[30],
money,
level
};
new PData[MAX_PLAYERS][pinfo];
new playername[MAX_PLAYERS][30];
new MySQL:dbhandle;
new PlayerIP[MAX_PLAYERS][17];
forward OnPlayerLogin(playerid);
forward SavePlayer(playerid);
forward RegisterPlayer(playerid);
forward LoadPlayer(playerid);
native WP_Hash(buffer[], len, const str[]);
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
return 1;
}
#else
main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}
#endif
public OnGameModeInit()
{
// Don't use these lines if it's a filterscript
mysql_log(ALL);
dbhandle = mysql_connect(host,user,pass,db);
if (dbhandle == MYSQL_INVALID_HANDLE || mysql_errno(dbhandle) != 0)
{
print("MySQL connection failed. Server is shutting down."); // Read below
SendRconCommand("exit"); // close the server if there is no connection
return 1;
}
print("eokboss\n");
SetGameModeText("Blank Script");
return 1;
}
public OnGameModeExit()
{
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 OnPlayerLogin(playerid)
{
new rows,string[150];
cache_get_row_count(rows);
if (rows)
{
cache_get_value_name(0, "password", PData[playerid][passw], 129); // Load the player's password
cache_get_value_name_int(0, "id", PData[playerid][id]);
format(string,sizeof(string),"Welcome back to the server.\nPlease type your password below to login to your account.");
Dialog_Show(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login", string, "Login", "Exit");
}
else
{
format(string, sizeof(string), "Welcome to our server.\nIf you want to play here, you must register an account. Type a strong password below to register.");
Dialog_Show(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Register", string, "Register", "Exit");
}
}
public OnPlayerConnect(playerid)
{
new query[140];
GetPlayerName(playerid,playername[playerid],30);
GetPlayerIp(playerid, PlayerIP[playerid], 16);
mysql_format(dbhandle,query,sizeof(query),"SE LECT 'password','Id' FROM 'user' WHERE 'username' = '%e' LIMIT 0, 1",playername[playerid]);
mysql_tquery(dbhandle,query,"OnPlayerLogin", "i", playerid);
return 1;
}
public OnPlayerDisconnect(playerid, reason)
{
SavePlayer(playerid);
return 1;
}
public SavePlayer(playerid)
{
new query[140];
mysql_format(dbhandle, query, sizeof(query), "UPDATE `user` SET `cash` = '%d' WHERE `ID` = '%d'", PData[playerid][money], PData[playerid][id]);
mysql_tquery(dbhandle,query);
}
public RegisterPlayer(playerid)
{
PData[playerid][id] = cache_insert_id();
printf("A new account with the id of %d has been registered!", PData[playerid][id]); // You can remove this if you want, I just used it to debug.
return 1;
}
public LoadPlayer(playerid)
{
cache_get_value_name_int(0, "cash", PData[playerid][money]);
GivePlayerMoney(playerid,PData[playerid][money]); //Load the player's cash and give it to them.
return 1;
}
DialogIALOG_LOGIN(playerid,response,listite m,inputtext[])
{
if(!response) return Kick(playerid);
new password[129], query[100];
WP_Hash(password, 129, inputtext);
if(!strcmp(password, PData[playerid][passw]))
{
mysql_format(dbhandle, query, sizeof(query), "SELECT * FROM `user` WHERE `username` = '%e' LIMIT 0, 1", playername[playerid]);
mysql_tquery(dbhandle, query, "LoadPlayer", "i", playerid);
}
else
{
Dialog_Show(playerid,DIALOG_LOGIN,DIALOG_STYL E_PASSWORD,"Login", "{FF0000}Wrong Password!\n{FFFFFF}Type your correct password below to continue and sign in to your account", "Login", "Exit");
}
return 1;
}
DialogIALOG_REGISTER(playerid,response,list item,inputtext[])
{
if (!response) return Kick(playerid);
if (strlen(inputtext) < 3) return Dialog_Show(playerid,DIALOG_REGISTER,DIALOG_S TYLE_PASSWORD,"Register", "{FF0000}Short Password!\n{FFFFFF}Type a 3+ characters password if you want to register and play on this server", "Register", "Exit");
new query[300];
WP_Hash(PData[playerid][passw], 129, inputtext);
mysql_format(dbhandle, query, sizeof(query), "INSERT INTO `user` (`username`, `password`, `level`, `cash`, `admin`, `ip` , `vip`) VALUES ('%e', '%e', 0, 0, 0,'%e', 0)", playername[playerid], PData[playerid][passw], PlayerIP[playerid]);
mysql_pquery(dbhandle, query, "RegisterPlayer", "i", playerid);
return 1;
}
StanCatalin is offline
CliptonHeist
Senior Member
Join Date: Feb 2016
Old 04-24-2019 , 17:55   Re: I have a problem with my login/register system.
Reply With Quote #2

idk how you get from samp to sourcemod but good job
CliptonHeist is offline
cristian20042
AlliedModders Donor
Join Date: Jun 2016
Location: Romania
Old 04-24-2019 , 19:41   Re: I have a problem with my login/register system.
Reply With Quote #3

Even tough SA:MP uses PAWN (same as sourcemod) this is still not the place for this. And you also didn't even put your code properly.
__________________
Steam - https://steamcommunity.com/id/sniperheroofficialu/
Discord - SniperHero#8545
cristian20042 is offline
Reply



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

Forum Jump


All times are GMT -4. The time now is 20:33.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode