3B00DG4MER Posted March 20, 2014 Share Posted March 20, 2014 Hello,Today i made a Spawn System which Spawn Vehicle From Selected Row It's work perfectly but there is one Problem : i have add if the vehicle is Sultan set the color of sultan blue sky it show : Bad argument @ 'setVehicleColor' Client Side: function createveh() local pspawner = getLocalPlayer() local x, y, z = getElementPosition ( pspawner ) local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) guiSetVisible(GUIEditor.window[1], false) outputChatBox("You selected "..vehicle..".",pspawner) createVehicle ( vehicle, x, y, z, 0,0,90 ) if vehicle == "560" then setVehicleColor ( vehicle, 7, 7, 0, 0 ) end showCursor(false) end addEventHandler("onClientGUIClick", spawn, createveh, false) Link to comment
DNL291 Posted March 20, 2014 Share Posted March 20, 2014 function createveh() local pspawner = getLocalPlayer() local x, y, z = getElementPosition ( pspawner ) local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) guiSetVisible(GUIEditor.window[1], false) outputChatBox("You selected "..vehicle..".",pspawner) local veh = createVehicle ( vehicle, x, y, z, 0,0,90 ) if vehicle == "560" then setVehicleColor ( veh, 7, 7, 0, 0 ) end showCursor(false) end addEventHandler("onClientGUIClick", spawn, createveh, false) Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 function createveh() local pspawner = getLocalPlayer() local x, y, z = getElementPosition ( pspawner ) local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) guiSetVisible(GUIEditor.window[1], false) outputChatBox("You selected "..vehicle..".",pspawner) local veh = createVehicle ( vehicle, x, y, z, 0,0,90 ) if vehicle == "560" then setVehicleColor ( veh, 7, 7, 0, 0 ) end showCursor(false) end addEventHandler("onClientGUIClick", spawn, createveh, false) There is No Bug But it doesn't set Color of Vehicle Link to comment
cheez3d Posted March 20, 2014 Share Posted March 20, 2014 addEventHandler("onClientGUIClick",spawn,function() local x,y,z = getElementPosition(localPlayer) local id = guiGridListGetItemText(GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),1) guiSetVisible(GUIEditor.window[1],false) showCursor(false) outputChatBox("You selected "..vehicle..".",localPlayer) local vehicle = createVehicle(tonumber(id),x,y,z,0,0,90) if tonumber(id) == 560 then setVehicleColor(vehicle,0,128,255) end end,false) Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 addEventHandler("onClientGUIClick",spawn,function() local x,y,z = getElementPosition(localPlayer) local id = guiGridListGetItemText(GUIEditor.gridlist[1],guiGridListGetSelectedItem(GUIEditor.gridlist[1]),1) guiSetVisible(GUIEditor.window[1],false) showCursor(false) outputChatBox("You selected "..vehicle..".",localPlayer) local vehicle = createVehicle(tonumber(id),x,y,z,0,0,90) if tonumber(id) == 560 then setVehicleColor(vehicle,0,128,255) end end,false) Doesn't work it mean there is a bug with that function Link to comment
Weii. Posted March 20, 2014 Share Posted March 20, 2014 Doesn't work it mean there is a bug with that function Don't know what you meant, but try spawning vehicle in server side! Link to comment
Castillo Posted March 20, 2014 Share Posted March 20, 2014 The grid list contains vehicle names or vehicle models? Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 The grid list contains vehicle names or vehicle models? First row contain IDs Second contain Vehicle names GUIEditor.gridlist[1] = guiCreateGridList(30, 124, 337, 221, false, GUIEditor.window[1]) guiGridListAddColumn(GUIEditor.gridlist[1], "ID", 0.3) guiGridListAddColumn(GUIEditor.gridlist[1], "Name", 0.7) for i = 1, 6 do guiGridListAddRow(GUIEditor.gridlist[1]) end guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "596", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 0, 2, "Police Car (Los Santos)", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "597", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 1, 2, "Police Car (San Fierro)", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "598", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 2, 2, "Police Car (Las Venturas)", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "523", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 3, 2, "HPV1000", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "528", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 4, 2, "FBI Truck", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 5, 1, "560", false, false) guiGridListSetItemText(GUIEditor.gridlist[1], 5, 2, "Sultan", false, false) Link to comment
Castillo Posted March 20, 2014 Share Posted March 20, 2014 And what is the problem? is this a vehicle spawner script? because if it is, then you must create the vehicle server side, if you don't, players won't be able to use them. Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 And what is the problem? is this a vehicle spawner script? because if it is, then you must create the vehicle server side, if you don't, players won't be able to use them. Can you explain please things about triggerServerEvent because i haven't understood anything Link to comment
Castillo Posted March 20, 2014 Share Posted March 20, 2014 There's an example on the wiki, try to adapt it to your script. Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 There's an example on the wiki, try to adapt it to your script. Thanks My problem from beginning of developing So,now i can made all Scripts Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 Hello,Today i made a Spawn System which Spawn Vehicle From Selected RowIt's work perfectly but there is one Problem : i have add if the vehicle is Sultan set the color of sultan blue sky it show : Bad argument @ 'setVehicleColor' Client Side: function createveh() local pspawner = getLocalPlayer() local x, y, z = getElementPosition ( pspawner ) local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) guiSetVisible(GUIEditor.window[1], false) outputChatBox("You selected "..vehicle..".",pspawner) createVehicle ( vehicle, x, y, z, 0,0,90 ) if vehicle == "560" then setVehicleColor ( vehicle, 7, 7, 0, 0 ) end showCursor(false) end addEventHandler("onClientGUIClick", spawn, createveh, false) Can you fix that ? function spawnvehicle( vehicle ) if veh then destroyElement(veh) end local x, y, z = getElementPosition(source) local veh = createVehicle(vehicle , x, y, z) if vehicle == "560" then setVehicleColor ( veh, 7, 7, 0, 0 ) end warpPedIntoVehicle(source ,veh) end addEvent( "onSpawnVeh", true ) addEventHandler( "onSpawnVeh", root, spawnvehicle ) Vehicle Won't Destory Link to comment
Castillo Posted March 20, 2014 Share Posted March 20, 2014 Remove the "local" infront of "veh". Link to comment
3B00DG4MER Posted March 20, 2014 Author Share Posted March 20, 2014 Remove the "local" infront of "veh". Thanks But does it destroy vehicle of client OR all Players Link to comment
DNL291 Posted March 20, 2014 Share Posted March 20, 2014 3B00DG4MER, Try this: Client function createveh() local pspawner = getLocalPlayer() local x, y, z = getElementPosition ( pspawner ) local vehicle = guiGridListGetItemText ( GUIEditor.gridlist[1], guiGridListGetSelectedItem ( GUIEditor.gridlist[1] ), 1 ) if vehicle then outputChatBox("You selected "..vehicle..".",pspawner) triggerServerEvent("onSpawnVeh", localPlayer, tonumber(vehicle)) guiSetVisible(GUIEditor.window[1], false) showCursor(false) end end addEventHandler("onClientGUIClick", spawn, createveh, false) Server local vehicle = {} function spawnvehicle( vehID ) if isElement(vehicle[source]) then destroyElement(vehicle[source]) end local x, y, z = getElementPosition(source) vehicle[source] = createVehicle(vehID , x, y, z) if vehID == 560 then setVehicleColor ( vehicle[source], 7, 7, 0, 0 ) end warpPedIntoVehicle( source, vehicle[source] ) end addEvent( "onSpawnVeh", true ) addEventHandler( "onSpawnVeh", root, spawnvehicle ) 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