Jump to content

Duda con 'return'


Alexs

Recommended Posts

Hola a Todos, hoy desperté de uno de mis letargos sin memoria y tenia esto anotado en mi cuaderno:

function isPlayerInParty( thePlayer ) 
local inf = getElementData( thePlayer, "player.party") 
   if ( inf == true ) then 
      return inf 
       end 
   end 

Esto serviria para comprobar si "player.party" esta en true?, jamas use el return :S

Link to comment
function isPlayerInParty ( thePlayer ) 
    return getElementData ( thePlayer, "player.party" ) 
end 

Es mucho mas facil eso, deberia devolver: true o false.

Ok, creo que inconscientemente soy complicado, Gracias.

PD: La "mía" debería funcionar de igual manera?

Link to comment
Funcionaria solo si el resultado es "true", pero lo mejor es directamente devolver el resultado.

Ok, en ese caso esto debería funcionar...

function isPlayerInParty ( thePlayer ) 
    return getElementData ( thePlayer, "player.party" ) 
end 
  
addEventHandler("onPlayerSpawn", getRootElement(),  
function() 
if isPlayerInParty(source) then 
killPed(source, source) 
end 
end 
) 

...Verdad?

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...