Jump to content

Duda con 'return'


Alexs

Recommended Posts

Posted

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

Posted
function isPlayerInParty ( thePlayer ) 
    return getElementData ( thePlayer, "player.party" ) 
end 

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

Posted
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?

Posted
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?

  • Recently Browsing   0 members

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