ALE34 Posted July 24, 2013 Posted July 24, 2013 menopeli.lua:11 attempt to perfom arithmetic on local z (a nil value) i dont know what i do wrong function startScript () menopeli34 = createObject (5837, 0, 0, 100, 0, 0, 0) end function menopeli (cmd, posX, posY, posZ) moveObject ( menopeli34, 15000, posX, posY, posZ ) end function kutsumenopeli ( cmd, thePlayer ) local x, y, z = getElementPosition ( thePlayer ) moveObject ( menopeli34, 15000, x, y, z + 10 ) end function menowarp ( cmd, who ) local kohde = getPlayerFromName ( who ) if ( kohde ) then local x,y,z = getElementPosition ( kohde ) moveObject ( menopeli34, 15000, x, y, z + 50 ) end end addCommandHandler ( "kohdemeno", menowarp ) addCommandHandler ( "kutsumeno", kutsumenopeli ) addCommandHandler ( "meno", menopeli ) addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), startScript)
Vector Posted July 24, 2013 Posted July 24, 2013 function startScript () menopeli34 = createObject (5837, 0, 0, 100, 0, 0, 0) end function menopeli (thePlayer, cmd, posX, posY, posZ) moveObject ( menopeli34, 15000, posX, posY, posZ ) end function kutsumenopeli (thePlayer, cmd) local x, y, z = getElementPosition ( thePlayer ) moveObject ( menopeli34, 15000, x, y, z + 10 ) end function menowarp (who, cmd) local kohde = getPlayerFromName ( who ) if ( kohde ) then local x,y,z = getElementPosition ( kohde ) moveObject ( menopeli34, 15000, x, y, z + 50 ) end end addCommandHandler ( "kohdemeno", menowarp ) addCommandHandler ( "kutsumeno", kutsumenopeli ) addCommandHandler ( "meno", menopeli ) addEventHandler ("onResourceStart", getResourceRootElement(getThisResource()), startScript) there are two kinds of people: those who know C++ and those who don´t. .)
Vector Posted July 24, 2013 Posted July 24, 2013 the problem is that the command handler arguments are: 1ºst the Player who type the command. 2ºnd the command. then, the parameters. check this page. https://wiki.multitheftauto.com/wiki/AddCommandHandler there are two kinds of people: those who know C++ and those who don´t. .)
TAPL Posted July 24, 2013 Posted July 24, 2013 menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ) if posX and posX and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 10) end addCommandHandler("kutsumeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 50) end end addCommandHandler("kohdemeno", menowarp)
ALE34 Posted July 24, 2013 Author Posted July 24, 2013 menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ) if posX and posX and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 10) end addCommandHandler("kutsumeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 50) end end addCommandHandler("kohdemeno", menowarp) Thanks a lot! only one thing missed : local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ)
ALE34 Posted July 24, 2013 Author Posted July 24, 2013 now when the other part of the script works im trying to attach playsound3d to the object: no errors it just doesnt work server: function startscript menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) end addEventHandler ( "onResourceStart", getRootElement(), startscript) function menomusa (menopeli34) triggerClientEvent ( "playSoundOnStart", getRootElement, menopeli34) end addCommandHandler ( "turnupthemusic", menomusa ) function afterSound(radio) if menopeli34 and radio then attachElements ( radio, menopeli34 ) end end addEvent("afterSoundCreation") addEventHandler("afterSoundCreation",getRootElement(),afterSound) client: function musa ( menopeli34) if menopeli34 then local x,y,z = getElementPosition ( menopeli34 ) radio = playSound3D( "https://dl.dropboxusercontent.com/s/9z9n7oez2d55xif/amispoppia_-_waves-hZ35j1c6BJw_fmt34.mp3", x, y, z, true) setSoundMaxDistance( radio, 200 ) outputChatBox ( "music is on!", source, 255, 0, 0, true ) triggerServerEvent ( "afterSoundCreation",getRootElement, radio) else outputChatBox ( "cant find the menopeli", getRootElement(), 255, 0, 0, true ) end end addEvent("playSoundOnStart", true) addEventHandler("playSoundOnStart",getRootElement(), musa)
iMr.3a[Z]eF Posted July 24, 2013 Posted July 24, 2013 Why triggering? function startscript( ) menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) end addEventHandler ( "onClientResourceStart", getRootElement(), startscript) function menomusa (menopeli34, radio) if menopeli34 and radio then local x,y,z = getElementPosition ( menopeli34 ) radio = playSound3D( "https://dl.dropboxusercontent.com/s/9z9n7oez2d55xif/amispoppia_-_waves-hZ35j1c6BJw_fmt34.mp3", x, y, z, true) attachElements ( radio, menopeli34 ) setSoundMaxDistance( radio, 200 ) outputChatBox ( "music is on!", source, 255, 0, 0, true ) else outputChatBox ( "cant find the menopeli and radio", getRootElement(), 255, 0, 0, true ) end end addCommandHandler ( "startTheMusic", menomusa ) function stopSound( ) stopSound(radio) end addCommandHandler ( "stopTheMusic", stopSound ) To Visit Us Press Here: mtasa://5.9.206.180:22002
iMr.3a[Z]eF Posted July 24, 2013 Posted July 24, 2013 menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ) if posX and posX and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 10) end addCommandHandler("kutsumeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 50) end end addCommandHandler("kohdemeno", menowarp) your code will not working this is the reason local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ) To Visit Us Press Here: mtasa://5.9.206.180:22002
DNL291 Posted July 24, 2013 Posted July 24, 2013 function stopSound( ) stopSound(radio) end addCommandHandler ( "stopTheMusic", stopSound ) Stack overflow. Please do not PM me with scripting related question nor support, use the forums instead.
iMr.3a[Z]eF Posted July 25, 2013 Posted July 25, 2013 If you don't want to stop the sound so remove the function and the command. To Visit Us Press Here: mtasa://5.9.206.180:22002
TAPL Posted July 25, 2013 Posted July 25, 2013 menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ) if posX and posX and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 10) end addCommandHandler("kutsumeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 50) end end addCommandHandler("kohdemeno", menowarp) your code will not working this is the reason local posX = tonumber(posX) local posX = tonumber(posY) local posZ = tonumber(posZ) Ops, how did i repeat posX two time :@
ALE34 Posted July 25, 2013 Author Posted July 25, 2013 Why triggering? function startscript( ) menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) end addEventHandler ( "onClientResourceStart", getRootElement(), startscript) function menomusa (menopeli34, radio) if menopeli34 and radio then local x,y,z = getElementPosition ( menopeli34 ) radio = playSound3D( "https://dl.dropboxusercontent.com/s/9z9n7oez2d55xif/amispoppia_-_waves-hZ35j1c6BJw_fmt34.mp3", x, y, z, true) attachElements ( radio, menopeli34 ) setSoundMaxDistance( radio, 200 ) outputChatBox ( "music is on!", source, 255, 0, 0, true ) else outputChatBox ( "cant find the menopeli and radio", getRootElement(), 255, 0, 0, true ) end end addCommandHandler ( "startTheMusic", menomusa ) function stopSound( ) stopSound(radio) end addCommandHandler ( "stopTheMusic", stopSound ) triggering because im trying to attach the music to moving object: menopeli34' client: function musa ( menopeli34) if menopeli34 then local x,y,z = getElementPosition ( menopeli34 ) radio = playSound3D( "https://dl.dropboxusercontent.com/s/9z9n7oez2d55xif/amispoppia_-_waves-hZ35j1c6BJw_fmt34.mp3", x, y, z, true) setSoundMaxDistance( radio, 200 ) outputChatBox ( "music is on!", source, 255, 0, 0, true ) attachElements ( radio, menopeli34 ) else outputChatBox ( "cant find the menopeli", getRootElement(), 255, 0, 0, true ) end end addEvent("playSoundOnStart", true) addEventHandler("playSoundOnStart",getRootElement(), musa) server: function startscript menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) end addEventHandler ( "onResourceStart", getRootElement(), startscript) function menomusa (menopeli34) triggerClientEvent ( "playSoundOnStart", getRootElement, menopeli34) end addCommandHandler ( "turnupthemusic", menomusa ) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posY = tonumber(posY) local posZ = tonumber(posZ) if posX and posX and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 1 ) end addCommandHandler("callmeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 25) end end addCommandHandler("targetmeno", menowarp) function pikameno(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 1000, x, y, z + 25) end end addCommandHandler("fasttarget", pikameno) function nousumeno(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 20000, x, y, z + 1000) end addCommandHandler("goup", nousumeno)
TAPL Posted July 25, 2013 Posted July 25, 2013 -- Client Side -- function musa(object) if object then local x,y,z = getElementPosition(object) radio = playSound3D("https://dl.dropboxusercontent.com/s/9z9n7oez2d55xif/amispoppia_-_waves-hZ35j1c6BJw_fmt34.mp3", x, y, z, true) setSoundMaxDistance(radio, 200) outputChatBox("music is on!", 255, 0, 0, true) attachElements(radio, menopeli34) else outputChatBox("cant find the menopeli and radio", 255, 0, 0, true) end end addEvent("playSoundOnStart", true) addEventHandler("playSoundOnStart", root, musa) -- Server Side -- menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) function menomusa(player) triggerClientEvent(root, "playSoundOnStart", player, menopeli34) end addCommandHandler("turnupthemusic", menomusa) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posY = tonumber(posY) local posZ = tonumber(posZ) if posX and posY and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 1 ) end addCommandHandler("callmeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 25) end end addCommandHandler("targetmeno", menowarp) function pikameno(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 1000, x, y, z + 25) end end addCommandHandler("fasttarget", pikameno) function nousumeno(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 20000, x, y, z + 1000) end addCommandHandler("goup", nousumeno)
ALE34 Posted July 25, 2013 Author Posted July 25, 2013 -- Client Side -- function musa(object) if object then local x,y,z = getElementPosition(object) radio = playSound3D("https://dl.dropboxusercontent.com/s/9z9n7oez2d55xif/amispoppia_-_waves-hZ35j1c6BJw_fmt34.mp3", x, y, z, true) setSoundMaxDistance(radio, 200) outputChatBox("music is on!", 255, 0, 0, true) attachElements(radio, menopeli34) else outputChatBox("cant find the menopeli and radio", 255, 0, 0, true) end end addEvent("playSoundOnStart", true) addEventHandler("playSoundOnStart", root, musa) -- Server Side -- menopeli34 = createObject(5837, 0, 0, 100, 0, 0, 0) function menomusa(player) triggerClientEvent(root, "playSoundOnStart", player, menopeli34) end addCommandHandler("turnupthemusic", menomusa) function menopeli(player, cmd, posX, posY, posZ) local posX = tonumber(posX) local posY = tonumber(posY) local posZ = tonumber(posZ) if posX and posY and posZ then moveObject(menopeli34, 15000, posX, posY, posZ) end end addCommandHandler("meno", menopeli) function kutsumenopeli(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 15000, x, y, z + 1 ) end addCommandHandler("callmeno", kutsumenopeli) function menowarp(player, cmd, who) local kohde = getPlayerName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 15000, x, y, z + 25) end end addCommandHandler("targetmeno", menowarp) function pikameno(player, cmd, who) local kohde = getPlayerFromName(who) if (kohde) then local x, y, z = getElementPosition(kohde) moveObject(menopeli34, 1000, x, y, z + 25) end end addCommandHandler("fasttarget", pikameno) function nousumeno(player) local x, y, z = getElementPosition(player) moveObject(menopeli34, 20000, x, y, z + 1000) end addCommandHandler("goup", nousumeno) Thanks! you missed only one thing again attachElements(radio, menopeli34) -- this wont work attachElements(radio, object) -- this will work
iMr.3a[Z]eF Posted July 26, 2013 Posted July 26, 2013 Yes, attachElements(radio, menopeli34) will work, because menopeli34 is the object name. To Visit Us Press Here: mtasa://5.9.206.180:22002
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now