Author Topic: -Tutorial-Taking car from marker  (Read 27 times)

Offline Brian

  • Owner
  • Regular Poster
  • *****
  • Posts: 61
  • Location: Moscow,Russia
    • View Profile
-Tutorial-Taking car from marker
« on: June 23, 2012, 10:24:55 am »
Let's start.
First create "meta.xml" file here (You can create your file name "My server and create all scripts there : Local Disk:C/Program Files/MTA/Server/Mods/Resourse



Second you need get ID of car/motorcycle anything you want.

Third , we will create marker


Code: [Select]
marker = createMarker(114,-1675,20,"corona",2,0,255,0)
Now, we add a handled function that will happen when player (source) hits the marker:


Code: [Select]
addEventHandler("onClientMarkerHit",marker,
function()
    local vh = getPedOccupiedVehicle ( source )
    vehicles = { --[[ID here (Ex: 1, 2, 3)]] }
    nm = tonumber ( math.random( #vehicles ) )
    setElementModel ( vh, nm ) 
end)

Now , merge that two codes.

Code: [Select]
marker = createMarker(x, y, z,"corona",2,0,255,0)
 
addEventHandler("onClientMarkerHit",marker,
function()
    local vh = getPedOccupiedVehicle ( source )
    vehicles = { --[[YOUR ID'S HERE, SEPARATED BY A COMA (Ex: 1, 2, 3)]] }
    nm = tonumber ( math.random( #vehicles ) )
    setElementModel ( vh, nm ) 
end)


 Save that code as "client.lua" into the map folder.

 Open the file meta.xml located inside the map folder.

 Add at the beginning below <meta> this code:


Code: [Select]
<script src="client.lua" type="client" />
Finaly we finished,save meta.xml

If you have some problems PM me.BTW My new skype is nemanja.stanojevic58
Education is the most powerful weapon which you can use to change the world.

Share on Bluesky Share on Facebook