Jump to content

Script Vehicle Spawn


Ryan123

Recommended Posts

Hello, I can't get the vehicle spawn.The server say "bad argument addEvent".

here is script client-side:

local vehicles = {"BMX", "Bike", "Mountain Bike"} 
local bikes = createMarker(1183.2487792969, -1314.9769287109, 12.546875, 'cylinder', 1.5, 255, 255, 255, 255) 
function createVehGui () 
    MainGui = guiCreateWindow(408,203,240,349,"Get your bike",false) 
    VehGrid = guiCreateGridList(14,32,180,256,false,MainGui) 
    guiGridListSetSelectionMode(VehGrid,2) 
    _bikes = guiGridListAddColumn(VehGrid,"Bikes",0.85) 
    Spawn = guiCreateButton(15,305,96,35,"Spawn",false,MainGui) 
    guiSetFont(Spawn,"clear-normal") 
    Cancel = guiCreateButton(128,305,96,35,"Cancel",false,MainGui) 
    guiSetFont(Cancel,"clear-normal") 
    for index, vehicle in ipairs(vehicles) do 
        local row = guiGridListAddRow (VehGrid) 
        guiGridListSetItemText ( VehGrid, row, _bikes, tostring(vehicle), false, false ) 
    end 
end 
addEventHandler("onClientMarkerHit", bikes, 
    function ( hitElement ) 
        if (hitElement == localPlayer) then 
            createVehGui ( hitElement ) 
            if (MainGui ~= nil) then 
                guiSetVisible(MainGui, true) 
                showCursor(true) 
                guiSetInputEnabled(true) 
            else 
                outputChatBox ("Error: Please Re-enter in the marker to get your vehicle.", 255, 0, 0) 
            end 
        end 
end 
) 
  
addEventHandler("onClientGUIClick", root, 
    function () 
        if (source == Spawn) then 
            local row,col = guiGridListGetSelectedItem(VehGrid) 
            if (row and col and row ~= -1 and col ~= -1) then 
                local vehicleName = guiGridListGetItemText(VehGrid, row, 1) 
                if vehicleName then 
                    triggerServerEvent("spawnBike",localPlayer,vehicleName) 
                end  
            else 
                outputChatBox("Erro: Please select a vehicle from the list.",255,0,0) 
            end 
        elseif (source == Cancel) then 
            guiSetVisible(MainGui, false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
        end 
    end 
) 
  
addEventHandler("onClientPlayerWasted", root, 
function () 
            guiSetVisible(MainGui, false) 
            showCursor(false) 
            guiSetInputEnabled(false) 
end) 

and here is Server-Side:

function spawnBike (lol) 
local id = getElementModel(thevehicle) 
  if id == 509 or id == 510 or id == 481 then 
  local x, y, z = getElementPosition ( source ) 
  local xr, yr, zr = getElementRotation ( source ) 
  createVehicle = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) 
  warpPedIntoVehicle(source, createVehicle) 
  end 
end 
  
addEvent( "spawnBike", bikes, spawnBike ) 

Regards Ryan

Link to comment
  
  
function spawnBike (lol) 
local id = getElementModel(thevehicle) 
  if id == 509 or id == 510 or id == 481 then 
  local x, y, z = getElementPosition ( source ) 
  local xr, yr, zr = getElementRotation ( source ) 
  createVehicle = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) 
  warpPedIntoVehicle(source, createVehicle) 
  end 
end 
  
addEvent( "spawnBike", true) 
addEventHandler("spawnBike",root,spawnBike) 
  
  

Link to comment
  
  
function spawnBike (lol) 
local id = getElementModel(thevehicle) 
  if id == 509 or id == 510 or id == 481 then 
  local x, y, z = getElementPosition ( source ) 
  local xr, yr, zr = getElementRotation ( source ) 
  createVehicle = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) 
  warpPedIntoVehicle(source, createVehicle) 
  end 
end 
  
addEvent( "spawnBike", true) 
addEventHandler("spawnBike",root,spawnBike) 
  
  

didn't worked.

script stolen?? the script was made by me

Oh Really? you downloaded the client from a server.

why you said I stolen the script?If I stole one script say me which is.

Link to comment
  
  
function spawnBike (lol) 
local id = getElementModel(thevehicle) 
  if id == 509 or id == 510 or id == 481 then 
  local x, y, z = getElementPosition ( source ) 
  local xr, yr, zr = getElementRotation ( source ) 
  createVehicle = createVehicle (id, x, y, z + 0.5, xr, yr, zr ) 
  warpPedIntoVehicle(source, createVehicle) 
  end 
end 
  
addEvent( "spawnBike", true) 
addEventHandler("spawnBike",getRootElement(),spawnBike) 
  
  

didn't worked.

script stolen?? the script was made by me

Oh Really? you downloaded the client from a server.

why you said I stolen the script?If I stole one script say me which is.

getRootElement is, not root

try this i think it work

i dont have time for test

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...