Jump to content

Script Vehicle Spawn


Ryan123

Recommended Posts

Posted

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

Posted

Script stolen, we can't help.

Please do not PM me with scripting related question nor support, use the forums instead.

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

WRS( World Racing Server) [server] = 8%

Posted
script stolen?? the script was made by me

Oh Really? you downloaded the client from a server.

Please do not PM me with scripting related question nor support, use the forums instead.

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

Posted
  
  
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

MTA Scripter.

If you want scripter PM me and i will accept every job for fair price.

Posted

I corrected this script to a friend. obviously, you downloaded the client side from server, and is asking for help with the server side without permission.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

We don't help people who steal other's work.

Topic locked.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

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

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