Jump to content

createProjectile


Sasu

Recommended Posts

function fuego(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) 
if ( not clickedElement ) then return end 
if state == "down" and clickedElement and getElementType ( clickedElement ) == "vehicle" and getElementType ( clickedElement ) == "player" then 
local x,y,z = getElementRotation ( localPlayer ) 
local rx,ry,rz =  getElementPosition ( localPlayer ) 
kame = playSound3D("kame.mp3", rx, ry, rz) 
setTimer(createProjectile, 3500, 1, localPlayer, 20, rx, ry, rz, 200, clickedElement, x, y, z) 
if kame then 
setTimer(stopSound, 7000, 1, kame) 
end 
end 
end 
addEventHandler("onClientClick", root, fuego) 
  

Why this dont work?

No errors on debug.

Link to comment

You used "and" instead of "or" to check if the clicked element is a vehicle or player.

function fuego(button, state, absoluteX, absoluteY, worldX, worldY, worldZ, clickedElement) 
    if (not clickedElement) then return end 
    if state == "down" and getElementType ( clickedElement ) == "vehicle" or "player" then 
        local x, y, z = getElementRotation ( localPlayer ) 
        local rx,ry,rz =  getElementPosition ( localPlayer ) 
        kame = playSound3D("kame.mp3", rx, ry, rz) 
        setTimer(createProjectile, 3500, 1, localPlayer, 20, rx, ry, rz, 200, clickedElement, x, y, z ) 
        if kame then 
            setTimer(stopSound, 7000, 1, kame) 
        end 
    end 
end 
addEventHandler("onClientClick", root, fuego) 

EDIT: Ah, haven't seen the new post.

Link to comment

Another script:

function mp3url(cmd, url) 
if isElement(sound) then 
destroyElement(sound) 
end 
local x,y,z = getElementPosition(localPlayer) 
sound = playSound3D(url, x, y, z) 
attachElements(sound, localPlayer) 
setSoundMaxDistance(sound, 100) 
end 
addCommandHandler("url", mp3url) 

Why others players near me cant listen the music?

Link to comment
Another script:
function mp3url(cmd, url) 
if isElement(sound) then 
destroyElement(sound) 
end 
local x,y,z = getElementPosition(localPlayer) 
sound = playSound3D(url, x, y, z) 
attachElements(sound, localPlayer) 
setSoundMaxDistance(sound, 100) 
end 
addCommandHandler("url", mp3url) 

Why others players near me cant listen the music?

I presume this is in client? so it execute the script only on your pc, you should make the commandHandler in server, and trigger the client function.

Link to comment

Client:

function mp3url(source, url, x, y, z) 
if isElement(sound) then 
destroyElement(sound) 
end 
sound = playSound3D(url, x, y, z) 
attachElements(sound, source) 
setSoundMaxDistance(sound, 100) 
end 
addEvent("onPlayerRequestMusic", true) 
addEventHandler("onPlayerRequestMusic", getRootElement(), mp3url) 
  
function parar() 
if isElement(sound) then 
destroyElement(sound) 
end 
end 
addEvent("onPlayerRequestStopMusic", true) 
addEventHandler("onPlayerRequestStopMusic", getRootElement(), parar) 
  

Server:

function mp3(source, cmd, url) 
local x,y,z = getElementPosition(source) 
triggerClientEvent("onPlayerRequestMusic", getRootElement(), source, url, x, y, z) 
end 
addCommandHandler("url", mp3) 
  
function stop() 
triggerClientEvent("onPlayerRequestStopMusic", getRootElement()) 
end 
addCommandHandler("parar", stop) 
  

But nothings happen.

Link to comment
Client:
function mp3url(source, url, x, y, z) 
if isElement(sound) then 
destroyElement(sound) 
end 
sound = playSound3D(url, x, y, z) 
attachElements(sound, source) 
setSoundMaxDistance(sound, 100) 
end 
addEvent("onPlayerRequestMusic", true) 
addEventHandler("onPlayerRequestMusic", getRootElement(), mp3url) 
  
function parar() 
if isElement(sound) then 
destroyElement(sound) 
end 
end 
addEvent("onPlayerRequestStopMusic", true) 
addEventHandler("onPlayerRequestStopMusic", getRootElement(), parar) 
  

Server:

function mp3(source, cmd, url) 
local x,y,z = getElementPosition(source) 
triggerClientEvent("onPlayerRequestMusic", getRootElement(), source, url, x, y, z) 
end 
addCommandHandler("url", mp3) 
  
function stop() 
triggerClientEvent("onPlayerRequestStopMusic", getRootElement()) 
end 
addCommandHandler("parar", stop) 
  

But nothings happen.

I tested this again with someone else and it works.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...