Ryan123 Posted May 15, 2012 Share Posted May 15, 2012 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
Ryan123 Posted May 15, 2012 Author Share Posted May 15, 2012 script stolen?? the script was made by me Link to comment
Edikosh998 Posted May 15, 2012 Share Posted May 15, 2012 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
DNL291 Posted May 15, 2012 Share Posted May 15, 2012 script stolen?? the script was made by me Oh Really? you downloaded the client from a server. Link to comment
Ryan123 Posted May 17, 2012 Author Share Posted May 17, 2012 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
Genius Posted May 17, 2012 Share Posted May 17, 2012 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
Smart. Posted May 17, 2012 Share Posted May 17, 2012 As TAPL said; thevehicle isn't defined anywhere. @Genius: root is a predefined MTA variable of getRootElement() see: https://wiki.multitheftauto.com/wiki/Pre ... ables_list Link to comment
TAPL Posted May 17, 2012 Share Posted May 17, 2012 also you should use getVehicleModelFromName Instead of getElementModel Link to comment
DNL291 Posted May 17, 2012 Share Posted May 17, 2012 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. Link to comment
Castillo Posted May 17, 2012 Share Posted May 17, 2012 We don't help people who steal other's work. Topic locked. Link to comment
Recommended Posts