Jump to content

createProjectile


Sasu

Recommended Posts

Posted
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.

State: Inactive

Posted

An element can't be a vehicle and a player at the same time.

if getElementType ( clickedElement ) == "vehicle" and getElementType ( clickedElement ) == "player" then 

Owner of [HUN]Magyar Play Szerver 1.4, IP: 31.220.43.153:22003

Posted

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.

 

Posted

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?

State: Inactive

Posted
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.

bruh

Posted

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.

State: Inactive

Posted

Hmm, do you execute the command correctly? Don't forget to give the url you are using in

playSound3D(url, x, y, z) 

like /url song.mp3

bruh

Posted

But before that I change the script works fine but players near me cant listen. :/

State: Inactive

Posted
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.

bruh

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...