~DarkRacer~ Posted March 4, 2013 Share Posted March 4, 2013 it's me again, is there function or event that can return an integer(number) of the current car visibility. Link to comment
myonlake Posted March 4, 2013 Share Posted March 4, 2013 You can get the element's alpha by using getElementAlpha function. Link to comment
~DarkRacer~ Posted March 4, 2013 Author Share Posted March 4, 2013 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
PaiN^ Posted March 4, 2013 Share Posted March 4, 2013 getLocalPlayer is client side only .. Replace it with source ... Link to comment
iPrestege Posted March 4, 2013 Share Posted March 4, 2013 The alpha value to set. Value can be 0-255, where 255 is fully opaque and 0 is fully transparent. Link to comment
PaiN^ Posted March 4, 2013 Share Posted March 4, 2013 LooL I didn't notice it's a client side 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
iPrestege Posted March 4, 2013 Share Posted March 4, 2013 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
TAPL Posted March 4, 2013 Share Posted March 4, 2013 LooLI didn't notice it's a client side 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
~DarkRacer~ Posted March 4, 2013 Author Share Posted March 4, 2013 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
TAPL Posted March 4, 2013 Share Posted March 4, 2013 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
~DarkRacer~ Posted March 4, 2013 Author Share Posted March 4, 2013 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
PaiN^ Posted March 4, 2013 Share Posted March 4, 2013 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 Link to comment
~DarkRacer~ Posted March 4, 2013 Author Share Posted March 4, 2013 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? Link to comment
Castillo Posted March 4, 2013 Share Posted March 4, 2013 You want to show/hide the vehicles for all players when you press F2? or just for the player that pressed it? Link to comment
~DarkRacer~ Posted March 5, 2013 Author Share Posted March 5, 2013 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. Link to comment
Anony# Posted March 5, 2013 Share Posted March 5, 2013 https://forum.multitheftauto.com/viewtopic.php?f=108&t=55219 Link to comment
Castillo Posted March 5, 2013 Share Posted March 5, 2013 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
~DarkRacer~ Posted March 5, 2013 Author Share Posted March 5, 2013 Thank You Anony. and Thank You Solidsnake14 the code is working fine but there's only one little bug --> the vehicle is hidden but the ped is shown and it's really annoying Link to comment
Anony# Posted March 5, 2013 Share Posted March 5, 2013 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
Anderl Posted March 5, 2013 Share Posted March 5, 2013 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
~DarkRacer~ Posted March 5, 2013 Author Share Posted March 5, 2013 so setElementDimension (element, 0) make the element disappear. then how can i hide the player too Anony's code didn't work. Link to comment
iPrestege Posted March 5, 2013 Share Posted March 5, 2013 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
Castillo Posted March 5, 2013 Share Posted March 5, 2013 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
~DarkRacer~ Posted March 5, 2013 Author Share Posted March 5, 2013 Thank you all for help solved finally . Link to comment
iPrestege Posted March 5, 2013 Share Posted March 5, 2013 Not at all i just try to make the vehicle alpha 0 the script for SolidSnake. 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