Perfect Posted December 28, 2013 Share Posted December 28, 2013 Hi, I am Trying to Make a Script, which will enable/disable player collision. I have made a script but i think its too big and it can be compress. Can you guys please compress it ? function ghost (playerSource, commandName, switch) local switch = true local veh = getPedOccupiedVehicle(playerSource) if ( switch == true and isPedInVehicle(playerSource) == false ) then setElementCollisionsEnabled(playerSource, true) outputChatBox("Server: Ghostmod: on", playerSource, 0, 255, 0 ) switch = false elseif (switch == false and isPedInVehicle(playerSource) == false) then setElementCollisionsEnabled(playerSource, false) switch = true outputChatBox("Server: Ghostmod: off", playerSource, 0, 255, 0 ) elseif ( switch == true isPedInVehicle(playerSource) == true) then setElementCollisionsEnabled(veh, true) switch = false outputChatBox("Server: Ghostmod: on", playerSource, 0, 255, 0 ) elseif (switch == false) then setElementCollisionsEnabled(veh, false) switch = true outputChatBox("Server: Ghostmod: off", playerSource, 0, 255, 0 ) end end addCommandHandler("ghost", ghost) (by compress i mean make it small, its have too many elseif) Link to comment
Perfect Posted December 28, 2013 Author Share Posted December 28, 2013 Not Compiling but making it Small and Better as you can it have Too Many ifelse. Link to comment
SuleymanM Posted December 28, 2013 Share Posted December 28, 2013 add my skype: i'm trying to make it...= SKYPE: metin.white Link to comment
Perfect Posted December 28, 2013 Author Share Posted December 28, 2013 I don't have skype. You can Pm me here in forum.Thanks for Trying. Link to comment
TAPL Posted December 28, 2013 Share Posted December 28, 2013 addCommandHandler("ghost", function(player) local veh = getPedOccupiedVehicle(player) local stat = getElementCollisionsEnabled(veh or player) setElementCollisionsEnabled(veh or player, not stat) outputChatBox("Server: Ghostmod: "..(stat and "on" or "off"), player, 0, 255, 0 ) end) Link to comment
Perfect Posted December 28, 2013 Author Share Posted December 28, 2013 Woah, Its have almost 1/3 lines of my code. Can you Please Explain me this ? local stat = getElementCollisionsEnabled(veh or player) setElementCollisionsEnabled(veh or player, not stat) outputChatBox("Server: Ghostmod: "..(stat and "on" or "off"), player, 0, 255, 0 ) Curious and a bit confused. Link to comment
johny46 Posted December 28, 2013 Share Posted December 28, 2013 Have a look at this: http://lua-users.org/wiki/TernaryOperator 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