Jump to content

Problems


Jaysds1

Recommended Posts

  • Replies 365
  • Created
  • Last Reply

Top Posters In This Topic

To make the 'background' blank (it is blank by default, however) you can use;

fadeCamera(false) 

As for the login GUI, you can use;

guiSetVisible(loginGUIWindow) -- of course, you replace loginGUIWindow with your own variable. 

Link to comment

thnx,

My light and engine script doesn't work. WHY?

  
addEvent ( "bindKeys",true ) 
addEventHandler ( "bindKeys", getRootElement(), 
function() 
    -- Initilize Player Element Data 
    local players = getElementsByType ( "player" ) 
    for k,p in ipairs(players) do 
        if player == source then 
        bindKey ( "f", "down", engineOffOn ) 
        bindKey( "l", "down", changeLightsState ) 
        end 
    end 
end 
) 
  
addEvent ( "unbindKeys",true ) 
addEventHandler ( "unbindKeys", getRootElement(), 
function() 
    -- Initilize Player Element Data 
    local players = getElementsByType ( "player" ) 
    for k,p in ipairs(players) do 
        if player == source then 
        unbindKey ( "f", "down", engineOffOn ) 
        unbindKey( "l", "down", changeLightsState ) 
        end 
    end 
end 
) 
  
function engineOffOn() 
    local vehicle = getPedOccupiedVehicle( source ) 
    if leftseat == 1 then 
        setVehicleEngineState ( vehicle, false ) 
    else 
        setVehicleEngineState ( vehicle, true ) 
    end 
end 
  
function changeLightsState() 
    local vehicle = getPedOccupiedVehicle( source ) 
    if leftseat == 1 then 
        setVehicleOverrideLights( vehicle, 2 ) 
    else 
        setVehicleOverrideLights( vehicle, 1 ) 
    end 
end 
  

Link to comment
  • Moderators
My light and engine script doesn't work. WHY?

Because you have to stop copy the wiki and paste it whithout your brain :roll:

leftseat is not defined in your code and it's come from the wiki exemple GetVehicleEngineState

      
addEvent ( "bindKeys",true ) 
addEventHandler ( "bindKeys", getRootElement(), 
function() 
    -- Initilize Player Element Data 
    local players = getElementsByType ( "player" ) 
    for k,p in ipairs(players) do 
        if player == source then 
            bindKey ( "f", "down", engineOffOn ) 
            bindKey( "l", "down", changeLightsState ) 
        end 
    end 
end 
) 
  
addEvent ( "unbindKeys",true ) 
addEventHandler ( "unbindKeys", getRootElement(), 
function() 
    -- Initilize Player Element Data 
    local players = getElementsByType ( "player" ) 
    for k,p in ipairs(players) do 
        if player == source then 
            unbindKey ( "f", "down", engineOffOn ) 
            unbindKey( "l", "down", changeLightsState ) 
        end 
    end 
end 
) 
  
function engineOffOn() 
    local vehicle = getPedOccupiedVehicle( source ) 
    if ( getVehicleEngineState ( theVehicle ) ~= false ) 
        setVehicleEngineState ( vehicle, false ) 
    else 
        setVehicleEngineState ( vehicle, true ) 
    end 
end 
  
function changeLightsState() 
    local vehicle = getPedOccupiedVehicle( source ) 
    if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then 
        setVehicleOverrideLights( vehicle, 2 ) 
    else 
        setVehicleOverrideLights( vehicle, 1 ) 
    end 
end 

Link to comment

I am using my brain I'm trying to learn scripting easier by using examples from the wiki.

if you looked at my Login GUI resource then you could see that I used wiki......

AND THE (f) button DOESN'T WORK WHEN I TRY TO TURN OFF THE ENGINE!!!

Link to comment

Maybe because you aren't using bindKey right?

