TheBenja(totoco) Posted November 19, 2011 Share Posted November 19, 2011 Hello everyone,well im new on this and I didn't see a script for a car spawnmarker.What Im trying to mean?a marker in the map that when you walk to it appear a window with a list of cars/boats/bikes/planes to spawn,I want to learn but i didnt understand the wiki and I need an example to know it,if you can give it to me I will feel so good,thanks Link to comment
12p Posted November 19, 2011 Share Posted November 19, 2011 createMarker addEventHandler ( "onMarkerHit" ) createVehicle Maybe there is some example you can find, at some of these 3 documentations. Link to comment
unknooooown Posted November 19, 2011 Share Posted November 19, 2011 Hello everyone,well im new on this and I didn't see a script for a car spawnmarker.What Im trying to mean?a marker in the map that when you walk to it appear a window with a list of cars/boats/bikes/planes to spawn,I want to learn but i didnt understand the wiki and I need an example to know it,if you can give it to me I will feel so good,thanks Hi. Just made an example that should be pretty easy to understand. Please note that this is just one way of doing it. Other people might not do it the same way. Also, this is only a resource to help you learn, so its not very good or optimzed. But the script is tested and works for what you need. If you have any questions, then just ask me. You can also send me a private message if you'd like. Just remember this, I am not gonna make your resources. I only did it this one time because you have to start learning somewhere Feel free to edit this any way you want. Best of luck! PS. Almost forgot to tell you how it works You simply input the ID of the vehicle you want to spawn. You can find all valid IDs here: https://wiki.multitheftauto.com/wiki/Vehicle_IDs META: <meta> <script src="vehClient.lua" type="client" /> <script src="vehServer.lua" /> </meta> CLIENT: --[[The function below is the spawn window itself. If you have any previous experience with scripting, even HTML, some of this should make sense to you.--]] function openVehicleSpawnClient() local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 233, 104 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 showCursor(true) vehSpawnWin = guiCreateWindow(left, top, windowWidth, windowHeight, "Vehicle Spawner", false) guiWindowSetSizable(vehSpawnWin, false) sampleLabel = guiCreateLabel(15, 25, 201, 20, "Sample Vehicle Spawner", false, vehSpawnWin) guiLabelSetHorizontalAlign(sampleLabel, "center", false) guiLabelSetVerticalAlign(sampleLabel, "center") -- The lineEdit is where you type the modelID you want to spawn. lineEdit = guiCreateEdit(12, 45, 211, 20, "", false, vehSpawnWin) guiEditSetMaxLength(lineEdit, 32767) -- After entering the modelID you wish to spawn, you press the button "Spawn Vehicle" -- The button triggers the next function we use: spawnVehicleClient spawnBtn = guiCreateButton(14, 75, 211, 23, "Spawn Vehicle", false, vehSpawnWin) addEventHandler("onClientGUIClick", spawnBtn, spawnVehicleClient, false) end addEvent("openVehicleSpawn",true) addEventHandler("openVehicleSpawn",localPlayer,openVehicleSpawnClient) --[[This function gets the modelID you entered in the window, checks if it exists,- - and if the model does exist, it will trigger a serverside event. If the vehicle does not exist, you will get a message with an error warning.--]] function spawnVehicleClient() local id = guiGetText(lineEdit) triggerServerEvent("spawnVehicleServer",localPlayer,id) showCursor(false) guiSetVisible(vehSpawnWin,false) end SERVER: --[[ The first thing we do in our script is create a marker that the player has to enter. When the player enters this marker, it triggers "addEventHandler("onMarkerHit",vehMark,openVehicleSpawnServer)" That line is what triggers our first function. In this case: openVehicleSpawnServer--]] local vehMark = createMarker(-706,966,11.447,"cylinder") function openVehicleSpawnServer(hitElement,matchingDimension) -- Checks if the player is in a vehicle. if getPedOccupiedVehicle(hitElement) == false then -- If the player is not in a vehicle, we will open the spawn window. triggerClientEvent(hitElement,"openVehicleSpawn",hitElement) return true end end addEventHandler("onMarkerHit",vehMark,openVehicleSpawnServer) --[[This function creates the vehicle, if the player is not already in a vehicle.--]] function spawnVehicleServer(id) local x,y,z = getElementPosition(source) local myVeh = createVehicle(id,x+5,y,z) if id == "" then outputChatBox("ERROR: You did not input any value.",source,255,0,0,true) triggerClientEvent(source,"openVehicleSpawn",source) return false end if myVeh then warpPedIntoVehicle(source,myVeh) outputChatBox("You have spawned a "..getVehicleNameFromModel(id).." and have been warped into it",source,0,153,0,true) else outputChatBox("ERROR: The requested ID does not exist.",source,255,0,0,true) triggerClientEvent(source,"openVehicleSpawn",source) end end addEvent("spawnVehicleServer",true) addEventHandler("spawnVehicleServer",root,spawnVehicleServer) Link to comment
myonlake Posted November 19, 2011 Share Posted November 19, 2011 Even though you said it's one way of doing it, you still didn't do what he wanted. He wanted especially a gridlist. Link to comment
unknooooown Posted November 19, 2011 Share Posted November 19, 2011 Even though you said it's one way of doing it, you still didn't do what he wanted.He wanted especially a gridlist. Which he is gonna have to figure out for himself. As I said, I am not gonna make the resource for him. But I dont mind pointing him in the right direction. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now