-
Posts
104 -
Joined
-
Last visited
Everything posted by Furious
-
[Ajuda] - O que está de errado nesse código?
Furious replied to Furious's topic in Programação em Lua
Não aparece nada. Na verdade ele está me retornando isso: cmodels/tent.dff No print (file) -
local replace_model = { {"cmodels/tent.txd","cmodels/tent.dff",3243,"cmodels/vvoabC2xENOoQhgpE9MvT8kHWsQXEl","cmodels/6edp8dkehrk1sghEJD1cazP0rT8weF"} } function onStartResourceDeleteFiles() for _,data in ipairs(replace_model) do if not fileExists(data[4]) and not fileExists(data[5]) then downloadFile(data[1]) downloadFile(data[2]) else engineImportTXD(engineLoadTXD(data[4]),data[3]) engineReplaceModel(engineLoadDFF(data[5],0),data[3]) end end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onStartResourceDeleteFiles) addEventHandler("onClientFileDownloadComplete", getResourceRootElement(getThisResource()),function(file) for _,data in ipairs(replace_model) do if file == data[1] or file == data[2] then fileRename(data[1],data[4]) fileRename(data[2],data[5]) engineImportTXD(engineLoadTXD(data[4]),data[3]) engineReplaceModel(engineLoadDFF(data[5],0),data[3]) end end end) Parece que o "OnClientFileDownloadComplete" não funciona, pq o arquivo não troca o nome.
-
Obrigado, vou dar uma olhada e vou ver o que posso fazer, vou deixar o MySQL de lado e tentar fazer com SQLite!
-
Poderia me dar um exemplo de call?
-
Vou usar os dois, mais gostaria de usar o MySQL caso precise lá na frente de puxar algum dado para o site, como rank, jogadores online, etc.. essas coisas, ou tbm utilizar para o login do server no site.
-
Eu pensei que fazer isso, tipo criar uma nova coluna com o nome "rank" e se for 5 = admin, 4 = mod etc... mas o que eu queria saber é como posso verificar se tal jogador é admin ou não, como por exemplo, ele entra no servidor e faz uma verificação no banco de dados nessa coluna "rank" caso esteja 0 = jogador mas caso esteja 5 = admin, fazendo essa verificação eu queria saber como vou permitir os comandos, no ALC é liberado o painel pela letra "P", é possível eu liberar essa função usando MySQL? igual adicionar no ACL o serial do jogador? Estou usando essa maneira de login, apenas a fase de testes: Mysql sistema - server.lua: local MySQL = nil function Database(host, user, pass, database) MySQL = dbConnect('mysql', ('dbname=%s;host=%s;port=%d'):format(database, host, (tonumber(port) or 3306)), user, pass) if (not MySQL) then outputDebugString('[DB] * Não foi possível conectar ao servidor!') stopResource(getThisResource()) else Query("SET NAMES utf8;") setTimer(Query,1000*60*2,0,'SET NAMES utf8;') outputDebugString('[DB] * Conexão relizada com sucesso!') end end function deDatabase() if (MySQL) then destroyElement(MySQL) end end function Query(query, ...) local queryHandle = dbQuery(MySQL, query, ...) local r1, r2, r3 = dbPoll(queryHandle, -1) if (not r1) then outputDebugString(('Query failed: errCode: %d - errMsg: %s'):format(r2, r3)) return false end return r1, r2, r3 end function Exec(query, ...) return dbExec(MySQL, query, ...) end addEventHandler('onResourceStart', resourceRoot, function () Database("127.0.0.1", "root", "", "db") end ) addEventHandler('onResourceStop', resourceRoot, function () deDatabase() end ) Login sistema - server.lua local mysql = exports.mysql --MySQL Resource function submitlogin(name, serial, player) local query, result = mysql:Query('SELECT `serial` FROM `contas` WHERE `serial` = ?', tostring(serial)) if (query) then if (result > 0) then --outputChatBox ( 'SERIAL: '..serial, source) triggerEvent("onPlayerLogin", getRootElement(), serial, player, source) outputDebugString('Jogador fez login!') else local pass = createRandomPassword (10) local query = mysql:Exec('INSERT INTO `contas` (`id`, `name`, `pass`, `serial`) VALUES (NULL, ?, ?, ?)', name, string.sub(md5(pass),1,24), tostring(serial)) if (query) then --outputChatBox ( 'SERIAL: '..serial, source) triggerEvent("onPlayerRegister", getRootElement(), serial, player, source) outputDebugString('Jogador registrado!') end end end end addEvent("submitlogin", true) addEventHandler("submitlogin", getRootElement(), submitlogin)
-
Olá, eu tentei dar admin pelo ACL usando login mysql, mas sem sucesso, como eu posso dar admin para um player com login mysql? Eu preciso criar um recurso apenas para admin? tipo um painel de administração com comandos? etc...
-
Guys, after a long time I figured out what it was, the temporary files, were conflicting with the server files. Thank you all! I used the example of: Mr.Loki But I'm sure the example of: Dimos7, is running too! Code that worked, I did not want to store the skins and even then the code worked. -- Server-side addEventHandler( "onPlayerQuit", root, function( ) local serial = getPlayerSerial( source ) lastSkinTable[serial] = getElementModel( source ) outputDebugString(lastSkinTable[serial]) end ) addEvent( "onRequestLastSkin", true ) addEventHandler( "onRequestLastSkin", root, function( ) local serial = getPlayerSerial( source ) triggerClientEvent( source, "onGetLastSkin", source, lastSkinTable[serial] ) end ) --Client-side addEvent( "onGetLastSkin", true ) addEventHandler( "onGetLastSkin", root, function( skinID ) local ped = createPed((skinID or 0),-1600.9000244141,-1620.6999511719,36.599998474121,241.908905,0,0) end )
-
Please see your inbox.
-
Black screen, This time I give up, better make another input panel.
-
[2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:61: Bad argument @ 'getPlayerName' [Expected element at argument 1, got nil] [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:61: Bad argument @ 'getPlayerAccount' [Expected element at argument 1, got boolean] [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:62: Bad argument @ 'getAccountData' [Expected account at argument 1, got boolean] [2019-02-24 18:43:34] WARNING: [Gamemode]\login\server.lua:63: Bad argument @ 'createPed' [Expected bool at argument 6, got number '0']
-
I want before the login.
-
Personally the "Mr.Loki" example is what I get closer, but I can not get the data from the file to check on the client. File: skinDB.json [ { "2CE273F16F6AE8C5C248E511F0FAF9A1": 189 } ] I do not know how to open this in the client and get the "id" of the skin, how can I explain, I do not know how to get the serial and do a verification of the serial of the player, if you can do the verification of the two serial, in the "createPed". I'm trying to do it all the way, but it's impossible.
-
The skin of id "0" has appeared, but can not get the data of the player that was logged in before. Edit: I'm almost giving up, I think I'd better try to make another entry.
-
Ajuda - createPed deslogar e entrar no servidor
Furious replied to Furious's topic in Programação em Lua
Agluém? -
Without success yet, nothing appears. I will explain better, when the player leaves the server "onPlayerQuit" his skin will be saved and when entering the server "onClientResourceStart" a skin that was already with him, will be loaded in the "createPed", this before he log in.
-
Alguém pode me ajudar nesse tópico? eu não consigo pegar os dados do arquivo e transferir para o client-side:
-
I think you do not understand, I wanted to know how I open the file and I get the "serial" and the "skin" id from inside the file. Example: function onPlayerCheckSkin() local accountName = getPlayerName(getLocalPlayer()) local playeraccount = getPlayerAccount(accountName) if (playeraccount) then local playerSkin = lastSkinTable[serial] if (playerSkin) then return playerSkin end end end I do not know how I open the file "skinDB.json" and get its data.
-
Hello, I can not figure out how to get the data out of the file.
-
Can someone save me?
-
How do I get the data from the table and step into the client?
-
I can not do it, something very complicated!
-
My problem is checking on the client side, how can I check on the client side that skin belongs to the player before he logs in?
-
So I use "fileCreate" on the server-side with "onPlayerQuit" and on the client-side I use "FileOpen"?
-
Could you tell me which side is "toJSON" and "fromJSON"? Server-side or Client-side?