Jump to content

Hugo_Almeidowski

Members
  • Posts

    71
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Hugo_Almeidowski

  1. Like this? dimensaoB = setElementDimension(dimension) It still doesn't work.
  2. It's still not working, but not it gives no Error... ?
  3. Doesn't work. The sound doesn't play. Thanks anyways! Question: What are you looking after when you put isElement and why the need to check if it is an Element and then to destroy it? Error at pedsclient.lua (the second script): Bad Argument @ addEventHandler Expected element at argument 2, got nil
  4. function setPlayerDimension (source, command, dimension) local dimensaoA = getElementDimension(source) dimensaoB = setElementDimension(source, dimension) outputChatBox(horaJ.. "Foste transferido da dimensão " ..corEspaco.. dimensaoA.. " para a dimensão " ..corEspaco.. dimensaoB, source, isR, isG, isB, true) end addCommandHandler("dimension", setPlayerDimension) I'm trying to set the source to the dimension he writes after /dimension, but the console is returning me this ERROR: attempt to concatenate global 'dimensaoB' (a boolean value) I tried to do it in multiple ways (including with if statements), but it never worked. PS: horaJ and corEspaco are just colors that work fine in every other outputChatBox.
  5. I just managed to do it just now haha, thanks anyways!
  6. (script.lua) function CriarPed (source, command, model) local sX, sY, sZ = getElementPosition(source) ped = createPed(model, sX, sY, sZ) if ped then outputChatBox ("Criaste um ped com o modelo: " .. model .. ".") setPedAnimation(ped, "ped", "WOMAN_walknorm") addEventHandler("onPedWasted", ped, PedMorreu) addCommandHandler("matarped", MatarPed) addCommandHandler("setvp", SetarVidaPed) addCommandHandler("setsp", SetarSkinPed) triggerClientEvent ("onPedCriado", source) else outputChatBox("Uso: /criarped [0-312].") end end addCommandHandler("criarped", CriarPed) addCommandHandler("cp", CriarPed) addCommandHandler("criarped", CriarPed) So, before the else I trigger a Client Event named "onPedCriado", which I then create on the client script (scriptclient.lua); function TocarSomPed () local sound = playSound3D("main/reeet.mp3", 1948, -1713, 13.5, true) end addEvent("onPedCriado", true) addEventHandler("onPedCriado", localPlayer, TocarSomPed) The sound is located in deathmatch > resources > main and this is my meta: <meta> <info author="HugoAlmeida" type="gamemode" name="O meu humilde servidor" description="Prepara-te, Bill Gates! Eu venho aí!" /> <script src="script.lua" /> <script src="scriptclient.lua" type="client" /> <script src="client/gui.lua" type="client" /> <script src="ficheiro.lua" /> <file src="reeet.mp3" /> </meta> What's wrong?
  7. How can I send a multicolored message? outputChatBox("A skin do ped foi definida para: " .. model) I want the model to be from a different color then the rest of the message, how to do it?
  8. Like this?: function CriarPed (source, command, model) local sX, sY, sZ = getElementPosition(source) ped = createPed(model, sX, sY, sZ) if ped then outputChatBox ("Criaste um ped com o modelo: " .. model .. ".") setPedAnimation(ped, "ped", "WOMAN_walknorm") addEventHandler("onPedWasted", ped, PedMorreu) triggerClientEvent(playSound3D("reeet.mp3", 269.36532592773,-1939.908203125,1.2081558704376, true)) else outputChatBox("Uso: /criarped 0-312.") end end addCommandHandler("criarped", CriarPed) addCommandHandler("cp", CriarPed) addCommandHandler("criarpedestre", CriarPed) Now it completely stoped working. It returns this ERROR: Resource is loaded, but has errors (Couldn't parse meta file for resource 'main' [Line 8: error reading tag.] My meta.xml: <meta> <info author="HugoAlmeida" type="gamemode" name="O meu humilde servidor" description="Prepara-te, Bill Gates! Eu venho aí!" /> <script src="script.lua" /> <script src="scriptclient.lua" type="client" /> <script src="client/gui.lua" type="client" /> <script src="ficheiro.lua" /> <file src="reeet.mp3" /> </meta>
  9. So, I'm trying to make a ped have sound, the problem is, I created the ped on the server and it is only possible to create sound on the client. So, how can I apply a 3DSound to my ped? function CriarPed (source, command, model) local sX, sY, sZ = getElementPosition(source) ped = createPed(model, sX, sY, sZ) if (ped) then outputChatBox ("Criaste um ped com o modelo: " .. model .. ".") setPedAnimation(ped, "ped", "WOMAN_walknorm") addEventHandler("onPedWasted", ped, PedMorreu) else outputChatBox("Uso: /criarped 0-312.") end end addCommandHandler("criarped", CriarPed) function PedMorreu(player) outputChatBox("O teu ped morreu.") end
  10. function CriarGemeo (source) local sourceModel = getElementModel(source) local sX, sY, sZ = getElementPosition(source) outputChatBox ("Criaste um ped com o modelo: " .. sourceModel .. ".") twin = createPed(sourceModel, sX, sY, sZ) end addCommandHandler("criargemeo", CriarGemeo) function GemeoMorreu() outputChatBox ("O teu gémeo morreu.") end addEventHandler("onPedWasted", twin, GemeoMorreu) The first function works perfectly (the first one that's not super basic and that I created all by myself (YEY). But the second doesn't work and returns me this ERROR: @ Bad Argument @ 'addEventHandler' [Expected element at argument 2, got nil] I tried to add source and player between the function GemeoMorreu() parenthisis, but it still doesn't work.
  11. Ohhhh thaanks It was set to server. my bad! I changed it to client, ant it work, but now I have another problem. This function stoped working. function toggleSit(thePlayer) setPedAnimation(thePlayer, "ped", "seat_down", -1, false, false, false, true) end addCommandHandler("sit", toggleSit) So, I made two lua scripts. One for client and one for server. The one above was sent to the server script. And the one below was sent to the client script. function playerPressedKey(button, press, thePlayer) if button == "w" then setPedAnimation(thePlayer) end end addEventHandler("onClientKey", root, playerPressedKey) This one was supposed to stop the sit anim in the server script, but it doesn't. why?
  12. function coordenadas (player) local coordenadas = getElementPosition(player) outputChatBox("Estás nas coordenadas " .. coordenadas, player) end addCommandHandler("coordenadas", coordenadas) I want the code to send me a message with the three coordinates I'm in after I type /coordenadas, but it only tells me one coordinate. What's wrong?
  13. Nothing happens when I press W! function playerPressedKey(button, press) if button == "w" then outputChatBox("You pressed the " .. button .. " key!") end end addEventHandler("onClientKey", root, playerPressedKey) And also, if I made a table with various buttons, for example: movement = {"w", "s", "d", "a", "shift"} and substituted the "w" in the first code with movement, would it work (in the fixed version that you're please gonna tell me)? And is there anything wrong with this code? function playerPressedKey(button, press, thePlayer) if button == "w" then setPedAnimation(thePlayer) end end addEventHandler("onClientKey", root, playerPressedKey) Thanks!
  14. Thanks! I've read it! I've been reading the wiki and following tutorials, but there are still a lot of things I don't get.
  15. (sou português, mas não sei se posso falar português aqui) It was on a server-side script, that was the problem. Anyways I can make it into a server-side? And could you take answer me some small questions please?
  16. Thank you very much! BTW, you have a mistake on the second line after getElementPosition Can you please explain why sometimes I don't need to add nothing between the function brackets and other times I have?
  17. function showLocalHealth() -- get the player's health and output it local playerHealth = getElementHealth ( localPlayer ) outputChatBox ( "Your health: " .. playerHealth ) -- get the player's vehicle: if he is in one, output its health as well local playerVehicle = getPedOccupiedVehicle ( localPlayer ) if playerVehicle then local vehicleHealth = getElementHealth ( playerVehicle ) / 10 -- Divide this by 10, as default the denominator is 1000 outputChatBox ( "Your vehicle's health: " .. vehicleHealth ) end end addCommandHandler ( "showhealth", showLocalHealth ) I copied this one directly from the MTA Wiki and it doesn't work. I receive no message. Why? And how to fix it?
  18. function explosion () local pX, pY, pZ = getElementPosition (source) createExplosion (pX, pY, pZ, 6, source) end addCommandHandler ("explodir", explosion) These are the errors when I type the command: Bad argument @ 'getElementPosition' [Expected element at argument 1, got nil] Bad ARgument @ 'createExplosion' [Expected vector 3 at argument 1, got boolean]
×
×
  • Create New...