Created
January 13, 2016 17:34
-
-
Save anonymous/60ea3a8863dca8474837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sqlLink = mysql_connect("127.0.0.1", "root", "", "server") | |
if(not sqlLink) then | |
outputDebugString("Unable to connect to the MySQL server") | |
else | |
outputDebugString("Connecting to a database MySQL successfully") | |
end | |
createVehicle(415, 434.1500, -1807.3500, 7.1800) | |
createVehicle(411, 429.6800, -1807.2800, 7.1800) | |
createVehicle(541, 425.0265, -1807.1318, 7.1800) | |
createVehicle(400, 439.4214, -1807.1318, 7.1800) | |
function joinHandler() | |
fadeCamera(source, true, 3) | |
setCameraMatrix(source, 757.7927, -1750.3217, 37.9849, 757.1046, -1749.5906, 37.6599) | |
setPlayerHudComponentVisible(source, "all", false) | |
outputChatBox("Welcome to My Server", source) | |
-- triggerClientEvent(source, "hideWLogin", getRootElement()) | |
end | |
addEventHandler("onPlayerJoin", getRootElement(), joinHandler) | |
function setNight() | |
setTime(0, 0) | |
end | |
addCommandHandler("night", setNight) | |
function loginHandler(username, password) | |
local query = "SELECT * FROM accounts WHERE Login = '"..username.."' AND Password = '"..password.."'" | |
local result = mysql_query(sqlLink, query) | |
if(mysql_num_rows(result) > 0) then | |
spawnPlayer(client, 440.6100, -1753.6700, 9.5500) | |
fadeCamera(client, true) | |
setCameraTarget(client, client) | |
outputChatBox("Добро пожаловать на сервер. Приятной игры!", client) | |
triggerClientEvent(client, "hideWLogin", getRootElement()) | |
setPlayerHudComponentVisible(source, "all", true) | |
else | |
outputChatBox("Неправильный логин и/или пароль или аккаунт не зарегистрирован\nЕсли Вы забыли пароль, обратитесь к администратору", client) | |
end | |
mysql_free_result(result) | |
end | |
function registerHandler(username, password) | |
local query = "SELECT * FROM accounts WHERE Login = '"..username.."'" | |
local result = mysql_query(sqlLink, query) | |
if(mysql_num_rows(result) > 0) then | |
outputChatBox("Указаный логин уже используется.", client) | |
else | |
local regsuc = mysql_query(sqlLink, "INSERT INTO accounts (Login, Password) VALUES ('"..username.."', '"..password.."')") | |
if regsuc then | |
outputChatBox("Аккаунт зарегистрирован. Приятной игры!", client) | |
spawnPlayer(client, 440.6100, -1753.6700, 9.5500) | |
fadeCamera(client, true) | |
setCameraTarget(client, client) | |
setPlayerHudComponentVisible(source, "all", true) | |
triggerClientEvent(client, "hideWLogin", getRootElement()) | |
else | |
outputChatBox("Сбой SQL запроса. Попробуйте еще раз!", client) | |
end | |
end | |
mysql_free_result(result) | |
end | |
addEvent("submitLogin", true) | |
addEvent("submitRegister", true) | |
addEventHandler("submitLogin", root, loginHandler) | |
addEventHandler("submitRegister", root, registerHandler) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment