Jump to content

Search the Community

Showing results for tags 'help'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • SA-MP
    • News and updates
    • General
    • Client Support
  • SA-MP Servers
    • Server Support
    • Server Advertisements
  • SA-MP Scripting and Plugins
    • Scripting Help
    • Gamemode Scripts
    • Filterscripts
    • Plugin Development
  • SA-MP Design
    • 3D Model
    • Website
    • Photoshop

Blogs

There are no results to display.

Categories

  • San Andreas Multiplayer Vietnam - Wiki

Categories

  • San Andreas Multiplayer
    • Asi Plugin
  • 3D Models
    • Objects

Product Groups

There are no results to display.


Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


About me


Expertise

Found 2 results

  1. #include <a_samp> #include <a_mysql> #include <foreach> #include <sscanf2> main() { print("\n----------------------------------"); print(" Gamemode EDIT LAN THU 8 "); print("----------------------------------\n"); } new Text: LoginTD[2], Text: RegisterTD[2], PlayerText: LoginPTD[MAX_PLAYERS][3], PlayerText: RegisterPTD[MAX_PLAYERS][3]; #define MYSQL_HOST "localhost" // Change this to your MySQL Remote IP or "localhost". #define MYSQL_USER "root" // Change this to your MySQL Database username. #define MYSQL_PASS "" // Change this to your MySQL Database password. #define MYSQL_DATABASE "gamemode" // Change this to your MySQL Database name. #if !defined isnull #define isnull(%1) ((!(%1[0])) || (((%1[0]) == '\1') && (!(%1[1])))) #endif // Well, don't just enter random information and expect it to work, information // Should be valid and working fine. #define DIALOG_REGISTER (0) #define DIALOG_LOGIN (1) // Make sure the dialog IDs above do not match any dialog ID you're using in your // gamemode otherwise they won't do their job properly. new MySQL: Database, Corrupt_Check[MAX_PLAYERS]; //Creating an enumerator to store player's data for further use (below). //============================================================================== enum ENUM_PLAYER_DATA { ID, Name[25], Password[65], Salt[11], PasswordFails, Kills, Deaths, Score, Cash, Cache: Player_Cache, bool:LoggedIn } new pInfo[MAX_PLAYERS][ENUM_PLAYER_DATA]; //============================================================================== public OnGameModeInit() { new MySQLOpt: option_id = mysql_init_options(); mysql_set_option(option_id, AUTO_RECONNECT, true); // We will set that option to automatically reconnect on timeouts. Database = mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS, MYSQL_DATABASE, option_id); // Setting up the "Database" handle on the given MySQL details above. if(Database == MYSQL_INVALID_HANDLE || mysql_errno(Database) != 0) // Checking if the database connection is invalid to shutdown. { print("I couldn't connect to the MySQL server, closing."); // Printing a message to the log. SendRconCommand("exit"); // Sending console command to shut down server. return 1; } print("I have connected to the MySQL server."); // If the given MySQL details were all okay, this message prints to the log. // Now, we will set up the information table of the player's information. mysql_tquery(Database, "CREATE TABLE IF NOT EXISTS `PLAYERS` (`ID` int(11) NOT NULL AUTO_INCREMENT,`USERNAME` varchar(24) NOT NULL,`PASSWORD` char(65) NOT NULL,`SALT` char(11) NOT NULL,`SCORE` mediumint(7), `KILLS` mediumint(7), `CASH` mediumint(7) NOT NULL DEFAULT '0',`DEATHS` mediumint(7) NOT NULL DEFAULT '0', PRIMARY KEY (`ID`), UNIQUE KEY `USERNAME` (`USERNAME`))"); // So, this code is probably the only one which you haven't understood. // Well, we firstly create a table only if not existing in the database which is "USERS". // We create "ID" and set it as a primary key with auto increment to use it in retrieving information and many more uses. // We create "USERNAME" and set it as a unique key, the USERNAME stores every player's name in the database so you can // Control the players in offline mode and when a player leaves everything storted like kills, deaths, password and Saltion key // Wouldn't be lost upon server's close or player's disconnection. // We store kills, deaths, score and cash as written above so they might be useful for further use. return 1; } public OnGameModeExit() { foreach(new i: Player) { if(IsPlayerConnected(i)) // Checking if the players stored in "i" are connected. { OnPlayerDisconnect(i, 1); // We do that so players wouldn't lose their data upon server's close. } } mysql_close(Database); // Closing the database. return 1; } public OnPlayerConnect(playerid) { new DB_Query[115]; //Resetting player information. pInfo[playerid][Kills] = 0; pInfo[playerid][Deaths] = 0; pInfo[playerid][PasswordFails] = 0; GetPlayerName(playerid, pInfo[playerid][Name], MAX_PLAYER_NAME); // Getting the player's name. Corrupt_Check[playerid]++; mysql_format(Database, DB_Query, sizeof(DB_Query), "SELECT * FROM `PLAYERS` WHERE `USERNAME` = '%e' LIMIT 1", pInfo[playerid][Name]); mysql_tquery(Database, DB_Query, "OnPlayerDataCheck", "ii", playerid, Corrupt_Check[playerid]); LoginTD[0] = TextDrawCreate(448.266998, 152.640014, "box"); TextDrawLetterSize(LoginTD[0], 0.000000, 12.599336); TextDrawTextSize(LoginTD[0], 183.100006, 0.000000); TextDrawAlignment(LoginTD[0], 1); TextDrawColor(LoginTD[0], -1); TextDrawUseBox(LoginTD[0], 1); TextDrawBoxColor(LoginTD[0], 353704161); TextDrawSetShadow(LoginTD[0], 0); TextDrawBackgroundColor(LoginTD[0], 255); TextDrawFont(LoginTD[0], 1); TextDrawSetProportional(LoginTD[0], 1); LoginTD[1] = TextDrawCreate(315.333343, 158.000488, "LOGIN"); TextDrawLetterSize(LoginTD[1], 0.460000, 1.712000); TextDrawTextSize(LoginTD[1], 0.000000, 253.000000); TextDrawAlignment(LoginTD[1], 2); TextDrawColor(LoginTD[1], -1); TextDrawUseBox(LoginTD[1], 1); TextDrawBoxColor(LoginTD[1], 255); TextDrawSetShadow(LoginTD[1], 0); TextDrawBackgroundColor(LoginTD[1], 255); TextDrawFont(LoginTD[1], 1); TextDrawSetProportional(LoginTD[1], 1); LoginPTD[playerid][0] = CreatePlayerTextDraw(playerid, 315.000030, 184.175033, "NAME : OBBIE"); PlayerTextDrawLetterSize(playerid, LoginPTD[playerid][0], 0.400000, 1.600000); PlayerTextDrawTextSize(playerid, LoginPTD[playerid][0], 0.000000, 165.000000); PlayerTextDrawAlignment(playerid, LoginPTD[playerid][0], 2); PlayerTextDrawColor(playerid, LoginPTD[playerid][0], -1); PlayerTextDrawUseBox(playerid, LoginPTD[playerid][0], 1); PlayerTextDrawBoxColor(playerid, LoginPTD[playerid][0], 255); PlayerTextDrawSetShadow(playerid, LoginPTD[playerid][0], 0); PlayerTextDrawBackgroundColor(playerid, LoginPTD[playerid][0], 255); PlayerTextDrawFont(playerid, LoginPTD[playerid][0], 1); PlayerTextDrawSetProportional(playerid, LoginPTD[playerid][0], 1); LoginPTD[playerid][1] = CreatePlayerTextDraw(playerid, 315.000091, 213.414932, "PASSWORD : CLICK"); PlayerTextDrawLetterSize(playerid, LoginPTD[playerid][1], 0.400000, 1.600000); PlayerTextDrawTextSize(playerid, LoginPTD[playerid][1], 20.000000, 165.000000); PlayerTextDrawAlignment(playerid, LoginPTD[playerid][1], 2); PlayerTextDrawColor(playerid, LoginPTD[playerid][1], -1); PlayerTextDrawUseBox(playerid, LoginPTD[playerid][1], 1); PlayerTextDrawBoxColor(playerid, LoginPTD[playerid][1], 255); PlayerTextDrawSetShadow(playerid, LoginPTD[playerid][1], 0); PlayerTextDrawBackgroundColor(playerid, LoginPTD[playerid][1], 255); PlayerTextDrawFont(playerid, LoginPTD[playerid][1], 1); PlayerTextDrawSetProportional(playerid, LoginPTD[playerid][1], 1); PlayerTextDrawSetSelectable(playerid, LoginPTD[playerid][1], true); LoginPTD[playerid][2] = CreatePlayerTextDraw(playerid, 309.666442, 238.129821, "LOGIN"); PlayerTextDrawLetterSize(playerid, LoginPTD[playerid][2], 0.492332, 2.023111); PlayerTextDrawTextSize(playerid, LoginPTD[playerid][2], 20.000000, 95.000000); PlayerTextDrawAlignment(playerid, LoginPTD[playerid][2], 2); PlayerTextDrawColor(playerid, LoginPTD[playerid][2], -1); PlayerTextDrawUseBox(playerid, LoginPTD[playerid][2], 1); PlayerTextDrawBoxColor(playerid, LoginPTD[playerid][2], 255); PlayerTextDrawSetShadow(playerid, LoginPTD[playerid][2], 0); PlayerTextDrawBackgroundColor(playerid, LoginPTD[playerid][2], 255); PlayerTextDrawFont(playerid, LoginPTD[playerid][2], 1); PlayerTextDrawSetProportional(playerid, LoginPTD[playerid][2], 1); PlayerTextDrawSetSelectable(playerid, LoginPTD[playerid][2], true); RegisterTD[0] = TextDrawCreate(448.266998, 152.640014, "box"); TextDrawLetterSize(RegisterTD[0], 0.000000, 12.599336); TextDrawTextSize(RegisterTD[0], 183.100006, 0.000000); TextDrawAlignment(RegisterTD[0], 1); TextDrawColor(RegisterTD[0], -1); TextDrawUseBox(RegisterTD[0], 1); TextDrawBoxColor(RegisterTD[0], 353704161); TextDrawSetShadow(RegisterTD[0], 0); TextDrawBackgroundColor(RegisterTD[0], 255); TextDrawFont(RegisterTD[0], 1); TextDrawSetProportional(RegisterTD[0], 1); RegisterTD[1] = TextDrawCreate(315.333343, 158.000488, "REGISTER"); TextDrawLetterSize(RegisterTD[1], 0.460000, 1.712000); TextDrawTextSize(RegisterTD[1], 0.000000, 253.000000); TextDrawAlignment(RegisterTD[1], 2); TextDrawColor(RegisterTD[1], -1); TextDrawUseBox(RegisterTD[1], 1); TextDrawBoxColor(RegisterTD[1], 255); TextDrawSetShadow(RegisterTD[1], 0); TextDrawBackgroundColor(RegisterTD[1], 255); TextDrawFont(RegisterTD[1], 1); TextDrawSetProportional(RegisterTD[1], 1); RegisterPTD[playerid][0] = CreatePlayerTextDraw(playerid, 315.000030, 184.175033, "NAME : OBBIE"); PlayerTextDrawLetterSize(playerid, RegisterPTD[playerid][0], 0.400000, 1.600000); PlayerTextDrawTextSize(playerid, RegisterPTD[playerid][0], 0.000000, 165.000000); PlayerTextDrawAlignment(playerid, RegisterPTD[playerid][0], 2); PlayerTextDrawColor(playerid, RegisterPTD[playerid][0], -1); PlayerTextDrawUseBox(playerid, RegisterPTD[playerid][0], 1); PlayerTextDrawBoxColor(playerid, RegisterPTD[playerid][0], 255); PlayerTextDrawSetShadow(playerid, RegisterPTD[playerid][0], 0); PlayerTextDrawBackgroundColor(playerid, RegisterPTD[playerid][0], 255); PlayerTextDrawFont(playerid, RegisterPTD[playerid][0], 1); PlayerTextDrawSetProportional(playerid, RegisterPTD[playerid][0], 1); RegisterPTD[playerid][1] = CreatePlayerTextDraw(playerid, 315.000091, 213.414932, "PASSWORD : "); PlayerTextDrawLetterSize(playerid, RegisterPTD[playerid][1], 0.400000, 1.600000); PlayerTextDrawTextSize(playerid, RegisterPTD[playerid][1], 20.000000, 165.000000); PlayerTextDrawAlignment(playerid, RegisterPTD[playerid][1], 2); PlayerTextDrawColor(playerid, RegisterPTD[playerid][1], -1); PlayerTextDrawUseBox(playerid, RegisterPTD[playerid][1], 1); PlayerTextDrawBoxColor(playerid, RegisterPTD[playerid][1], 255); PlayerTextDrawSetShadow(playerid, RegisterPTD[playerid][1], 0); PlayerTextDrawBackgroundColor(playerid, RegisterPTD[playerid][1], 255); PlayerTextDrawFont(playerid, RegisterPTD[playerid][1], 1); PlayerTextDrawSetProportional(playerid, RegisterPTD[playerid][1], 1); PlayerTextDrawSetSelectable(playerid, RegisterPTD[playerid][1], true); RegisterPTD[playerid][2] = CreatePlayerTextDraw(playerid, 309.666442, 238.129821, "REGISTER"); PlayerTextDrawLetterSize(playerid, RegisterPTD[playerid][2], 0.492332, 2.023111); PlayerTextDrawTextSize(playerid, RegisterPTD[playerid][2], 20.000000, 95.000000); PlayerTextDrawAlignment(playerid, RegisterPTD[playerid][2], 2); PlayerTextDrawColor(playerid, RegisterPTD[playerid][2], -1); PlayerTextDrawUseBox(playerid, RegisterPTD[playerid][2], 1); PlayerTextDrawBoxColor(playerid, RegisterPTD[playerid][2], 255); PlayerTextDrawSetShadow(playerid, RegisterPTD[playerid][2], 0); PlayerTextDrawBackgroundColor(playerid, RegisterPTD[playerid][2], 255); PlayerTextDrawFont(playerid, RegisterPTD[playerid][2], 1); PlayerTextDrawSetProportional(playerid, RegisterPTD[playerid][2], 1); PlayerTextDrawSetSelectable(playerid, RegisterPTD[playerid][2], true); return 1; } public OnPlayerDisconnect(playerid, reason) { Corrupt_Check[playerid]++; new DB_Query[256]; //Running a query to save the player's data using the stored stuff. mysql_format(Database, DB_Query, sizeof(DB_Query), "UPDATE `PLAYERS` SET `SCORE` = %d, `CASH` = %d, `KILLS` = %d, `DEATHS` = %d WHERE `ID` = %d LIMIT 1", pInfo[playerid][Score], pInfo[playerid][Cash], pInfo[playerid][Kills], pInfo[playerid][Deaths], pInfo[playerid][ID]); mysql_tquery(Database, DB_Query); if(cache_is_valid(pInfo[playerid][Player_Cache])) //Checking if the player's cache ID is valid. { cache_delete(pInfo[playerid][Player_Cache]); // Deleting the cache. pInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; // Setting the stored player Cache as invalid. } pInfo[playerid][LoggedIn] = false; return 1; } public OnPlayerDeath(playerid, killerid, reason) { if(killerid != INVALID_PLAYER_ID) // Checking if the killer of the player is valid. { //Increasing the kills of the killer and the deaths of the player. pInfo[killerid][Kills]++; pInfo[playerid][Deaths]++; } return 1; } public OnPlayerRequestSpawn(playerid) { if(pInfo[playerid][LoggedIn] == false) return 0; // Ignoring the request incase player isn't logged in. return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { switch (dialogid) { case DIALOG_LOGIN: { if(response) { SetPVarString(playerid, "Stored_Login_Password", inputtext); PlayerTextDrawSetString(playerid, LoginPTD[playerid][1], "DA NHAP PASSWORD"); PlayerTextDrawShow(playerid, LoginPTD[playerid][1]); SelectTextDraw(playerid, 0xFF4040AA); } else SelectTextDraw(playerid, 0xFF4040AA); } case DIALOG_REGISTER: { if(!response) return Kick(playerid); if(strlen(inputtext) <= 5 || strlen(inputtext) > 60) { SendClientMessage(playerid, 0x969696FF, "Mat khau phai 5 - 60 ky tu."); PlayerTextDrawSetString(playerid, RegisterPTD[playerid][1], "NHAP LAI PASSWORD"); } else { SetPVarString(playerid, "Stored_Register_Password", inputtext); PlayerTextDrawSetString(playerid, RegisterPTD[playerid][1], "DA NHAP PASSWORD"); PlayerTextDrawShow(playerid, RegisterPTD[playerid][1]); } } } return 1; } forward public OnPlayerDataCheck(playerid, corrupt_check); public OnPlayerDataCheck(playerid, corrupt_check) { if (corrupt_check != Corrupt_Check[playerid]) return Kick(playerid); // You'd have asked already what's corrput_check and how it'd benefit me? // Well basically MySQL query takes long, incase a player leaves while its not proceeded // With ID 1 for example, then another player comes as ID 1 it'll basically corrupt the data // So, once the query is done, the player will have the wrong data assigned for himself. new string[150]; if(cache_num_rows() > 0) { // If the player exists, everything is okay and nothing is wrongly detected // The player's password and Saltion key gets stored as seen below // So we won't have to get a headache just to match player's password. cache_get_value(0, "PASSWORD", pInfo[playerid][Password], 65); cache_get_value(0, "SALT", pInfo[playerid][Salt], 11); pInfo[playerid][Player_Cache] = cache_save(); // ^ Storing the cache ID of the player for further use later. format(string, sizeof(string), "NAME: %s", pInfo[playerid][Name]); PlayerTextDrawSetString(playerid, LoginPTD[playerid][0], string); PlayerTextDrawSetString(playerid, LoginPTD[playerid][1], "NHAP PASSWORD"); for(new i = 0; i < 3; i++) PlayerTextDrawShow(playerid, LoginPTD[playerid][i]); for(new i = 0; i < 2; i++) TextDrawShowForPlayer(playerid, LoginTD[i]); TogglePlayerSpectating(playerid, 1); PlayerTextDrawShow(playerid, LoginPTD[playerid][1]); SelectTextDraw(playerid, 0xFF4040AA); /* format(string, sizeof(string), "{FFFFFF}Welcome back, %s.\n\n{0099FF}This account is already registered.\n\ {0099FF}Please, input your password below to proceed to the game.\n\n", pInfo[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login System", string, "Login", "Leave"); */ } else { format(string, sizeof(string), "NAME: %s", pInfo[playerid][Name]); PlayerTextDrawSetString(playerid, RegisterPTD[playerid][0], string); PlayerTextDrawSetString(playerid, RegisterPTD[playerid][1], "NHAP PASSWORD"); for(new i = 0; i < 3; i++) PlayerTextDrawShow(playerid, RegisterPTD[playerid][i]); for(new i = 0; i < 2; i++) TextDrawShowForPlayer(playerid, RegisterTD[i]); TogglePlayerSpectating(playerid, 1); PlayerTextDrawShow(playerid, RegisterPTD[playerid][1]); SelectTextDraw(playerid, 0xFF4040AA); /*format(string, sizeof(string), "{FFFFFF}Welcome %s.\n\n{0099FF}This account is not registered.\n\ {0099FF}Please, input your password below to proceed to the game.\n\n", pInfo[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration System", string, "Register", "Leave");*/ } return 1; } forward public OnPlayerRegister(playerid); public OnPlayerRegister(playerid) { // This gets called only when the player registers a new account. SendClientMessage(playerid, 0x00FF00FF, "Ban da dang ky xong. Chao mung ban da den voi NONOGAME."); pInfo[playerid][LoggedIn] = true; TextDrawHideForPlayer(playerid, RegisterTD[0]); TextDrawHideForPlayer(playerid, RegisterTD[1]); PlayerTextDrawHide(playerid, RegisterPTD[playerid][0]); PlayerTextDrawHide(playerid, RegisterPTD[playerid][1]); PlayerTextDrawHide(playerid, RegisterPTD[playerid][2]); CancelSelectTextDraw(playerid); SetSpawnInfo(playerid, 0, 0, 1508.1501,-884.4976,60.4167,309.6271, 0, 0, 0, 0, 0, 0 ); SpawnPlayer(playerid); TogglePlayerSpectating(playerid,false); PlayerTextDrawTextSize(playerid, RegisterPTD[playerid][1], 20.000000, 165.000000); return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { if(newkeys == KEY_SUBMISSION) { SelectTextDraw(playerid, 0xFF4040AA); } return 1; } public OnPlayerClickPlayerTextDraw(playerid, PlayerText:playertextid) { new String[150]; if(playertextid == LoginPTD[playerid][1]) { CancelSelectTextDraw(playerid); format(String, sizeof(String), "{FFFFFF}Chao mung, %s da quay lai may chu.\n\n{0099FF}Tai khoan nay da duoc dang ky.\n\ {0099FF}Vui long nhap mat khau de vao game.\n\n", pInfo[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login System", String, "Xac Nhan", "Huy Bo"); PlayerTextDrawTextSize(playerid, LoginPTD[playerid][1], 0.000000, 165.000000); return 1; } else if(playertextid == RegisterPTD[playerid][1]) { CancelSelectTextDraw(playerid); format(String, sizeof(String), "{FFFFFF}Chao mung %s da tham gia may chu.\n\n{0099FF}Tai khoan nay chua duoc dang ky.\n\ {0099FF}Vui long nhap mat khau de dang ky tai khoan.\n\n", pInfo[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Registration System", String, "Xac Nhan", "Huy Bo"); PlayerTextDrawTextSize(playerid, RegisterPTD[playerid][1], 0.000000, 165.000000); return 1; } else if(playertextid == LoginPTD[playerid][2]) { new Salted_Key[65], stored_login_password[32]; GetPVarString(playerid, "Stored_Login_Password", stored_login_password, sizeof(stored_login_password)); if(isnull(stored_login_password)) return SendClientMessage(playerid, -1, "Ban chua nhap mat khau, khong the dang nhap."); SHA256_PassHash(stored_login_password, pInfo[playerid][Salt], Salted_Key, 65); if(strcmp(Salted_Key, pInfo[playerid][Password]) == 0) { // Now, password should be correct as well as the strings // Matched with each other, so nothing is wrong until now. // We will activate the cache of player to make use of it e.g. // Retrieve their data. cache_set_active(pInfo[playerid][Player_Cache]); // Okay, we are retrieving the information now.. cache_get_value_int(0, "ID", pInfo[playerid][ID]); cache_get_value_int(0, "KILLS", pInfo[playerid][Kills]); cache_get_value_int(0, "DEATHS", pInfo[playerid][Deaths]); cache_get_value_int(0, "SCORE", pInfo[playerid][Score]); cache_get_value_int(0, "CASH", pInfo[playerid][Cash]); SetPlayerScore(playerid, pInfo[playerid][Score]); ResetPlayerMoney(playerid); GivePlayerMoney(playerid, pInfo[playerid][Cash]); // So, we have successfully retrieved data? Now deactivating the cache. cache_delete(pInfo[playerid][Player_Cache]); pInfo[playerid][Player_Cache] = MYSQL_INVALID_CACHE; pInfo[playerid][LoggedIn] = true; SendClientMessage(playerid, 0x00FF00FF, "Chao mung ban tro lai."); TextDrawHideForPlayer(playerid, LoginTD[0]); TextDrawHideForPlayer(playerid, LoginTD[1]); PlayerTextDrawHide(playerid, LoginPTD[playerid][0]); PlayerTextDrawHide(playerid, LoginPTD[playerid][1]); PlayerTextDrawHide(playerid, LoginPTD[playerid][2]); CancelSelectTextDraw(playerid); SetSpawnInfo(playerid, 0, 0, 1508.1501,-884.4976,60.4167,309.6271, 0, 0, 0, 0, 0, 0 ); SpawnPlayer(playerid); TogglePlayerSpectating(playerid,false); PlayerTextDrawTextSize(playerid, LoginPTD[playerid][1], 20.000000, 165.000000); } else { new String[150]; pInfo[playerid][PasswordFails] += 1; printf("%s da dang nhap that bai. (%d)", pInfo[playerid][Name], pInfo[playerid][PasswordFails]); // Printing the message that someone has failed to login to his account. if (pInfo[playerid][PasswordFails] >= 3) // If the fails exceeded the limit we kick the player. { format(String, sizeof(String), "%s da bi kicked boi li do: {FF0000}(%d/3) Dang Nhap That Bai.", pInfo[playerid][Name], pInfo[playerid][PasswordFails]); SendClientMessageToAll(0x969696FF, String); Kick(playerid); } else { PlayerTextDrawTextSize(playerid, LoginPTD[playerid][1], 20.000000, 165.000000); PlayerTextDrawSetString(playerid, LoginPTD[playerid][1], "NHAP LAI PASSWORD"); PlayerTextDrawShow(playerid, LoginPTD[playerid][1]); format(String, sizeof(String), "Sai mat khau, ban da nhap sai %d/3 lan. Vui long nhap lai mat khau.", pInfo[playerid][PasswordFails]); SendClientMessage(playerid, 0xFF0000FF, String); CancelSelectTextDraw(playerid); format(String, sizeof(String), "{FFFFFF}Chao mung, %s da quay lai may chu.\n\n{0099FF}Tai khoan nay da duoc dang ky.\n\ {0099FF}Vui long nhap mat khau de vao game.\n\n", pInfo[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login System", String, "Xac Nhan", "Huy Bo"); } } return 1; } else if(playertextid == RegisterPTD[playerid][2]) { new Salted_Key[65], stored_register_password[32]; GetPVarString(playerid, "Stored_Register_Password", stored_register_password, sizeof(stored_register_password)); if(isnull(stored_register_password)) return SendClientMessage(playerid, -1, "Ban chua nhap mat khau, khong the dang ky tai khoan."); for (new i = 0; i < 10; i++) { pInfo[playerid][Salt][i] = random(79) + 47; } pInfo[playerid][Salt][10] = 0; SHA256_PassHash(stored_register_password, pInfo[playerid][Salt], pInfo[playerid][Password], 65); new DB_Query[225]; // Storing player's information if everything goes right. mysql_format(Database, DB_Query, sizeof(DB_Query), "INSERT INTO `PLAYERS` (`USERNAME`, `PASSWORD`, `SALT`, `SCORE`, `KILLS`, `CASH`, `DEATHS`)\ VALUES ('%e', '%s', '%e', '20', '0', '0', '0')", pInfo[playerid][Name], pInfo[playerid][Password], pInfo[playerid][Salt]); mysql_tquery(Database, DB_Query, "OnPlayerRegister", "d", playerid); return 1; } return 0; } Phía trên là Code mình cần giúp đỡ. Bây giờ mình cần phải sử dụng hàm nào để khi người ta nhập sai mật khẩu thì phần code này nó reset lại như ban đầu. : if(playertextid == LoginPTD[playerid][1]) { CancelSelectTextDraw(playerid); format(String, sizeof(String), "{FFFFFF}Chao mung, %s da quay lai may chu.\n\n{0099FF}Tai khoan nay da duoc dang ky.\n\ {0099FF}Vui long nhap mat khau de vao game.\n\n", pInfo[playerid][Name]); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Login System", String, "Xac Nhan", "Huy Bo"); PlayerTextDrawTextSize(playerid, LoginPTD[playerid][1], 0.000000, 165.000000); return 1; } Có nghĩa là khi nhập sai mật khẩu thì khi mình bấm vào Texdraw Login thì nó sẽ trả về là bạn chưa nhập mật khẩu. Mong mọi người giúp đỡ. Cảm ơn mọi người nhiều.
  2. Mình bật samp server lên nó hiện thế này xong tự tắt luôn , anh em chỉ mình cách fix với ạ
×
×
  • Create New...