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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.