addEvent ( "bindKeys",true ) 
addEventHandler ( "bindKeys", getRootElement(), 
function() 
    -- Initilize Player Element Data 
    local players = getElementsByType ( "player" ) 
    for k,p in ipairs(players) do 
        if p == source then 
            bindKey (p, "f", "down", engineOffOn ) 
            bindKey(p, "l", "down", changeLightsState ) 
        end 
    end 
end 
) 
  
addEvent ( "unbindKeys",true ) 
addEventHandler ( "unbindKeys", getRootElement(), 
function() 
    -- Initilize Player Element Data 
    local players = getElementsByType ( "player" ) 
    for k,p in ipairs(players) do 
        if p == source then 
            unbindKey (p, "f", "down", engineOffOn ) 
            unbindKey(p, "l", "down", changeLightsState ) 
        end 
    end 
end 
) 
  
function engineOffOn(player) 
    local vehicle = getPedOccupiedVehicle( player ) 
    if ( getVehicleEngineState ( theVehicle ) ~= false ) 
        setVehicleEngineState ( vehicle, false ) 
    else 
        setVehicleEngineState ( vehicle, true ) 
    end 
end 
  
function changeLightsState(player) 
    local vehicle = getPedOccupiedVehicle( player ) 
    if ( getVehicleOverrideLights ( playerVehicle ) ~= 2 ) then 
        setVehicleOverrideLights( vehicle, 2 ) 
    else 
        setVehicleOverrideLights( vehicle, 1 ) 
    end 
end 

Try that.

Edit: Why do you check if source is one of these players? because if you want to bind it just for the one who triggered the event just bind it for source.

Link to comment

Your problem here is that you just copy & paste from the wiki, you don't even think what you are doing.

addEvent ( "bindKeys",true ) 
addEventHandler ( "bindKeys", getRootElement(), 
function() 
bindKey (source, "f", "down", engineOffOn ) 
bindKey(source, "l", "down", changeLightsState ) 
end) 
  
addEvent ( "unbindKeys",true ) 
addEventHandler ( "unbindKeys", getRootElement(), 
function() 
unbindKey (source, "f", "down", engineOffOn ) 
unbindKey(source, "l", "down", changeLightsState ) 
end) 
  
function engineOffOn(player) 
    local vehicle = getPedOccupiedVehicle( player ) 
    if vehicle then 
    if ( getVehicleEngineState ( vehicle ) ~= false ) then 
        setVehicleEngineState ( vehicle, false ) 
    else 
        setVehicleEngineState ( vehicle, true ) 
        end 
    end 
end 
  
function changeLightsState(player) 
    local vehicle = getPedOccupiedVehicle( player ) 
    if vehicle then 
    if ( getVehicleOverrideLights ( vehicle ) ~= 2 ) then 
        setVehicleOverrideLights( vehicle, 2 ) 
    else 
        setVehicleOverrideLights( vehicle, 1 ) 
        end 
    end 
end 

Link to comment

Well, you could have said that at the start, because it will never work if you won't trigger these events.

addEventHandler ( "onPlayerJoin", getRootElement(), 
function() 
bindKey (source, "f", "down", engineOffOn ) 
bindKey(source, "l", "down", changeLightsState ) 
end) 
  
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), 
function() 
for index, player in pairs(getElementsByType("player")) do 
unbindKey (player, "f", "down", engineOffOn ) 
unbindKey(player, "l", "down", changeLightsState ) 
end) 
  
function engineOffOn(player) 
    local vehicle = getPedOccupiedVehicle( player ) 
    if vehicle then 
    if ( getVehicleEngineState ( vehicle ) ~= false ) then 
        setVehicleEngineState ( vehicle, false ) 
    else 
        setVehicleEngineState ( vehicle, true ) 
        end 
    end 
end 
  
function changeLightsState(player) 
    local vehicle = getPedOccupiedVehicle( player ) 
    if vehicle then 
    if ( getVehicleOverrideLights ( vehicle ) ~= 2 ) then 
        setVehicleOverrideLights( vehicle, 2 ) 
    else 
        setVehicleOverrideLights( vehicle, 1 ) 
        end 
    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...