Jump to content

Problems


Jaysds1

Recommended Posts

  • Replies 365
  • Created
  • Last Reply

Top Posters In This Topic

Posted

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. 

Retired

Posted

No, you can call the function with many ways, command handlers, event handlers, from another function, etc, etc.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 
  

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

  • Moderators
Posted
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 

The rEvolution is coming ...

  • MTA Team
Posted
My light and engine script doesn't work. WHY?

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

Atleast he is using the wiki :P:roll:

Posted

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

My in-game name: Jaysds1

Retired CMG Scripter

World Of Tanks GameMode (Open-Source): https://github.com/Jaysds1/mtasa-wot-gamemode

Online GUI-Editor (WIP): https://forum.mtasa.com/topic/47678-online-gui-editor/

 

sE5Qm.png

TiV3C.png

img.php?id=0&text=Lua%20Scripter

Posted

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.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Well, that resource was really bugged or you messed everything.

Apart from that, is it working?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Well, then you are either lying or not using it as you should, since it works just fine here.

How are you triggering "bindKeys" and "unbindKeys"?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

No problem, but remember this, if you want to get it fixed, tell them what you have.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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