Jump to content

[HELP] setElementData


ViRuZGamiing

Recommended Posts

Hi guys,

I'm trying to figure out the setElementData, i've read the wiki and now's my question.

I want to assign some ElementData called ID to a vehicle (which would be possible for me)

But! I want to do it like on the second car it needs to get the next ID + 1.

Example: 
Vehicle Banshee bought! ID = 1 
Next Vehicle! ID = 2 

I hope you'll understand what I'm trying to say.

Regards Viruz

Link to comment

I've made this already, could I use this to implement it into an XML, and I will take a look at the XML Functions.

function saveYourCar (thePlayer) 
    local vehicle = getPedOccupiedVehicle (thePlayer) 
     
    if (vehicle == false) then 
        outputChatBox("Your not in a vehicle") 
    else 
        local idData = getElementData(vehicle, "ID") 
        local ownerData = getElementData(vehicle, "Owner") 
         
        if (thePlayer == ownerData) then 
            local vPX, vPY, vPZ = getElementPosition(vehicle) 
            setElementData(thePlayer, "vehPositionX", vPX) 
            setElementData(thePlayer, "vehPositionY", vPY) 
            setElementData(thePlayer, "vehPositionZ", vPZ) 
            outputChatBox("Position Saved!", thePlayer) 
        else 
            outputChatBox("This vehicle doesn't belong to you!", thePlayer) 
        end 
    end 
end 
  
addCommandHandler("save", saveYourCar) 

Link to comment

If you want to save vehicles for a player, you can use account data. Just put everything of the vehicle (position, id, etc) into a table and put the table into the player's account. Later you can call it and then you can use functions like setElementPosition and such. (Check or the player is logged in!)

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