Jump to content

Calculating


JanriKallas

Recommended Posts

Lets say theres a three markers

MechanicMarker

MedicMarker

PoliceMarker

They are all invisible.

Then function makes one of the Marker visible that player chose from clientside.

So to not make three different function for policemarker, medicmarker, mechanicmarker

  
Function () --clientside 
duty = GuigetText (bla1) 
TriggerEvent ("serverfunc", localplayer, localplayer, duty) 
End 
  
Function (player,duty) --duty is "Mechanic" / "Medic" / "Police" 
setElementVisibleTo (player, ..duty..Marker) 
end 
  

I alrady tried: (tostring(duty)Marker) and tostring (duty)..Marker

Link to comment
local markers = { 
["Mechanic"] = createMarker(...), 
["Medic"] = createMarker(...), 
["Police"] = createMarker(...), 
} 
  
function anFunction(player,duty) 
    setElementVisibleTo(markers[duty],player,true) 
    for k,v in pairs(markers) do 
        if k ~= duty then 
            setElementVisibleTo(v,player,false) 
        end 
    end 
end 
  
anFunction(getRandomPlayer(),"Police") 

Is that what you mean?

Link to comment

You actually don't need to enable OOP if you prefer not to use it. If you look at the wiki page of getElementMatrix you have this example which does exactly what you want;

function getPositionFromElementOffset(element,offX,offY,offZ) 
    local m = getElementMatrix ( element )  -- Get the matrix 
    local x = offX * m[1][1] + offY * m[2][1] + offZ * m[3][1] + m[4][1]  -- Apply transform 
    local y = offX * m[1][2] + offY * m[2][2] + offZ * m[3][2] + m[4][2] 
    local z = offX * m[1][3] + offY * m[2][3] + offZ * m[3][3] + m[4][3] 
    return x, y, z                               -- Return the transformed point 
end 
  
-- Get the position of a point 3 units to the right of the element: 
x,y,z = getPositionFromElementOffset(element,3,0,0) 
  
-- Get the position of a point 2 units in front of the element: 
x,y,z = getPositionFromElementOffset(element,0,2,0) 
  
-- Get the position of a point 1 unit above the element: 
x,y,z = getPositionFromElementOffset(element,0,0,1) 

Link to comment

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
  • Recently Browsing   0 members

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