17.03.2017, 04:19
So working on a registration system. Problem is when I join my server, it says the account isn't registered, which is good because it isn't yet. So I enter a pass to register, it then tells me invalid then wants me to log in. I can just close out of the login menu then gain access to the server. Probably just gonna link up the close button to kick the player, but I just need the registration system working. Here's the bit of code and some screenshots. Still relatively new to pawn, learning some everyday.
IMAGE ONE
IMAGE TWO
IMAGE THREE
Код:
public OnPlayerConnect(playerid) { new query[126], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); format(query, sizeof(query), "SELECT * FROM users WHERE name = '%s'", pName); mysql_query(query); mysql_store_result(); if(mysql_num_rows() == 1) { SendClientMessage(playerid, -1, "That username is registered!"); ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please log in with your password.", "Login", "Close"); } else { SendClientMessage(playerid, -1, "That username is not registered. You may register it!"); ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Register", "Register with your desired password.", "Register", "Close"); } return 1; }
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch(dialogid) { case 0: { if(response) { new query[126], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); format(query, sizeof(query), "SELECT * FROM users WHERE name ='%s' AND password ='%s'", pName, inputtext); mysql_query(query); mysql_store_result(); if(mysql_num_rows() == 1) { SendClientMessage(playerid, -1, "You have successfully signed in!"); SpawnPlayer(playerid); } else { SendClientMessage(playerid, -1, "Incorrect password!"); ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "Please log in with your password.", "Login", "Close"); } } } case 1: { if(response) { new query[126], pName[MAX_PLAYER_NAME]; GetPlayerName(playerid, pName, sizeof(pName)); format(query, sizeof(query), "INSERT INTO users VALUES ('%s', '%s')", pName, inputtext); mysql_query(query); SendClientMessage(playerid, -1, "You have registered!"); SpawnPlayer(playerid); } } } return 1; }
IMAGE TWO
IMAGE THREE