if u use the function isPlayerGhost(cid) says that you aways invisible 
example use this script ^^:
PS.: Ignore executecommand (but doesn't has at the forggoten ^^. It's a function that execute a command without access restriction)
set this function at any script like a talk action etc... and test it ^^
of course has an console erro with exhaustion function
UPDATE:
of course the function is it now and work prefect:

example use this script ^^:
PHP:
function setPlayerGhost(cid, val)
if val == 0 then
if isPlayerGhost(cid) then
doPlayerSendCancel(cid,"invisible val = 1")
executeCommand(cid, "/ghost", "")
else
doPlayerSendCancel(cid,"visible1")
end
else
if not isPlayerGhost(cid) then
doPlayerSendCancel(cid,"visible0")
executeCommand(cid, "/ghost", "")
else
doPlayerSendCancel(cid,"invisible val = 0")
end
end
end
PS.: Ignore executecommand (but doesn't has at the forggoten ^^. It's a function that execute a command without access restriction)
set this function at any script like a talk action etc... and test it ^^
of course has an console erro with exhaustion function

[17/05/2008 14:30:22] Lua Script Error: [TalkAction Interface]
[17/05/2008 14:30:22] in a timer event called from:
[17/05/2008 14:30:22] data/talkactions/scripts/spells/invisible.luanSay
[17/05/2008 14:30:22] attempt to index a nil value
UPDATE:
well, I guess it should be:
if isPlayerGhost(cid) == TRUE/FALSE (1/0) then
of course the function is it now and work prefect:
PHP:
function setPlayerGhost(cid, val)
if isPlayerGhost(cid) ~= val then
executeCommand(cid, "/ghost", "")
end
end
Last edited: