Tete omar Posted July 9, 2012 Posted July 9, 2012 server side local blip = createBlip ( 0, 0, 0, 0, 3 ) local BusJobMarker = createMarker ( 1620.2777099609, -1041.3696289063, 22.8984375, "cylinder", 2, 255, 0, 0, 255 ) local busteam = createTeam ( "Bus drivers", 255, 255, 0 ) function attachblipwith() attachElements ( blip, BusJobMarker, 0, 0, 0 ) end addEventHandler("onResourceStart", getRootElement(), attachblipwith) function showWindow(player) triggerClientEvent(player,"Showbusjobwindow", player) end addEventHandler("onMarkerHit", getRootElement(), showWindow) addEvent("StartBusJob", true) function StartBusJob(thePed) setPlayerTeam ( source, busteam) gX, gY, gZ = getElementPosition ( source ) bus = createVehicle ( 431, gX, gY, gZ ) warpPedIntoVehicle ( thePed, bus ) end addEventHandler("StartBusJob",getRootElement(),StartBusJob) client side addEvent("Showbusjobwindow", true) function Showbusjobwindow() guiSetVisible(GUIEditor_Window[1], true) showCursor(true) guiSetInputEnabled(false) end addEventHandler("Showbusjobwindow",getRootElement(),Showbusjobwindow) GUIEditor_Window = {} GUIEditor_Button = {} GUIEditor_Memo = {} GUIEditor_Window[1] = guiCreateWindow(335,371,488,186,"[LSR]BusJob",false) GUIEditor_Button[1] = guiCreateButton(186,142,104,35,"START",false,GUIEditor_Window[1]) guiSetAlpha(GUIEditor_Button[1],1) GUIEditor_Button[2] = guiCreateButton(457,153,22,24,"?",false,GUIEditor_Window[1]) GUIEditor_Button[3] = guiCreateButton(9,21,74,28,"EXIT",false,GUIEditor_Window[1]) GUIEditor_Memo[1] = guiCreateMemo(92,46,301,87,"",false,GUIEditor_Window[1]) guiMemoSetReadOnly(GUIEditor_Memo[1],true) guiSetVisible( GUIEditor_Window[1], false ) guiSetVisible( GUIEditor_Memo[1], false ) function exiting() if ( source == GUIEditor_Button[3] ) then guiSetVisible ( GUIEditor_Window[1], false ) showCursor( false ) guiSetInputEnabled( false ) end end addEventHandler("onClientGUIClick", getRootElement(), exiting) function showTheMemo() if ( source == GUIEditor_Button[2] ) then guiSetVisible ( GUIEditor_Memo[1], true ) end end addEventHandler("onClientGUIClick", getRootElement(), showTheMemo) function startTheJob() if ( source == GUIEditor_Button[1] ) then triggerServerEvent("StartBusJob", getRootElement()) guiSetVisible ( GUIEditor_Window[1], false ) showCursor( false ) guiSetInputEnabled( false ) end end addEventHandler("onClientGUIClick", getRootElement(), startTheJob) DEBUG ERRORS : SERVER SIDE WARNING: Bad 'Player' pointer @ 'setPlayerTeam'(1) WARNING Bad argument @ 'warpPedIntoVehicle' CLIENT SIDE NONE
Castillo Posted July 9, 2012 Posted July 9, 2012 Your problem is at the client side, here: triggerServerEvent("StartBusJob", getRootElement()) It should be: triggerServerEvent("StartBusJob", localPlayer)
Tete omar Posted July 9, 2012 Author Posted July 9, 2012 Your problem is at the client side, here: triggerServerEvent("StartBusJob", getRootElement()) It should be: triggerServerEvent("StartBusJob", localPlayer) How fast was you but it says bad argument @ warpPedIntoVehicle only and thanks
Tete omar Posted July 9, 2012 Author Posted July 9, 2012 Problem resolved thanks warpPedIntoVehicle ( source, bus ) but i got 1 more problem .. is there any code that destroy the old vehicle .. if the player keep clicking on start then it spawns 2 buses than more
Castillo Posted July 9, 2012 Posted July 9, 2012 You should make a table of the buses, then destroy old one.
Tete omar Posted July 9, 2012 Author Posted July 9, 2012 i got this Castillo client side function startTheJob() if ( source == GUIEditor_Button[1] ) then local getvehicle = guiGridListGetSelectedItem ( GUIEditor_Grid[1] ) if getvehicle == "Bus" then triggerServerEvent("StartBusJob", localPlayer) elseif getvehicle == "Coach" then triggerServerEvent("StartCoachJob", localPlayer) guiSetVisible ( GUIEditor_Window[1], false ) showCursor( false ) guiSetInputEnabled( false ) end end end addEventHandler("onClientGUIClick", getRootElement(), startTheJob) server side addEvent("StartBusJob", true) function StartBusJob() setPlayerTeam ( source, busteam) gX, gY, gZ = getElementPosition ( source ) bus = createVehicle ( 431, gX, gY, gZ ) warpPedIntoVehicle ( source, bus ) end addEventHandler("StartBusJob",getRootElement(),StartBusJob) addEvent("StartCoachJob", true) function StartBusJob() setPlayerTeam ( source, busteam) gX, gY, gZ = getElementPosition ( source ) coach = createVehicle ( 437, gX, gY, gZ ) warpPedIntoVehicle ( source, coach ) end addEventHandler("StartBusJob",getRootElement(),StartBusJob) i've created a gridlist here which allows you to choose coach or bus but if clicked on the button nothing happens
Wei Posted July 9, 2012 Posted July 9, 2012 you can use something like this remVehicle( player) -- here you create vehicle setElementData( vehicle, "Owner", getPlayerName(player) and then destroy it with function remVeh(source) for k, v in ipairs (getElementsByType("vehicle")) do if getElementData( v, "Owner" ) == getPlayerName(source) then destroyElement( v ) end end end function destroyVehicle() for k, v in ipairs (getElementsByType("vehicle")) do if getElementData( v, "Owner" ) == getPlayerName(source) then destroyElement(v) end end end addEventHandler("onPlayerQuit", root, destroyVehicle) addEventHandler("onPlayerWasted", root, destroyVehicle)
Castillo Posted July 9, 2012 Posted July 9, 2012 There's no need for that blazy, as I said before, he can make a table and store the vehicles of each player. Like this: --Outside function buses = { } --Inside function if ( isElement ( buses [ source ] ) ) then destroyElement ( buses [ source ] ) end buses [ source ] = createVehicle ( arguments... )
Tete omar Posted July 9, 2012 Author Posted July 9, 2012 There's no need for that blazy, as I said before, he can make a table and store the vehicles of each player.Like this: --Outside function buses = { } --Inside function if ( isElement ( buses [ source ] ) ) then destroyElement ( buses [ source ] ) end buses [ source ] = createVehicle ( arguments... ) i did it like this buses = { } function StartBusJob() setPlayerTeam ( source, busteam) gX, gY, gZ = getElementPosition ( source ) if ( isElement ( buses [ source ] ) ) then bus = createVehicle ( 431, gX, gY, gZ ) warpPedIntoVehicle ( source, bus ) destroyElement ( buses [ source ] ) buses [ source ] = bus end end addEventHandler("StartBusJob",getRootElement(),StartBusJob) i'm sure it's wrong
Castillo Posted July 9, 2012 Posted July 9, 2012 Yeah, it's wrong. buses = { } function StartBusJob ( ) setPlayerTeam ( source, busteam ) local gX, gY, gZ = getElementPosition ( source ) if ( isElement ( buses [ source ] ) ) then destroyElement ( buses [ source ] ) end buses [ source ] = createVehicle ( 431, gX, gY, gZ ) setTimer ( warpPedIntoVehicle, 200, 1, source, buses [ source ] ) end addEventHandler ( "StartBusJob", root, StartBusJob )
Tete omar Posted July 9, 2012 Author Posted July 9, 2012 buses = { } function StartBusJob ( ) setPlayerTeam ( source, busteam ) local gX, gY, gZ = getElementPosition ( source ) if ( isElement ( buses [ source ] ) ) then destroyElement ( buses [ source ] ) end buses [ source ] = createVehicle ( 431, gX, gY, gZ ) setTimer ( warpPedIntoVehicle, 200, 1 source, buses [ source ] ) -- here's the debug error end end addEventHandler ( "StartBusJob", root, StartBusJob ) debug says : ')' expected near source
Wei Posted July 9, 2012 Posted July 9, 2012 There's no need for that blazy, as I said before, he can make a table and store the vehicles of each player. It's easyer for me (I'm not pro)
Tete omar Posted July 9, 2012 Author Posted July 9, 2012 (edited) ok thanks Castillo Edited July 10, 2012 by Guest
Castillo Posted July 9, 2012 Posted July 9, 2012 I just wake up, forgot the 'end' as well. You're welcome.
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