Jump to content

Return more than one argument (?)


'LinKin

Recommended Posts

Posted

Hello,

I've a custom function to return the a player by sending it a part of its nick. But, I was wondering if it is possible to return more than one argument in my function, I mean:

Return the player,

but, if there are more than one (1) players with the same part of the nick, I want to return false & the number of players who have that part of the nick.

If this is not possible, Would it be right if I return different types of elements in the same function?

Example:

if matches == 0 then

return false

elseif matches == 1 then

return thePlayer

elseif matches > 1 then

return matches (*)

end

(*): Would return a number

Need a clanwar script? Click here!

Do you want some free scripts for your DD server? Visit my website.

Posted

You can return multiple values in lua and with different types. For example:

function f() 
    local player = localPlayer 
    local playersFound = 3 
    return player, playersFound 
end 
  
local thePlayer, playersFound = f() 
  

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