Hugo_Almeidowski
Members-
Posts
71 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Hugo_Almeidowski
-
I've created a grid list and added a button. What I want to do is after I click the button check what row in the gridlist has been choosen. Also, the same but for EditBoxes. About the gridlists, I saw this link (https://wiki.multitheftauto.com/wiki/GuiGridListGetSelectedItem), but it's really confusing. I can't find anything about the EditBoxes. Thanks for the help. EditBox. I want the code to see what I've written on both EditBoxes after I click buttonE, and give me a weapon with the ID and bullets I've written on the EditBox. You don't need to tell me how to make the second part of that sentence, I'll try to do it by myself, but I can't really understand how to check what's written in the EditBoxes. function armasJanela() local janelaArmas = guiCreateWindow (0.015, 0.18, 0.10, 0.2, "Armas", true) showCursor(true) guiSetInputMode("no_binds_when_editing") guiWindowSetSizable(janelaArmas, false) IDArma = guiCreateEdit(0.1, 0.12, 0.8, 0.15, "ID da Arma [0-46]", true, janelaArmas) guiEditSetMaxLength (IDArma, 20) Balas = guiCreateEdit(0.1, 0.30, 0.8, 0.15, "Balas [0-10000]", true, janelaArmas) guiEditSetMaxLength (Balas, 6) buttonC = guiCreateButton(0.5, 0.87, 0.4, 0.6, "Cancelar", true, janelaArmas) addEventHandler ( "onClientGUIClick", buttonC, cancelamentoJanelaArmas) buttonE = guiCreateButton(0.1, 0.87, 0.4, 0.6, "Escolher", true, janelaArmas) addEventHandler ("onClientGUIClick", buttonE, escolhaJanelaArmas) end addCommandHandler("armas", armasJanela) function cancelamentoJanelaArmas() local destruirArmasJanela = getResourceGUIElement(getThisResource()) destroyElement(destruirArmasJanela) showCursor(false) end function escolhaJanelaArmas() local textoIDArma = guiGetText(IDArma) outputChatBox(textoIDArma) givePedWeapon(localPlayer, textoIDArma, 999, true) local destruirArmasJanela = getResourceGUIElement(getThisResource()) destroyElement(destruirArmasJanela) showCursor(false) end GridLists. I want to get what row was selected after I pressed the buton2 and then read a function based on what row was selected. function janelaJarda (commandName) local jardaJanela = guiCreateWindow (0.25, 0.15, 0.20, 0.4, "Esteróides", true) local lista = guiCreateGridList (0, 0.1, 1, 0.75, true, jardaJanela) guiWindowSetMovable(jardaJanela, true) guiWindowSetSizable(jardaJanela, false) showCursor(true) coluna1 = guiGridListAddColumn(lista, "Nome", 0.49) coluna2 = guiGridListAddColumn(lista, "Propriedades", 0.49) guiGridListAddRow(lista, "Esteróide Máximo", "Jarda potentíssima") guiGridListAddRow(lista, "Esteróide Segundo", "Jarda muito potente") button = guiCreateButton(0.6, 0.87, 0.3, 0.1, "Cancelar", true, jardaJanela) addEventHandler ( "onClientGUIClick", button, cancelamentoJardaJanela) button2 = guiCreateButton(0.1, 0.87, 0.3, 0.1, "Escolher", true, jardaJanela) addEventHandler ("onClientGUIClick", button2, escolhaJarda) end addCommandHandler ("jarda", janelaJarda) function cancelamentoJardaJanela() local destruirJardaJanela = getResourceGUIElement(getThisResource()) destroyElement(destruirJardaJanela) showCursor(false) end function escolhaJarda() local destruirJardaJanela = getResourceGUIElement(getThisResource()) destroyElement(destruirJardaJanela) end function escolhaJarda() end
-
I can't use the command, it says I don't have permission, even tho I gave myself admin. About the debugging messages, I just received one saying joinHandler and the ones when I teleport. The spawn functions are working.
-
It says Incorrect client type for this command. My code: meta.xml <meta> <info author="HugoAlmeida" name="O meu humilde servidor" description="Prepara-te, Bill Gates! Eu venho aí!" /> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> <script src="ficheiro.lua" /> <script src="markers.lua" type="server" /> <script src="markersclient.lua" type="client" /> </meta> client.lua function playerJoin() local chooseSpawn = guiCreateWindow (0.25, 0.15, 0.30, 0.4, "Spawn", true) guiWindowSetMovable(chooseSpawn, true) guiWindowSetSizable(chooseSpawn, false) showCursor(true) buttonLS = guiCreateButton(0.6, 0.87, 0.3, 0.1, "Los Santos", true, chooseSpawn) addEventHandler ("onClientGUIClick", buttonLS, spawnLosSantos, false) buttonSF = guiCreateButton(0.1, 0.87, 0.3, 0.1, "San Fierro", true, chooseSpawn) addEventHandler ("onClientGUIClick", buttonSF, spawnSanFierro, false) end addEventHandler("onClientResourceStart", resourceRoot, playerJoin) function spawnLosSantos() triggerServerEvent("spawnarLosSantos", localPlayer) end function spawnSanFierro() triggerServerEvent("spawnarSanFierro", localPlayer) end server.lua function spawnLS(thePlayer) local thePlayer = thePlayer and thePlayer or source spawnPlayer (thePlayer, 1479, -1672, 14) setCameraTarget(thePlayer, thePlayer) end addEvent("spawnarLosSantos", true) addEventHandler("spawnarLosSantos", root, spawnLS) addCommandHandler("spawnls", spawnLS) addCommandHandler("ls", spawnLS) function spawnSF(thePlayer) local thePlayer = thePlayer and thePlayer or source spawnPlayer (thePlayer, -2706, 376, 5) setCameraTarget(thePlayer, thePlayer) end addEvent("spawnarSanFierro", true) addEventHandler("spawnarSanFierro", root, spawnSF) addCommandHandler("spawnsf", spawnSF) addCommandHandler("sf", spawnSF) function joinHandler() local playerName = getPlayerName(source) fadeCamera(source, true) outputChatBox (horaS.. corMS.. "Sê bem-vindo ao meu servidor, caro " ..corJogador.. playerName.. corMS..".", source, 66, 212, 244, true) end addEventHandler("onPlayerJoin", root, joinHandler)
-
I think I did. Thanks for the help!!! But it's stil not showing up haha
-
Got it! Ok: meta.xml <meta> <info author="HugoAlmeida" name="O meu humilde servidor" description="Prepara-te, Bill Gates! Eu venho aí!" /> <script src="server.lua" type="server" /> <script src="client.lua" type="client" /> <script src="client/gui.lua" type="client" /> <script src="ficheiro.lua" /> <scrpt src="markets.lua" type="server" /> <script src="markersclient.lua" type="client" /> </meta> client.lua: function playerJoin() local chooseSpawn = guiCreateWindow (0.25, 0.15, 0.30, 0.4, "Spawn", true) guiWindowSetMovable(chooseSpawn, true) guiWindowSetSizable(chooseSpawn, false) showCursor(true) buttonLS = guiCreateButton(0.6, 0.87, 0.3, 0.1, "Los Santos", true, chooseSpawn) addEventHandler ("onClientGUIClick", buttonLS, spawnLosSantos, false) buttonSF = guiCreateButton(0.1, 0.87, 0.3, 0.1, "San Fierro", true, chooseSpawn) addEventHandler ("onClientGUIClick", buttonSF, spawnSanFierro, false) end addEventHandler("onClientResourceStart", getRootElement(), playerJoin) function spawnLosSantos() triggerServerEvent(spawnarLosSantos) end function spawnSanFierro() triggerServerEvent(spawnarSanFierro) end server.lua (the functions seem to be working here, because the commands that activate them work): function spawnLS(source) spawnPlayer (source, 1479, -1672, 14) setCameraTarget(source, source) end addEvent("spawnarLosSantos") addEventHandler("spawnarLosSantos", root, spawnLS) addCommandHandler("spawnls", spawnLS) addCommandHandler("ls", spawnLS) function spawnSF(source) spawnPlayer (source, -2706, 376, 5) setCameraTarget(source, source) end addEvent("spawnarSanFierro") addEventHandler("spawnarSanFierro", root, spawnSF) addCommandHandler("spawnsf", spawnSF) addCommandHandler("sf", spawnSF) function joinHandler() local playerName = getPlayerName(source) fadeCamera(source, true) outputChatBox (horaS.. corMS.. "Sê bem-vindo ao meu servidor, caro " ..corJogador.. playerName.. corMS..".", source, 66, 212, 244, true) end addEventHandler("onPlayerJoin", root, joinHandler)
-
Thanks! But what does it trigger for then? Why false? It still isn't showing
-
CLIENT: function playerJoin() local chooseSpawn = guiCreateWindow (0.25, 0.15, 0.30, 0.4, "Spawn", true) guiWindowSetMovable(chooseSpawn, true) guiWindowSetSizable(chooseSpawn, false) showCursor(true) buttonLS = guiCreateButton(0.6, 0.87, 0.3, 0.1, "Los Santos", true, chooseSpawn) addEventHandler ("onClientGUIClick", buttonLS, spawnLosSantos) buttonSF = guiCreateButton(0.1, 0.87, 0.3, 0.1, "San Fierro", true, chooseSpawn) addEventHandler ("onClientGUIClick", buttonSF, spawnSanFierro) end addEventHandler("onClientPlayerJoin", getRootElement(), playerJoin) So. Supposedly, whenever a player joined the server a window with two buttons should appear. When he clicked in one button he would spawn LS, when he clicked on the other button he would spawn in SF. The problem is that the window doesn't even show up. The spawn functions are working because I made them triggable with commands and they work.
-
Thanks. I've read and it's really helpful!
-
Yep. They're right here in front of me and their sound is playing https://imgur.com/a/1dTBa8c
-
It sends me this message: elem:sound000200C6 I don't know what that means, and I didn't know about that inspect thing, I'll study it. @EDIT: everytime i create another Ped, the last digit goes up +1 BTW, I've edited the last message before this one, I don't know if you saw it
-
No error nor any message in the console. And I don't think there's any error in the function that triggers the client event (see below), nor in the function that makes the sound play. function CriarPed (thePlayer, command, id, model, dimensao) local sX, sY, sZ = getElementPosition(thePlayer) ped = createPed(tonumber(model), sX, sY, sZ) pedID = setElementID (ped, id) dimensaoP = setElementDimension(ped, tonumber(dimensao)) if pedID and dimensaoP then qDimensao = getElementDimension(ped) nomePed = getElementID (ped) outputChatBox (horaJ.. "Criaste um ped chamado " ..corPed.. nomePed.. corMJ.. " com o modelo " ..corPed.. model.. corMJ.." na dimensão " ..corEspaco.. tostring(qDimensao).. corMJ.. ".", thePlayer, isR, isG, isB, true) triggerClientEvent ("onPedCriado", thePlayer, ped) else destroyElement(ped) outputChatBox(horaE.. "Uso: /criarped [" ..corPed.. "Nome do Ped" ..corErro.. "] [" ..corPed.. "0" ..corErro.. "-" ..corPed.. "312" ..corErro.. "] [" ..corEspaco.. "0" ..corErro.. "-" ..corEspaco.. "65535" ..corErro.. "].", source, isR, isG, isB, true) end end addCommandHandler("criarped", CriarPed) addCommandHandler("cp", CriarPed) addCommandHandler("criarped", CriarPed) It's weirds because I believe that what you've sent me is perfect... Makes no sense. Oh wait. I've copied it once again, but now the sound starts playing but it doesn't stop whenever the ped dies.
-
Thank you very much for all the explanation and the links! But now the sound doesn't play when I create the ped (and I don't receive the message telling me the ped's name). I tried to make it work but I couldn't
-
Guess who's back. SERVER: function CriarPed (thePlayer, command, id, model, dimensao) local sX, sY, sZ = getElementPosition(thePlayer) ped = createPed(tonumber(model), sX, sY, sZ) pedID = setElementID (ped, id) dimensaoP = setElementDimension(ped, tonumber(dimensao)) if pedID and dimensaoP then qDimensao = getElementDimension(ped) nomePed = getElementID (ped) outputChatBox (horaJ.. "Criaste um ped chamado " ..corPed.. nomePed.. corMJ.. " com o modelo " ..corPed.. model.. corMJ.." na dimensão " ..corEspaco.. tostring(qDimensao).. corMJ.. ".", thePlayer, isR, isG, isB, true) addEventHandler("onPedWasted", ped, pedMorreu) triggerClientEvent ("onPedCriado", thePlayer, ped) else destroyElement(ped) outputChatBox(horaE.. "Uso: /criarped [" ..corPed.. "Nome do Ped" ..corErro.. "] [" ..corPed.. "0" ..corErro.. "-" ..corPed.. "312" ..corErro.. "] [" ..corEspaco.. "0" ..corErro.. "-" ..corEspaco.. "65535" ..corErro.. "].", source, isR, isG, isB, true) end end addCommandHandler("criarped", CriarPed) addCommandHandler("cp", CriarPed) addCommandHandler("criarped", CriarPed) So, in the serverside I made this script that whenever I type /criarped [ID] [model] [dimension] it creates a ped with those parameters and triggers a Client Even named "onPedCriado". CLIENT function TocarSomPed(ped) local pX, pY, pZ = getElementPosition(ped) local dimensaoP = getElementDimension(ped) IDPed = getElementID(ped) outputChatBox("O nome deste ped é " ..IDPed) soundREEE = playSound3D("reeet.mp3", pX, pY, pZ, true) setElementDimension(soundREEE, dimensaoP) attachElements(soundREEE, ped) setarIDSom = setElementID(soundREEE, IDPed) IDSom = getElementID(setarIDSom) outputChatBox("O nome deste som é " ..tostring(IDSom)) addEventHandler("onClientPedWasted", getRootElement(), pedMorreuClient) end addEvent("onPedCriado", true) addEventHandler("onPedCriado", root, TocarSomPed) function pedMorreuClient(setarIDSom) IDSound = getElementByID(setarIDSom) if setarIDSom and getElementByID(setarIDSom) then destroyElement(getElementByID(setarIDSom)) outputChatBox("O som " ..tostring(IDSom)) else outputChatBox("Erro") end end The onPedCriado event triggers the function TocarSomPed that creates a 3D Sound and attaches it to the ped. It also gets the ped ID (and correctly sends me a message with the name of the ped). Now, supposedly, after creating the 3dSound, it should get the ped ID, give that same ID to the 3dsound and send me a message saying the ID of the sound, but instead it sends me one saying the ID of that sound is false. Anyways, if the ped died, it would activate the function pedMorreuClient, get the ElementByID of the sound and destroy it, but it doesn't. Sorry, once again. And thanks for the help. PS: If I just simply destroyed the Element without trying to get his ID, it would just destroy the sound of the last ped I created. If I killed one I created before the last ped, he's sound would keep playing forever.
-
OHHHHHH Thanks man it worked! I didn't know that function existed. If I'm not mistaken, I've actually looked for something like that but couldn't find nothing. Thanks!! Yes. Sometimes I have about 20 wiki pages opened hahaha. Thanks!
-
It doesn't work. I had already tried it like that. It returns me this error when I type /matarped hugo: Bad Argument @ killPed expected element at argument 1, got hugo And this when I just type /matarped Bad Argument @ killPed expected element at argument 1, got nill
-
I use command /cp NameOfThePed ModelOfThePed DimensionOfThePed Ex: /cp Hugo 23 0 Now, I have a command to kill the ped, called /matarped. But it only kills the last ped I've created. I want it to kill the ped that has the name that I've putten on argument1. In this case it would be /matarped Hugo But I can't do it.
-
So, I made a script where you can create a ped and give him an ID, a model and a dimension. function CriarPed (thePlayer, command, id, model, dimensao) local sX, sY, sZ = getElementPosition(thePlayer) ped = createPed(tonumber(model), sX, sY, sZ) pedID = setElementID (ped, id) dimensaoP = setElementDimension(ped, dimensao) if pedID and dimensaoP then qDimensao = getElementDimension(ped) nomePed = getElementID (ped) outputChatBox (horaJ.. "Criaste um ped chamado " ..corPed.. nomePed.. corMJ.. " com o modelo " ..corPed.. model.. corMJ.." na dimensão " ..corEspaco.. qDimensao.. corMJ.. ".", thePlayer, isR, isG, isB, true) addEventHandler("onPedWasted", ped, pedMorreu) addCommandHandler("matarped", matarPed) else destroyElement(ped) outputChatBox(horaE.. "Uso: /criarped [" ..corPed.. "Nome do Ped" ..corErro.. "] [" ..corPed.. "0" ..corErro.. "-" ..corPed.. "312" ..corErro.. "] [" ..corEspaco.. "0" ..corErro.. "-" ..corEspaco.. "65535" ..corErro.. "].", source, isR, isG, isB, true) end end addCommandHandler("criarped", CriarPed) addCommandHandler("cp", CriarPed) addCommandHandler("criarped", CriarPed) function matarPed(player, command) if killPed (ped) then outputChatBox("Mataste") else outputChatBox("Erro") end end Now, what I'm trying to do, but can't, is to be able to use /matarped [pedID] to kill the ped with that ID. For now, I can only kill the last one I created. I've read something about loops, but I'm not sure about how it works and can't apply it to my code by myself. Thanks for the help! Sorry for making so many posts, but I only do them when I really can't continue all by myself, and if you notice, my coding has gotten better by each post I made and you guys help me solve. Thanks!
-
Export an element from server to client
Hugo_Almeidowski replied to Hugo_Almeidowski's topic in Scripting
Thank you very much. I think I've got it. I'll try it whenever I get home. -
Why is this yet another code not working?
Hugo_Almeidowski replied to Hugo_Almeidowski's topic in Scripting
It worked! Thanks! I just don't get why mine didn't work. -
So, I've created a system to create peds, and whenever they are created, it creates a 3d sound at the player's location. The problem is that I want that sound element to be attached to the ped, which I can't, because the ped creation system is in the server and the sound is in the client. So, is there anyway to export the ped element to the client so I can attach the 3d sound to him or atleast create it at his location, or to export the sound element to the server? Client function TocarSomPed () if ( isElement ( sound ) ) then destroyElement ( sound ) end local pX, pY, pZ = getElementPosition(ped) local sound = playSound3D("reeet.mp3", pX, pY, pZ, true) end addEvent("onPedCriado", true) addEventHandler("onPedCriado", root, TocarSomPed) Server function CriarPed (thePlayer, command, model, id, dimensao) local sX, sY, sZ = getElementPosition(thePlayer) ped = createPed(tonumber(model), sX, sY, sZ) pedID = setElementID (ped, id) dimensaoP = setElementDimension(ped, dimensao) if pedID and dimensaoP then qDimensao = getElementDimension(ped) nomePed = getElementID (ped) outputChatBox (horaJ.. "Criaste um ped chamado " ..corPed.. nomePed.. corMJ.. " com o modelo " ..corPed.. model.. corMJ.." na dimensão " ..corEspaco.. qDimensao.. corMJ.. ".", thePlayer, isR, isG, isB, true) setPedAnimation(ped, "ped", "WOMAN_walknorm") triggerClientEvent ("onPedCriado", thePlayer) else destroyElement(ped) outputChatBox(horaE.. "Uso: /criarped [" ..corPed.. "0" ..corErro.. "-" ..corPed.. "312" ..corErro.. "] [" ..corPed.. "Nome do Ped" ..corErro.. "] [" ..corEspaco.. "0" ..corErro.. "-" ..corEspaco.. "65535" ..corErro.. "].", source, isR, isG, isB, true) end end addCommandHandler("criarped", CriarPed) addCommandHandler("cp", CriarPed) addCommandHandler("criarped", CriarPed)
-
Thanks. I had already switched this code to another resource, which wasn't also working, but now I've taken a look at the meta of that resource and it was wrong.
-
Why is this yet another code not working?
Hugo_Almeidowski replied to Hugo_Almeidowski's topic in Scripting
Doesn't work. The map is showing whenever I enter the map and I get the same error message when I type /mapa. And the console tells me that that command is depracated. Thanks anyways! -
function apagarRadar() setPlayerHudComponentVisible(source, "radar", false) setElementData(source, "semradar", radar) end addEventHandler("onPlayerJoin", root, apagarRadar) function mostrarRadar(thePlayer) local naoTemRadar = getElementData(thePlayer, "semradar") if naoTemRadar then setElementData(thePlayer, "comradar", radar) setPlayerHudComponentVisible(thePlayer, "radar", true) removeElementData(thePlayer, "semradar") else outputChatBox("Já tens um mapa.") end end addCommandHandler("mapa", mostrarRadar) So, the idea: whenever a player join he is given the Data "semradar" and his radar is erased. Whener he types /mapa, it will check if he has the Data "semradar" and if he does, he will erase it, give him the Data "comradar" and set his radar visible. If he already has the data "comradar", it will just send him an error message. The problem is that whenever I type /mapa I just the the error message. It works if I delete the if statement, but in that way I can't send him the error message.
-
It worked! Thank you very much! I will study it!
-
Alright, I've made this: function setPlayerDimension (source, command, dimension) local dimensaoA = getElementDimension(source) local nomeJ = getPlayerName(source) dimensaoB = setElementDimension(source, dimension) if dimensaoB then outputChatBox(horaJ.. "Foste transferido da dimensão " ..corEspaco.. dimensaoA.. " para a dimensão " ..corEspaco.. dimensaoB, source, isR, isG, isB, true) else outputChatBox("Erro") end end addCommandHandler("dimension", setPlayerDimension) But I still get an Error: Bad argument @ 'setElementDimension' Expected element at argument 1, [got string "whatever number I typed After /dimension']. I understand he's telling me to say the element I want to teleport before I say the dimension, but I want it to understand that I want it to teleport whoever type the command.
