Jump to content

script help


Stylez

Recommended Posts

Good Evening everybody :)

i have this small script. You should understand what i am trying to do.. i know where i have problem. But i cant solve it :D

the problem is in local vehicle = getPedOccupiedVehicle(source) - source argument.. but as i said, i cant solve this problem :D

Here is the code

function bind() 
local vehicle = getPedOccupiedVehicle(source) 
    if vehicle then 
        local driver = getVehicleOccupant(vehicle) 
            if driver then 
                bindKey(source, "m", "down", bind) 
                triggerClientEvent(source, "bindKey", getRootElement(), "trigger") 
            end 
    else 
        outputChatBox("u need to be in a car",source) 
    end 
end 
addEventHandler("onPlayerVehicleEnter", getRootElement(), bind) 
  

Link to comment

So, what you want to do is bind a key to trigger that event?

function bind ( ) 
    bindKey ( source, "m", "down", trigger ) 
end 
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), bind ) 
  
function trigger ( thePlayer ) 
    if ( isPedInVehicle ( thePlayer ) ) then 
        triggerClientEvent ( thePlayer, "bindKey", getRootElement(), "trigger" ) 
    else 
        outputChatBox ( "u need to be in a car", thePlayer ) 
    end 
end 

Link to comment

Here. i tried to bind m key when player enters vehicle, so i could show and hide mouse.

function cursor(button, state) 
    if showCursor == false then 
        showCursor(true) 
    else 
        showCursor(false) 
    end 
end 
function bind () 
    bindKey("m", "down", cursor) 
end 
addEventHandler("onClientPlayerVehicleEnter", getRootElement(), bind) 

Link to comment

Hey, solidsnake. i have new problem with same script. Everything works, just when i click on vehicle it opens 99999999+ window.

function masiniukui() 
    mainWin = guiCreateWindow(0.80, 0.15, 0.20, 0.60,"WINDOW!!!!!!!!!", true) 
    local car = getPedOccupiedVehicle(getLocalPlayer()) 
        if car then 
            local driver = getVehicleOccupant(car) 
                if driver then 
                    if isPedInVehicle(driver) then 
                        local carClick  = getPedOccupiedVehicle(driver) 
                            if carClick then 
                                guiSetVisible(mainWin, true) 
                            end 
                    end 
                end 
        end 
end 
addEventHandler("onClientClick", getRootElement(), masiniukui) 
  
function cursor( ) 
    if not isCursorShowing() then 
        showCursor(true) 
    else 
        showCursor(false) 
        guiSetVisible(mainWin, false) 
    end 
end 
function bind (thePlayer, seat) 
    if source == localPlayer then 
        bindKey( "m", "down", cursor) 
    end 
end 
addEventHandler("onClientPlayerVehicleEnter", getRootElement(), bind) 
  

Link to comment
mainWin = guiCreateWindow(0.80, 0.15, 0.20, 0.60,"WINDOW!!!!!!!!!", true) 
guiSetVisible ( mianWin, false ) 
  
function masiniukui() 
    local car = getPedOccupiedVehicle(getLocalPlayer()) 
        if car then 
            local driver = getVehicleOccupant(car) 
                if driver then 
                    if isPedInVehicle(driver) then 
                        local carClick  = getPedOccupiedVehicle(driver) 
                            if carClick then 
                                guiSetVisible(mainWin, true) 
                            end 
                    end 
                end 
        end 
end 
addEventHandler("onClientClick", getRootElement(), masiniukui) 
  
function cursor( ) 
    if not isCursorShowing() then 
        showCursor(true) 
    else 
        showCursor(false) 
        guiSetVisible(mainWin, false) 
    end 
end 
function bind (thePlayer, seat) 
    if source == localPlayer then 
        bindKey( "m", "down", cursor) 
    end 
end 
addEventHandler("onClientPlayerVehicleEnter", getRootElement(), bind) 

You was creating the window every time.

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