Jump to content

Little Help Please


Recommended Posts

I just wanna when i say /kazandik , everyone see this but now when i say /kazandik only i see this and only i listen that music . Help please I am newbie

function startMusic() 
    setRadioChannel(0) 
    song = playSound("music2.mp3",true) 
    outputChatBox ( "#FFFFFFGenius Monsters #33ff00Kazandı!", 255, 255, 255, true ) 
end 
  
function makeRadioStayOff() 
    setRadioChannel(0) 
    cancelEvent() 
end 
  
function toggleSong() 
    if not songOff then 
        setSoundVolume(song,0) 
        songOff = true 
        removeEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) 
    else 
        setSoundVolume(song,1) 
        songOff = false 
        setRadioChannel(0) 
        addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) 
    end 
end 
  
addCommandHandler ( "kazandik", startMusic ) 
addEventHandler("onClientPlayerRadioSwitch",getRootElement(),makeRadioStayOff) 
addEventHandler("onClientPlayerVehicleEnter",getRootElement(),makeRadioStayOff) 
addCommandHandler("musicmusic",toggleSong) 
bindKey("m","down","musicmusic") 

Link to comment

You can either go through events and trigger a client-sided event from server-side or, create a client-sided command and execute it from server-side. Both examples:

  
-- #1 
-- Server 
addCommandHandler("kazandik", 
    function(player, command, ...) 
        triggerClientEvent(root, "kazandik_music", root) -- trigger this event for every player belonging to the root element, which should trigger for everyone in case you did not change any player's parent element 
    end 
) 
-- Client / Add the snippet bellow into your code 
addEvent("kazandik_music", true) 
addEventHandler("kazandik_music", root, 
    function() 
        startMusic() -- calling and executing startMusic 
    end 
) 
----------------- 
-- #2 
-- Server 
addCommandHandler("kazandik_all", -- As both, server and client sided commands, can not be named the same - we are using a different one 
    function(player, command, ...) 
        executeCommandHandler("kazandik", root) -- not sure if root can be used here instead of a player element directly / executing 'kazandik', your client-sided command that does the thing 
        -- and in case that does not work 
        for _, v in ipairs(getElementsByType("player")) do -- we iterate over a table returned by 'getElementsByType' that contains all players and 
            executeCommandHandler("kazandik", v) -- execute the command for each one of them 
        end 
     
    end 
) 
  

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