// This is a comment // uncomment the line below if you want to write a filterscript //#define FILTERSCRIPT native WP_Hash(buffer[], len, const str[]); #include <a_samp> #include <zcmd> #include <sscanf2> #include <a_mysql> static mysql; #define dlogin 1 #define dregister 2 enum PlayerData { Name[MAX_PLAYER_NAME+1], Password[255], Money, ID } new PInfo[MAX_PLAYERS][PlayerData]; #if defined FILTERSCRIPT forward OnAccountCheck(playerid); public OnAccountCheck(playerid) { new rows, fields; cache_get_data(rows, fields, mysql); if(rows) { cache_get_field_content(0, "PASS", PInfo[playerid][Password], mysql, 129); ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "This name is registered, enter your password below.", "Login", "Quit"); } else { ShowPlayerDialog(playerid, dregister, DIALOG_STYLE_INPUT, "Register", "This name isn't registered, enter a password below.", "Register", "Quit"); } return 1; } forward OnAccountLoad(playerid); forward OnAccountRegister(playerid); public OnAccountLoad(playerid) { PInfo[playerid][Money] = cache_get_field_content_int(0, "Money"); GivePlayerMoney(playerid, PInfo[playerid][Money]); SendClientMessage(playerid, -1, "You have successfully logged in."); new pName[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, pName); new str[126]; format(str, sizeof(str), "%s has joined the server.", pName); SendClientMessageToAll(-1, str); return 1; } public OnAccountRegister(playerid) { PInfo[playerid][ID] = cache_insert_id(); printf("New account registered with the ID %d", PInfo[playerid][ID]); return 1; } 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() { mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG); mysql = mysql_connect("localhost", "root", "test", ""); if (mysql_errno(mysql) != 0) print("Could not connect to the database"); // Don't use these lines if it's a filterscript SetGameModeText("Blank Script"); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); 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 OnPlayerConnect(playerid) { new query[126], pName[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, pName, sizeof(pName)); mysql_format(mysql, query, sizeof(query), "SELECT * FROM users WHERE Name = '%s'", pName); mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid); return 1; } public OnPlayerDisconnect(playerid, reason) { new query[255]; mysql_format(mysql, query, sizeof(query), "UPDATE 'users' SET 'Money'= %i WHERE 'ID' =%d ", PInfo[playerid][Money], PInfo[playerid][ID]); mysql_tquery(mysql, query, "", ""); return 1; } public OnPlayerSpawn(playerid) { return 1; } public OnPlayerDeath(playerid, killerid, reason) { return 1; } public OnVehicleSpawn(vehicleid) { return 1; } public OnVehicleDeath(vehicleid, killerid) { return 1; } public OnPlayerText(playerid, text[]) { return 1; } public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/mycommand", cmdtext, true, 10) == 0) { // Do something here return 1; } return 0; } public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) { return 1; } public OnPlayerExitVehicle(playerid, vehicleid) { return 1; } public OnPlayerStateChange(playerid, newstate, oldstate) { return 1; } public OnPlayerEnterCheckpoint(playerid) { return 1; } public OnPlayerLeaveCheckpoint(playerid) { return 1; } public OnPlayerEnterRaceCheckpoint(playerid) { return 1; } public OnPlayerLeaveRaceCheckpoint(playerid) { return 1; } public OnRconCommand(cmd[]) { return 1; } public OnPlayerRequestSpawn(playerid) { return 1; } public OnObjectMoved(objectid) { return 1; } public OnPlayerObjectMoved(playerid, objectid) { return 1; } public OnPlayerPickUpPickup(playerid, pickupid) { return 1; } public OnVehicleMod(playerid, vehicleid, componentid) { return 1; } public OnVehiclePaintjob(playerid, vehicleid, paintjobid) { return 1; } public OnVehicleRespray(playerid, vehicleid, color1, color2) { return 1; } public OnPlayerSelectedMenuRow(playerid, row) { return 1; } public OnPlayerExitedMenu(playerid) { return 1; } public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) { return 1; } public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { return 1; } public OnRconLoginAttempt(ip[], password[], success) { return 1; } public OnPlayerUpdate(playerid) { return 1; } public OnPlayerStreamIn(playerid, forplayerid) { return 1; } public OnPlayerStreamOut(playerid, forplayerid) { return 1; } public OnVehicleStreamIn(vehicleid, forplayerid) { return 1; } public OnVehicleStreamOut(vehicleid, forplayerid) { return 1; } public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { new pName[MAX_PLAYER_NAME+1]; GetPlayerName(playerid, pName, sizeof(pName)); switch(dialogid) { case dlogin: { if(!response) return Kick(playerid); new hpass[255]; new query[100]; WP_Hash(hpass, 255, inputtext); if(!strcmp(hpass, PInfo[playerid][Password])) { mysql_format(mysql, query, sizeof(query), "SELECT * FROM 'users' WHERE 'Name' = '%e' LIMIT 1", pName); mysql_tquery(mysql, query, "OnAccountLoad", "i", playerid); } else { ShowPlayerDialog(playerid, dlogin, DIALOG_STYLE_INPUT, "Login", "Incorrect password, try again.", "Login", "Quit"); } } case dregister: { if (!response) return Kick(playerid); if (strlen(inputtext) < 6) return SendClientMessage(playerid, -1, "Your password must be no less than 6 characters."); else { new query[100]; WP_Hash(PInfo[playerid][Password], 129, inputtext); mysql_format(mysql, query, sizeof(query), "INSERT INTO 'users' ('Name', 'Password') VALUES ('%e', '%e')", pName, PInfo[playerid][Password]); mysql_tquery(mysql, query, "OnAccountRegister", "i", playerid); } } } return 1; } public OnPlayerClickPlayer(playerid, clickedplayerid, source) { return 1; }
[19:43:44] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "test", password: "****", port: 3306, autoreconnect: true [19:43:44] [DEBUG] CMySQLHandle::Create - creating new connection.. [19:43:44] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [19:43:44] [DEBUG] CMySQLHandle::Create - connection created with ID = 1 [19:43:44] [DEBUG] CMySQLConnection::Connect - connection was successful [19:43:44] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:43:44] [DEBUG] CMySQLConnection::Connect - connection was successful [19:43:44] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:43:44] [DEBUG] mysql_errno - connection: 1 [19:44:54] [DEBUG] mysql_format - connection: 1, len: 126, format: "SELECT * FROM users WHERE Name = '%s'" [19:44:54] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM users WHERE Name = 'Jonathan_Larsson'", callback: "OnAccountCheck", format: "i" [19:44:54] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [19:44:54] [DEBUG] mysql_tquery - scheduling query "SELECT * FROM users WHERE Name = 'Jonathan_Larsson'".. [19:44:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - starting query execution [19:44:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - query was successful [19:44:54] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [19:44:54] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - data being passed to ProcessCallbacks() [19:44:54] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [19:44:54] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called [19:45:04] [DEBUG] mysql_format - connection: 1, len: 255, format: "UPDATE 'users' SET 'Money'= %i WHERE 'ID' =%d " [19:45:04] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE 'users' SET 'Money'= 0 WHERE 'ID' =0 ", callback: "(null)", format: "(null)" [19:45:04] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [19:45:04] [DEBUG] mysql_tquery - scheduling query "UPDATE 'users' SET 'Money'= 0 WHERE 'ID' =0 ".. [19:45:04] [DEBUG] CMySQLQuery::Execute[()] - starting query execution [19:45:04] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' SET 'Money'= 0 WHERE 'ID' =0' at line 1 [19:45:04] [DEBUG] CMySQLQuery::Execute[()] - error will be triggered in OnQueryError [19:45:04] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks() [19:45:04] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called [19:52:04] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "test", password: "****", port: 3306, autoreconnect: true [19:52:04] [DEBUG] CMySQLHandle::Create - creating new connection.. [19:52:04] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called [19:52:04] [DEBUG] CMySQLHandle::Create - connection created with ID = 1 [19:52:04] [DEBUG] CMySQLConnection::Connect - connection was successful [19:52:04] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:52:04] [DEBUG] CMySQLConnection::Connect - connection was successful [19:52:04] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled [19:52:04] [DEBUG] mysql_errno - connection: 1 [19:52:34] [DEBUG] mysql_format - connection: 1, len: 126, format: "SELECT * FROM users WHERE Name = '%s'" [19:52:34] [DEBUG] mysql_tquery - connection: 1, query: "SELECT * FROM users WHERE Name = 'Jonathan_Larsson'", callback: "OnAccountCheck", format: "i" [19:52:34] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [19:52:34] [DEBUG] mysql_tquery - scheduling query "SELECT * FROM users WHERE Name = 'Jonathan_Larsson'".. [19:52:34] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - starting query execution [19:52:34] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - query was successful [19:52:34] [DEBUG] CMySQLResult::CMySQLResult() - constructor called [19:52:34] [DEBUG] CMySQLQuery::Execute[OnAccountCheck(i)] - data being passed to ProcessCallbacks() [19:52:34] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called [19:52:34] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called [19:52:43] [DEBUG] mysql_format - connection: 1, len: 255, format: "UPDATE 'users' SET 'Money'= %i WHERE 'ID' =%d " [19:52:43] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE 'users' SET 'Money'= 0 WHERE 'ID' =0 ", callback: "(null)", format: "(null)" [19:52:43] [DEBUG] CMySQLQuery::CMySQLQuery() - constructor called [19:52:43] [DEBUG] mysql_tquery - scheduling query "UPDATE 'users' SET 'Money'= 0 WHERE 'ID' =0 ".. [19:52:43] [DEBUG] CMySQLQuery::Execute[()] - starting query execution [19:52:43] [ERROR] CMySQLQuery::Execute[()] - (error #1064) You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''users' SET 'Money'= 0 WHERE 'ID' =0' at line 1 [19:52:43] [DEBUG] CMySQLQuery::Execute[()] - error will be triggered in OnQueryError [19:52:43] [DEBUG] CMySQLQuery::Execute[()] - data being passed to ProcessCallbacks() [19:52:43] [DEBUG] CMySQLQuery::~CMySQLQuery() - deconstructor called |
//#define FILTERSCRIPT
#if defined FILTERSCRIPT