Jump to content

Problems with my script


myjobisgop

Recommended Posts

TAPL, OK, but now there was another problem. So:

  
--Server side 
function stopMusic(thePlayer, key, keyState) 
    local playerVehicle = getPedOccupiedVehicle(thePlayer); 
     
    if (playerVehicle ~= false) then 
        local playerVehicleAttachedElements = getAttachedElements(playerVehicle) 
         
        if playerVehicleAttachedElements then 
            for ElementKey, ElementValue in ipairs (playerVehicleAttachedElements) do 
                if (getElementData(ElementValue, "MusicPlayer") == 1) then 
                    destroyElement(ElementValue); 
                    break; 
                end 
            end 
            outputChatBox("0!", thePlayer, 255, 0, 0, true) 
            return 0 
        else 
            outputChatBox("-2!", thePlayer, 255, 0, 0, true) 
            return (-2) 
        end 
    else 
        outputChatBox("-1!", thePlayer, 255, 0, 0, true) 
        return (-1) 
    end 
end 
  

When i enter 0 button, in chat script whites "0!", but sound doest't stop. Why?

Could this be due to the fact that data element 'MusicPlayer' sets in client side?

Edited by Guest
Link to comment

White color occur when you use client side outputChatBox and put visibleTo argument but it doesn't require it.

But in your case you used it server side (make sure you have it server side in meta).

Also you destroy the sound element in the server side but the sound elements exist client side only and it cannot be destroyed server side.

Link to comment

TAPL, I.e. I must to create a event of music stop on the client side and run it from the server side?

And yet. For example, the player A turned a music player. Then the server goes the new player B. New player B doesn't listen to music, which turned player A. How to make so B could hear A music?

Link to comment
TAPL, I.e. I must to create a event of music stop on the client side and run it from the server side?

Yes, and can be done with other way.

And yet. For example, the player A turned a music player. Then the server goes the new player B. New player B doesn't listen to music, which turned player A. How to make so B could hear A music?

This can be done with more than one way.

You can set element data on the vehicle which will content the sound info path etc .. and when any new player join the server make a loop in client side for all vehicle in the server and get the element data where it will content the path and the you can use playSound.

You can keep all the work in element data, so when you start the sound you just need to set the path as element data and when you stop the sound you just need to set the element data to false. In conjunction with event onClientElementDataChange you can play/destroy the sound element.

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