ThePCGuy Posted July 14, 2013 Share Posted July 14, 2013 Hi there, Could somebody explain what "return" actually does? And what it does here: function randomFunction(x,y,z,d) if ( source ~= localPlayer ) then return end if tonumber("".. littleCheck .."") > 1 then if d then if getElementDimension(getLocalPlayer()) == d then createExplosion(x, y, z - 10, 12, false, -1.0, false) end end end end addEvent("randomFunction",true) addEventHandler("randomFuction",getRootElement(),randomFunction) Link to comment
فاّرس Posted July 14, 2013 Share Posted July 14, 2013 It's end the function. Example : if isPedInVehicle(source) then return end And in your code it's : If the source does not = the player end the function. Link to comment
denny199 Posted July 14, 2013 Share Posted July 14, 2013 It's end the function.Example : if isPedInVehicle(source) then return end And in your code it's : If the source does not = the player end the function. Wrong. return, the word is actaully saying it. it will return a value. Lua always adjusts the number of results from a function to the circumstances of the call. When we call a function as a statement, Lua discards all of its results. When we use a call as an expression, Lua keeps only the first result. We get all results only when the call is the last (or the only) expression in a list of expressions. These lists appear in four constructions in Lua: multiple assignment, arguments to function calls, table constructors, and return statements. To illustrate all these uses, we will assume the following definitions for the next examples: function foo0 () end -- returns no results function foo1 () return 'a' end -- returns 1 result function foo2 () return 'a','b' end -- returns 2 results Like the quote above you can use by foo1: local chek1 = foo1() -- will return 'a' Link to comment
ThePCGuy Posted July 14, 2013 Author Share Posted July 14, 2013 Ok thanks, but in this function i posted it doesnt return any value, what is it doing now then? Just stopping the function if the source is different then localPlayer? EDIT: Oops, you already answered that. 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