21.07.2015, 18:34
Hi, this is my gamemode's source code:
For some reason, when I connect to the server (when OnPlayerConnect is triggered) I don't receive any sort of dialog or anything. Is there anything I need to fix? MySQL is up and running all the time on my computer.
Код:
// 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; }