Jump to content

HELP :D


Recommended Posts

i made this script and i don't know what's wrong, please help:

  
-- ClientSide 
local car = getPedOccupiedVehicle(getLocalPlayer()) 
local carV = getElementAlpha(car) 
  
bindKey("F1", down,  
    function() 
        if (carV == 0) then 
            setElementAlpha(car, 1) 
            outputChatBox("[iNFO] the vehicles are visible now.",166,255,6) 
        elseif (carV == 1) then 
            setElementAlpha(car, 0) 
            outputChatBox("[iNFO] the vehicles are invisible now.",255,100,0) 
        end 
    end 
) 
  

Link to comment

LooL

I didn't notice it's a client side :lol:

But it should be server side, So it works to everyone in the server ..

Here's the code :

-- Server :

local car = getPedOccupiedVehicle(source) 
local carV = getElementAlpha(car) 
  
bindKey("F1", "down", 
    function() 
        if (carV == 0) then 
            setElementAlpha(car, 255) 
            outputChatBox("[iNFO] the vehicles are visible now.",166,255,6) 
        elseif (carV == 255) then 
            setElementAlpha(car, 0) 
            outputChatBox("[iNFO] the vehicles are invisible now.",255,100,0) 
        end 
    end 
) 

Link to comment

No that's not right.

Server - Syntax 1

bindKey ( player thePlayer, string key, string keyState, function handlerFunction, [ var arguments, ... ] )

Required Arguments

thePlayer: The player you wish to bind the key of.

key: The key or control you wish to bind to the command. See key names for a list of possible keys and control names for a list of possible controls.

keyState: A string that has one of the following values:

Link to comment
LooL

I didn't notice it's a client side :lol:

But it should be server side, So it works to everyone in the server ..

Here's the code :

-- Server :

local car = getPedOccupiedVehicle(source) 
local carV = getElementAlpha(car) 
  
bindKey("F1", "down", 
    function() 
        if (carV == 0) then 
            setElementAlpha(car, 255) 
            outputChatBox("[iNFO] the vehicles are visible now.",166,255,6) 
        elseif (carV == 255) then 
            setElementAlpha(car, 0) 
            outputChatBox("[iNFO] the vehicles are invisible now.",255,100,0) 
        end 
    end 
) 

source of what? there no event.

bindKey server side required player element which i can't see it in your code, outputChatBox server side required visibleTo player element too.

Link to comment

i fixed the problem.. i didn't change the script to server it's now working on client.

but i've got two more issues:

1. Whenever i press the button (i changed it to F2) it makes the car invisible and display a message in chatbox that the cars now are invisible; but when i press F2 again to show the vehicles nothing happened and it display a message says that the vehicles are invisible AGAIN.

2. only my car is invisible :( and the other cars are shown in the server.

Link to comment
i fixed the problem.. i didn't change the script to server it's now working on client.

but i've got two more issues:

1. Whenever i press the button (i changed it to F2) it makes the car invisible and display a message in chatbox that the cars now are invisible; but when i press F2 again to show the vehicles nothing happened and it display a message says that the vehicles are invisible AGAIN.

2. only my car is invisible :( and the other cars are shown in the server.

Post your code then?

Link to comment
local car = getPedOccupiedVehicle(getLocalPlayer()) 
local carV = getElementAlpha(car) 
  
 outputChatBox("Press ~[F2]~ to Show/Hide vehicles.",0,166,255, true) 
  
  
bindKey("F2", "down", 
    function() 
        if (carV == 0) then 
            setElementAlpha(car, 255) 
            outputChatBox("[iNFO] the vehicles are visible now.",166,255,6) 
        elseif (carV == 255) then 
            setElementAlpha(car, 0) 
            outputChatBox("[iNFO] the vehicles are invisible now.",255,100,0) 
        end 
    end 
) 

Link to comment
local state = true 
outputChatBox ( "Press ~[F2]~ to Show/Hide vehicles.", 0, 166, 255, true ) 
  
bindKey ( "F2", "down", 
    function ( ) 
        state = ( not state ) 
        local pVehicle = getPedOccupiedVehicle ( localPlayer ) 
        if ( state ) then 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementDimension ( vehicle, 0 ) 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are visible now.", 166, 255, 6 ) 
        else 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementDimension ( vehicle, 1000 ) 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are invisible now.", 255, 100, 0 ) 
        end 
    end 
) 

Link to comment
local state = true 
outputChatBox ( "Press ~[F2]~ to Show/Hide vehicles.", 0, 166, 255, true ) 
  
bindKey ( "F2", "down", 
    function ( ) 
        state = ( not state ) 
        local pVehicle = getPedOccupiedVehicle ( localPlayer ) 
        if ( state ) then 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementDimension ( vehicle, 0 ) 
                    setElementDimension ( player, 0 ) 
                end   
            end 
            outputChatBox ( "[iNFO] the vehicles are visible now.", 166, 255, 6 ) 
        else 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementDimension ( vehicle, 1000 ) 
                    setElementDimension ( player, 1000 ) 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are invisible now.", 255, 100, 0 ) 
        end 
    end 
) 

Link to comment
local state = true 
outputChatBox ( "Press ~[F2]~ to Show/Hide vehicles.", 0, 166, 255, true ) 
  
bindKey ( "F2", "down", 
    function ( ) 
        state = ( not state ) 
        local pVehicle = getPedOccupiedVehicle ( localPlayer ) 
        if ( state ) then 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementDimension ( vehicle, 0 ) 
                    setElementDimension ( player, 0 ) 
                end   
            end 
            outputChatBox ( "[iNFO] the vehicles are visible now.", 166, 255, 6 ) 
        else 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementDimension ( vehicle, 1000 ) 
                    setElementDimension ( player, 1000 ) 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are invisible now.", 255, 100, 0 ) 
        end 
    end 
) 

Your code is wrong, 'player' is nowhere declared.

Link to comment

local state = true 
outputChatBox ( "Press ~[F2]~ to Show/Hide vehicles.", 0, 166, 255, true ) 
  
bindKey ( "F2", "down", 
    function ( ) 
        state = ( not state ) 
        local pVehicle = getPedOccupiedVehicle ( localPlayer ) 
        if ( state ) then 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementAlpha ( vehicle, 255 ) 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are visible now.", 166, 255, 6 ) 
        else 
            for _, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do 
                if ( vehicle ~= pVehicle ) then 
                    setElementAlpha ( vehicle, 0 ) 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are invisible now.", 255, 100, 0 ) 
        end 
    end 
) 

Like that?

Link to comment
local state = true 
outputChatBox ( "Press ~[F2]~ to Show/Hide vehicles.", 0, 166, 255, true ) 
  
bindKey ( "F2", "down", 
    function ( ) 
        state = ( not state ) 
        if ( state ) then 
            for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                if ( player ~= localPlayer ) then 
                    local vehicle = getPedOccupiedVehicle ( player ) 
                    if ( vehicle ) then 
                        setElementDimension ( vehicle, 0 ) 
                        setElementDimension ( player, 0 ) 
                    end 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are visible now.", 166, 255, 6 ) 
        else 
            for _, player in ipairs ( getElementsByType ( "player" ) ) do 
                if ( player ~= localPlayer ) then 
                    local vehicle = getPedOccupiedVehicle ( player ) 
                    if ( vehicle ) then 
                        setElementDimension ( vehicle, 1000 ) 
                        setElementDimension ( player, 1000 ) 
                    end 
                end 
            end 
            outputChatBox ( "[iNFO] the vehicles are invisible now.", 255, 100, 0 ) 
        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...