Mimimiguel Posted September 2, 2011 Posted September 2, 2011 Hello all, at first thanks for read it, another of my noobish questions, this: function actualizarPosicionSonido( sound, vehicle ) if sound and vehicle then x, y, z = getElementPosition( vehicle ) setElementPosition( sound, x, y, z ) end end function getSoundPath( id ) if id == 1 then return "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX" elseif id == 2 then return "http://194.169.201.177:8085/live3.mp3" elseif id == 3 then return "http://194.169.201.177:8085/liveDial.mp3" elseif id == 4 then return "http://194.169.201.177:8085/liveser.mp3" elseif id == 5 then return "http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u" elseif id == 7 then return "http://streaming.tst.es/stcasx/va90winlive2001/play.asx" end end sound = { [1] = {}, [2] = {}, [3] = {}, [4] = {}, [5] = {}, [6] = {}} addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, id, player ) if getElementData( player, "radio" ) == false then x, y, z = getElementPosition( veh ) path = getSoundPath( id ) sound[ player ] = playSound3D( path, x, y, z, false ) sound[1] = path sound[2] = x sound[3] = y sound[4] = z sound[5] = guiScrollBarGetScrollPosition (volumebar) / 50 sound[6] = setTimer( actualizarPosicionSonido, 50, 0, sound[player], getPedOccupiedVehicle( player ) ) setSoundMaxDistance( sound[player], maxdistance ) setElementData( player, "radio", true ) setSoundVolume( sound[player], sound[5] or 1 ) else stopSound( sound[ player ] ) sound[ player ] = nil sound[1] = nil sound[2] = nil sound[3] = nil sound[4] = nil sound[5] = nil killTimer( sound[6] ) sound[6] = nil setElementData( player, "radio", false ) end end ) returns: 'attempt to index global 'sound' ( a userdata value )' I did never had a error of this kind before so I don't know whats going on here
Castillo Posted September 3, 2011 Posted September 3, 2011 Try this: function actualizarPosicionSonido( sound, vehicle ) if sound and vehicle then x, y, z = getElementPosition( vehicle ) setElementPosition( sound, x, y, z ) end end function getSoundPath( id ) if id == 1 then return "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX" elseif id == 2 then return "http://194.169.201.177:8085/live3.mp3" elseif id == 3 then return "http://194.169.201.177:8085/liveDial.mp3" elseif id == 4 then return "http://194.169.201.177:8085/liveser.mp3" elseif id == 5 then return "http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u" elseif id == 7 then return "http://streaming.tst.es/stcasx/va90winlive2001/play.asx" end end sound = {} addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, id, player ) if getElementData( player, "radio" ) == false then x, y, z = getElementPosition( veh ) path = getSoundPath( id ) sound[player] = {} sound[player].theSound = playSound3D( path, x, y, z, false ) sound[player].path = path sound[player].x = x sound[player].y = y sound[player].z = z if volumebar then volume = guiScrollBarGetScrollPosition (volumebar) / 50 else volume = 2.5 end sound[player].volume = volume sound[player].timer = setTimer( actualizarPosicionSonido, 50, 0, sound[player].theSound, getPedOccupiedVehicle( player ) ) setSoundMaxDistance( sound[player], maxdistance ) setElementData( player, "radio", true ) setSoundVolume( sound[player], sound[5] or 1 ) else stopSound( sound[ player ] ) killTimer( sound[player].timer ) sound[ player ] = nil setElementData( player, "radio", false ) end end )
Mimimiguel Posted September 3, 2011 Author Posted September 3, 2011 Same error at line 25 in your post
Mimimiguel Posted September 3, 2011 Author Posted September 3, 2011 Could it be some error related with the trigger?
Mimimiguel Posted September 3, 2011 Author Posted September 3, 2011 addEvent( "radio", true ) addEventHandler( "radio", getRootElement(), function ( sound ) if isPedInVehicle( source ) then veh = getPedOccupiedVehicle( source ) triggerClientEvent( "playsound", getRootElement(), veh, sound, source ) end end ) addEvent( "OnCharacterLogin", true ) addEventHandler( "OnCharacterLogin", getRootElement(), function () triggerClientEvent( "sync", source ) end )
Castillo Posted September 3, 2011 Posted September 3, 2011 function actualizarPosicionSonido( sound, vehicle ) if sound and vehicle then x, y, z = getElementPosition( vehicle ) setElementPosition( sound, x, y, z ) end end function getSoundPath( id ) if id == 1 then return "http://salvajefm.com/modules/mod_ngs_shoutcast/singleplaylist.php?ip=94.75.209.28&port=8188&format=ASX" elseif id == 2 then return "http://194.169.201.177:8085/live3.mp3" elseif id == 3 then return "http://194.169.201.177:8085/liveDial.mp3" elseif id == 4 then return "http://194.169.201.177:8085/liveser.mp3" elseif id == 5 then return "http://rtve.stream.flumotion.com/rtve/radio1.mp3.m3u" elseif id == 7 then return "http://streaming.tst.es/stcasx/va90winlive2001/play.asx" end end sound = {} addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, id, player ) if getElementData( player, "radio" ) == false then outputChatBox(tostring(id)) outputChatBox(tostring(getPlayerName(player))) x, y, z = getElementPosition( veh ) path = getSoundPath( id ) sound[player] = {} sound[player].theSound = playSound3D( path, x, y, z, false ) sound[player].path = path sound[player].x = x sound[player].y = y sound[player].z = z if volumebar then volume = guiScrollBarGetScrollPosition (volumebar) / 50 else volume = 2.5 end sound[player].volume = volume sound[player].timer = setTimer( actualizarPosicionSonido, 50, 0, sound[player].theSound, getPedOccupiedVehicle( player ) ) setSoundMaxDistance( sound[player], maxdistance ) setElementData( player, "radio", true ) setSoundVolume( sound[player], sound[5] or 1 ) else stopSound( sound[ player ] ) killTimer( sound[player].timer ) sound[ player ] = nil setElementData( player, "radio", false ) end end ) Tell me if it outputs the sound ID and the player name to chatbox.
Mimimiguel Posted September 3, 2011 Author Posted September 3, 2011 Thanks for the effort, solidsnake, if any other knows how to solve this, please post it. Thanks in advice. Also changed something and the error changed also, here it is the code: addEvent( "playsound", true ) addEventHandler( "playsound", getRootElement(), function( veh, id, player ) if getElementData( player, "radio" ) == false then sound = {} data = sound[ player ] outputDebugString(tostring(id)) outputDebugString(tostring(getPlayerName(player)).." inició la radio") x, y, z = getElementPosition( veh ) path = getSoundPath( id ) data.theSound = playSound3D( path, x, y, z, false ) data.path = path data.x = x data.y = y data.z = z if volumebar then volume = guiScrollBarGetScrollPosition (volumebar) / 50 else volume = 2.5 end data.volume = volume data.timer = setTimer( actualizarPosicionSonido, 50, 0, data.theSound, getPedOccupiedVehicle( player ) ) setSoundMaxDistance( data, maxdistance ) setElementData( player, "radio", true ) setSoundVolume( sound[player], sound[5] or 1 ) else stopSound( sound[ veh ] ) killTimer( data.timer ) sound[ veh ] = nil setElementData( player, "radio", false ) end end ) Reports a nil value in the line 5
MTA Team qaisjp Posted September 5, 2011 MTA Team Posted September 5, 2011 That won't work, your creating another table "data". not redirecting it
Mimimiguel Posted September 5, 2011 Author Posted September 5, 2011 So what do I edit? I'm really lost
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