novo Posted December 23, 2011 Share Posted December 23, 2011 Hi all. I want make a script wich does for when you press "o", you don't see any car except your own. Please help me D: Link to comment
Al3grab Posted December 23, 2011 Share Posted December 23, 2011 bindKey getElementsByType setElementAlpha Link to comment
novo Posted December 23, 2011 Author Share Posted December 23, 2011 Maybe this: function invisible ( key, keyState ) local vehicles = getElementsByType ( "vehicle" ) local state = "Hiding" if ( keyState == "down" ) then setElementAlpha ( vehicles, 255 ) end outputChatBox ( "[iNFO]: Currently ".. state .." cars." ) end addEventHandler("onPlayerJoin", function(player) bindKey ( player, "F1", "up", invisible ) end ) Help plz ^^ Link to comment
BinSlayer1 Posted December 23, 2011 Share Posted December 23, 2011 Lol that's terribly wrong.. And setElementAlpha will make the car invisible but you can still see the shadow, headlights and the ped controlling it.. bindKey('f1', 'down', function() for _, player in ipairs(getElementsByType('player')) do if player ~= localPlayer then setElementDimension(getPedOccupiedVehicle(player), 1) setElementDimension(player, 1) end end end Note: This script is client-side. Note2: The script does not handle people who join AFTER the button was pressed. So you will either have to press it again when somebody joins the server or re-script it somehow. Note3: The script assumes you want vehicles that are controlled by players to be invisible, not parked vehicles. Link to comment
novo Posted December 23, 2011 Author Share Posted December 23, 2011 Thank you BinSlayer1. :] Link to comment
novo Posted December 23, 2011 Author Share Posted December 23, 2011 I made this: addEventHandler("onPlayerJoin", bindKey('F1', 'down', function() for _, player in ipairs(getElementsByType('player')) do if player ~= localPlayer then setElementDimension(getPedOccupiedVehicle(player), 1) setElementDimension(player, 1) outputChatBox("[iNFO]: Currently Hidding Vehicles.", player ) end end end )) bindKey('F1', 'up', function() for _, player in ipairs(getElementsByType('player')) do if ( getElementDimension ( source ) == 1 and seat == 0 ) then setElementDimension(getPedOccupiedVehicle(player), 0) setElementDimension(player, 0) outputChatBox("[iNFO]: Currently Showing Vehicles.", player ) end end end ) --[[ addEventHandler("onPlayerSpawn", function( thePlayer, key ) if ( getElementDimension ( source ) == 1 and seat == 0 ) then setElementDimension(getPedOccupiedVehicle(player), 1) setElementDimension(player, 1) end end ) ]]-- But when i press F1, it hide cars and show 4 texts. ON - OFF then again. Plz help <3 PD: Sorry 4 double post. Link to comment
Castillo Posted December 23, 2011 Share Posted December 23, 2011 local shown = true bindKey('F1', 'down', function() for _, player in ipairs(getElementsByType('player')) do if (player ~= localPlayer) then if (show) then setElementDimension(getPedOccupiedVehicle(player), 1) setElementDimension(player, 1) outputChatBox("[iNFO]: Currently Hidding Vehicles.", player ) else setElementDimension(getPedOccupiedVehicle(player), 0) setElementDimension(player, 0) outputChatBox("[iNFO]: Currently Showing Vehicles.", player ) end end end shown = not shown end) Link to comment
Aibo Posted December 23, 2011 Share Posted December 23, 2011 local hiding = false addEventHandler("onClientResourceStart", resourceRoot, function() bindKey('F1', 'down', hideVehicles) bindKey('F1', 'up', hideVehicles) end ) function hideVehicles(key, state) if (hiding and state == 'down') or (not hiding and state == 'up') then return false end hiding = not hiding for _, player in ipairs(getElementsByType('player')) do if player ~= localPlayer then setElementDimension(getPedOccupiedVehicle(player), hiding and 1 or 0) setElementDimension(player, hiding and 1 or 0) end end outputChatBox(hiding and "[iNFO]: Currently Hiding Vehicles." or "[iNFO]: Currently Showing Vehicles.") end PS: meh , already posted. well mine is a little different Link to comment
TAPL Posted December 24, 2011 Share Posted December 24, 2011 does this needed? bindKey('F1', 'down', hideVehicles) bindKey('F1', 'up', hideVehicles) it's can be bindKey('F1', 'both', hideVehicles) Link to comment
novo Posted December 24, 2011 Author Share Posted December 24, 2011 Thanks Solidsnake14. Thanks Aibo. Thanks TAPL for correct my dudes of this. @Aibo: I'll use Solidsnake14 code, because it's easyer to understand for me. Anyways, thank you for give me another method to script it. Bye. EDIT: @Solidsnake14: It's not working EDIT: local hiding = true addEventHandler("onClientResourceStart", resourceRoot, function() bindKey('F1', 'both', hideVehicles) end ) function hideVehicles(key, state) if (hiding and state == 'down') or (not hiding and state == 'up') then return false end hiding = not hiding for _, player in ipairs(getElementsByType('player')) do if player ~= localPlayer then setElementDimension(getPedOccupiedVehicle(player), hiding and 1 or not hiding and 0) setElementDimension(player, hiding and 1 or not hiding and 0) end end outputChatBox(hiding and "[iNFO]: Currently Hiding Vehicles." or "[iNFO]: Currently Showing Vehicles.") end It has a bug, when i press F1 it's not showing, but i need to keep it "pushed". If i stop "push" to key, the cars already are showing. Plz help. Link to comment
Aibo Posted December 24, 2011 Share Posted December 24, 2011 well that't what i meant by "mine is different". it's not a bug, it's supposed to work that way. since you've used both 'up' and 'down' keybinds yourself, i assumed that is how you wanted it to work. well anyway, if you want switching: local hiding = false function hideVehicles(key, state) hiding = not hiding for _, player in ipairs(getElementsByType('player')) do if player ~= localPlayer then setElementDimension(getPedOccupiedVehicle(player), hiding and 1 or 0) setElementDimension(player, hiding and 1 or 0) end end outputChatBox(hiding and "[iNFO]: Currently Hiding Vehicles." or "[iNFO]: Currently Showing Vehicles.") end bindKey('F1', 'down', hideVehicles) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now