Jump to content

StanCatalin

Member
  • Posts

    4
  • Joined

  • Last visited

About StanCatalin

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

StanCatalin's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. Cand intru pe server nu-mi apare casuta de register.
  2. Mai exact text-boxurile nu apar.As fi foarte recunoscator daca m-ati putea ajuta. // 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),"SELECT '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; } Dialog:DIALOG_LOGIN(playerid,response,listitem,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_STYLE_PASSWORD,"Login", "{FF0000}Wrong Password!\n{FFFFFF}Type your correct password below to continue and sign in to your account", "Login", "Exit"); } return 1; } Dialog:DIALOG_REGISTER(playerid,response,listitem,inputtext[]) { if (!response) return Kick(playerid); if (strlen(inputtext) < 3) return Dialog_Show(playerid,DIALOG_REGISTER,DIALOG_STYLE_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; }
×
×
  • Create New...