Sign in to follow this  
Pikachu

ghostmode for players

Recommended Posts

script:

local ghostMarker = createMarker(-2405, -598, 132.6, "cylinder", 10, 255, 255, 255, 255) 
  
function ghost() 
    local p = getElementsByType("player") 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do 
        setElementCollidableWith(vehicle, p, false) 
    end 
    outputChatBox("You have entred ghostmode marker, you are now a ghost ;P", source,0,0,55) 
end 
addEventHandler("onMarkerHit", ghostMarker, ghost) 
  
function unGhost() 
    local p = getElementsByType("player") 
    for index,vehicle in ipairs(getElementsByType("vehicle")) do 
        setElementCollidableWith(vehicle, p, true) 
    end 
    outputChatBox("You have left ghostmode marker, you are no more a ghost D:", source,0,0,55) 
end 
addEventHandler("onMarkerLeave", ghostMarker, unGhost) 

problem:

attempt to call global setElementCollidableWith (a nil value)

function(from script 2):

function onOccupationChange() 
    if not getElementData(source, "Occupation") == "Mailman" then return end 
    elseif getElementData(source, "Occupation") == "Mailman" then 
    local x, y, z = getNewMailLocation(source, 1) 
        setElementData(source,"mailData",1) 
end 
addEventHandler("onElementDataChange", getRootElement(), onOccupationChange) 

problem:

'end' expected (to close function at line 1) near elseif

Share this post


Link to post

Script 1: setElementCollidableWith is Client-only function and it Require element, not a table.

Script 2:

function onOccupationChange() 
     if getElementData(source, "Occupation") == "Mailman" then 
          local x, y, z = getNewMailLocation(source, 1) 
          setElementData(source,"mailData",1) 
     end 
end 
addEventHandler("onElementDataChange", root, onOccupationChange) 

Share this post


Link to post
Script 1: setElementCollidableWith is Client-only function and it Require element, not a table.

Script 2:

function onOccupationChange() 
     if getElementData(source, "Occupation") == "Mailman" then 
          local x, y, z = getNewMailLocation(source, 1) 
          setElementData(source,"mailData",1) 
     end 
end 
addEventHandler("onElementDataChange", root, onOccupationChange) 

Bad argument @ 'getElementData' [Expected element at argument 1, got nil]

Share this post


Link to post

Try.

function onOccupationChange(dataName) 
     if getElementType(source) == "player" and dataName == "Occupation" then 
          if getElementData(source, dataName) == "Mailman" then 
               local x, y, z = getNewMailLocation(source, 1) 
               setElementData(source,"mailData",1) 
          end 
     end 
end 
addEventHandler("onElementDataChange", root, onOccupationChange) 

Share this post


Link to post
Try.
function onOccupationChange(dataName) 
     if getElementType(source) == "player" and dataName == "Occupation" then 
          if getElementData(source, dataName) == "Mailman" then 
               local x, y, z = getNewMailLocation(source, 1) 
               setElementData(source,"mailData",1) 
          end 
     end 
end 
addEventHandler("onElementDataChange", root, onOccupationChange) 

still the same problem, and what about the first script?

Share this post


Link to post

This impossible!

The source of event onElementDataChange cannot be nil.

If there no source (nil) then there will be no element Data changed and that mean the event onElementDataChange will not triggered.

Share this post


Link to post
This impossible!

The source of event onElementDataChange cannot be nil.

If there no source (nil) then there will be no element Data changed and that mean the event onElementDataChange will not triggered.

script2 fixed.

still script 1, wich i really need it.

EDIT: script 1 solved.

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.