Jump to content

Crear Markers con Vehiculos Gratis


TigreBlanco

Recommended Posts

Buenas, Tengo un Par de Preguntas Sobre Como Crear Markers con Vehiculos Gratis como BMX, Carros Baratos, Etc, Alrededor de las Zonas en las Que se Necesiten, He Conseguido una Version Buscando en los Foros, y Ahora Quiero Saber Como Crear una Tabla con los Nombres de los Carros e Ids en Vez de Tener que Pon la Propia ID, en el Siguiente Script:

Client Side:

--[[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 Side:

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

Resumiendo, lo Que Necesito, es Sustituir lo de Poner la ID del Propio Carro, al Nombre del Carro, Como en el Car Shop, Pero Vehiculos Gratis

Link to post
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...