Jump to content

[HELP] setElementData


ViRuZGamiing

Recommended Posts

Posted

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

Posted

I don't use databases, I know they're the best to use and it can be used in every script.

XML seems quite hard, if I could get some basics going on XML I could try it.

Are you known with XML?

Posted

Yes. And XML is quite easy. Just start looking at the Wiki to the XML functions and you will know soon how it works. Maybe you even can use account data.

Posted

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) 

Posted

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!)

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