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

Developer @ MYVAL

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

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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?

Developer @ MYVAL

Posted

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

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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?

Developer @ MYVAL

Posted

Si, eso funcionaria.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Recently Browsing   0 members

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