Jump to content

HELP :D


Recommended Posts

Posted

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 
) 
  

Posted

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 
) 

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted

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:

  

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

CiTLh.png
Posted

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.

Posted
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?

CiTLh.png
Posted
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 
) 

Posted

It must be server sided .

Or else it well disappear only for you

+

You have to get all the cars in the server to make all of theme disappear

for _,vehicles in ipairs(getElementsByType("vehicle") do 

" Keep Thinking Different . " - Steve Jops

--------------------

Don't send me PMs asking for help, I Won't reply !

Posted

ok i will make it server side and i will put the 'for loop' but how can i get the current player since i'm coding in server side?

i tried 'source' but i didn't work :(

any solution?

Posted

You want to show/hide the vehicles for all players when you press F2? or just for the player that pressed it?

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

I'm a DM player and i'm making this mod because the members of my server are complaining from the cars (they want it to be hidden to play much better).

i want to make the player whenever HE press F2 all player will be hidden only for him he will not see any car.

Posted
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 
) 

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

Thank You Anony.

and Thank You Solidsnake14 the code is working fine but there's only one little bug :D --> the vehicle is hidden but the ped is shown and it's really annoying

Posted
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 
) 

Team, MTA Scripters.

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

"[...] If you don’t love it, if you’re not having fun doing it, you don’t really love it, you’re going to give up." - Steve Jobs, 2007

Posted

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?

  

Posted
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 
) 

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