Jump to content

Getting Pos, setting pos


xUltimate

Recommended Posts

Ok so I'm trying to make it so it detects if there in a certain area and then have them teleport it in to another area, but I also want it to detect if there in a vehicle that they teleport to a different area. I can't find out the certain functions for it

(Yes I am new to LUA/MTA.)

Here is the map info:

<map edf:definitions="editor_main"> 
    <object id="object (info) (1)" doublesided="false" model="1239" interior="0" dimension="0" posX="-2566.5703125" posY="553.54553222656" posZ="13.662875175476" rotX="0" rotY="0" rotZ="0" /> 
    <object id="object (genint_warehs) (1)" doublesided="false" model="14784" interior="0" dimension="0" posX="-2558.8142089844" posY="517.38647460938" posZ="635.09411621094" rotX="0" rotY="0" rotZ="0" /> 
    <object id="object (cn2_savgardr2_) (5)" doublesided="false" model="16501" interior="0" dimension="0" posX="-2530.3532714844" posY="551.5390625" posZ="628.78533935547" rotX="0" rotY="0" rotZ="0" /> 
    <object id="object (arrow) (1)" doublesided="false" model="1318" interior="0" dimension="0" posX="-2533.4072265625" posY="551.16674804688" posZ="626.20599365234" rotX="0" rotY="0" rotZ="0" /> 
    <object id="object (arrow) (2)" doublesided="false" model="1318" interior="0" dimension="0" posX="-2547.2822265625" posY="551.98864746094" posZ="626.19024658203" rotX="0" rotY="0" rotZ="270" /> 
</map> 

info is the enter area, arrow 1 is the area where players enter/leave the building. arrow 2 is the vehicle enter/exit.

Please can someone help me.

Link to comment
not sure what you are trying to do?

detect if player is sitting in vehicle, or to detect if on destination position there is any car (which makes player colliding with it on teleport) ?

I want to find out how to detect there position, if there in a area, and if they are in a vehicle.

Link to comment

here is an example my friend solidsnake made for me :wink:

marker1 = createMarker (3079.3068847656, -2098.3444824219, 31.440458297729, "corona", 10, 255, 0, 0, getRootElement()) 
  
function teleport1(thePlayer) 
if source == marker1 then 
if isPedInVehicle(thePlayer) then  
local vehicle = getPedOccupiedVehicle(thePlayer) 
if getVehicleController(vehicle) == thePlayer then  
setElementPosition (vehicle, 3440.9497070313,-2223.5588378906,1.34375) 
end 
end 
end 
end 
addEventHandler("onMarkerHit", getRootElement(), teleport1) 

Link to comment

I think you forgot we have the wiki there..

https://wiki.multitheftauto.com/wiki/Cli ... _Functions

https://wiki.multitheftauto.com/wiki/Ser ... _Functions

IsPlayerInArea -> isElementWithinColShape (you have to create colshape first! there are much types of colshapes - choose the one most suiting you - click)

IsPlayerInVehicle -> isPedInVehicle (i see you are checking for specific vehicle in SAMP - here you are checking if player is in any vehicle - to get player vehicle use getPedOccupiedVehicle - it will return vehicle elemnt or false if player is not in vehicle - you can use this instead of isPedInVehicle too)

Link to comment
show us your code, so we can fix it..

It was apart of this base GM I downloaded, just found out I could do /createint but I believe its this code

local function loadInterior( id, outsideX, outsideY, outsideZ, outsideInterior, outsideDimension, insideX, insideY, insideZ, insideInterior, interiorName, interiorPrice, interiorType, characterID, locked, dropoff ) 
    local outside = createColSphere( outsideX, outsideY, outsideZ, 1 ) 
    setElementInterior( outside, outsideInterior ) 
    setElementDimension( outside, outsideDimension ) 
    setElementData( outside, "name", interiorName ) 
     
    -- we only need it set in case there's really something for sale 
    if interiorType ~= 0 and characterID <= 0 then 
        setElementData( outside, "type", interiorType ) 
        setElementData( outside, "price", interiorPrice ) 
    end 
     
    local inside = createColSphere( insideX, insideY, insideZ, 1 ) 
    setElementInterior( inside, insideInterior ) 
    setElementDimension( inside, id ) 
     
    colspheres[ outside ] = { id = id, other = inside } 
    colspheres[ inside ] = { id = id, other = outside } 
    interiors[ id ] = { inside = inside, outside = outside, name = interiorName, type = interiorType, price = interiorPrice, characterID = characterID, locked = locked, blip = not locked and outsideDimension == 0 and not getElementData( outside, "price" ) and createBlipEx( outside, inside ), dropoff = dropoff } 
end 

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...