Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- database = mysql_connect("хостинг", "пользователь", "пароль", "название базы данных")
- addEvent('onPlayerLoginEx', true)
- addEventHandler("onPlayerLoginEx", getRootElement(), function(name, password)
- local result = mysql_query(database, "SELECT * FROM players WHERE Name = '"..name.."' AND Password = '"..password.."';")
- if(result and mysql_num_rows(result) > 0) then
- triggerClientEvent(source, "destroyGui", source)
- setPlayerName(source, name)
- local row = mysql_fetch_assoc(result)
- setElementData(source, "posX", (row['X']))
- setElementData(source, "posY", (row['Y']))
- setElementData(source, "posZ", (row['Z']))
- spawnPlayer(source, getElementData(source, "posX"), getElementData(source, "posY"), getElementData(source, "posZ"))
- fadeCamera(source, true)
- setCameraTarget(source, source)
- outputChatBox("Вы успешно авторизировались на сервере!", source, 0, 255, 0)
- else
- outputChatBox("Введенный вами пароль неверный, или аккаунт не существует.", source, 255, 0, 0)
- end
- end)
- addEvent("onPlayerRegisterEx", true)
- addEventHandler("onPlayerRegisterEx", getRootElement(), function(name, password)
- local result = mysql_query(database, "SELECT Name FROM players WHERE Name = '"..tostring(name).."';")
- if(result) then
- if(mysql_num_rows(result) > 0) then
- outputChatBox("Аккаунт с указанным вами логином уже зарегистрирован, используйте другой!", source)
- else
- result = mysql_query(database, "INSERT INTO players (Name, Password) VALUES ('"..tostring(name).."', '"..tostring(password).."');")
- if(result) then
- triggerClientEvent(source, "destroyGui", source)
- setPlayerName(source, name)
- spawnPlayer(source, 1714.96875, -1913.5341796875, 13.566567420959)
- setCameraTarget(source, source)
- fadeCamera(source, true)
- outputChatBox("Вы успешно зарегистрировались на сервере!", source, 0, 255, 0)
- else
- outputChatBox("При регистрации аккаунта возникла ошибка.", source, 255, 0, 0)
- end
- end
- end
- end)
- addEventHandler ("onPlayerQuit", getRootElement(), function(quitType)
- local x, y, z = getElementPosition(source)
- mysql_query(database, "UPDATE players SET X = '"..x.."', Y = '"..y.."', Z = '"..z.."' WHERE NAME = '"..getPlayerName(source).."';")
- end)
Add Comment
Please, Sign In to add comment