AlexWo Posted July 25, 2012 Share Posted July 25, 2012 Hi I started scripting 2 days ago and I have a problem with my CarSpawner-server data. local vehMarker = createMarker( 312, 1824, 18, "Cylinder", 1.5, 0, 0, 255, 150) addEventHandler("onMarkerHit",vehMark,openVehicleSpawnServer) local x,y,z = getElementPosition(source) local myVeh = createVehicle(525,x+5,y,z) if myVeh then warpPedIntoVehicle(source,myVeh) outputChatBox("Fahrzeug erfolgreich gespawnt",source,0,153,0,true) else outputChatBox("Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!",source,190,160,050) end end addEvent ("SpawnVehicleServer",true) addEventHandler ("SpawnVehicleServer",root,spawnVehicleServer) this is the server code and everytime when I start the script I get ' expected near 'end' I know its an easy script but it would be cool if you guys could help me Thank you! Xaiberalex Link to comment
Castillo Posted July 25, 2012 Share Posted July 25, 2012 local vehMarker = createMarker( 312, 1824, 18, "Cylinder", 1.5, 0, 0, 255, 150) addEventHandler ( "onMarkerHit", vehMark, openVehicleSpawnServer ) function spawnVehicleServer ( ) local x,y,z = getElementPosition(source) local myVeh = createVehicle(525,x+5,y,z) if myVeh then warpPedIntoVehicle(source,myVeh) outputChatBox("Fahrzeug erfolgreich gespawnt",source,0,153,0,true) else outputChatBox("Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!",source,190,160,050) end end addEvent ("SpawnVehicleServer",true) addEventHandler ("SpawnVehicleServer",root,spawnVehicleServer) You forgot to create the function: function spawnVehicleServer ( ) Link to comment
AlexWo Posted July 25, 2012 Author Share Posted July 25, 2012 Ok i copyed it but now there is another problem. It sais: Bad argument @ ' addEventHandler' [Expected element at argument 2, got nil] I really hope you can help me with that problem aswell Xaiberalex Link to comment
Castillo Posted July 25, 2012 Share Posted July 25, 2012 Well, you are attaching the element: "vehMark" to the "onMarkerHit" event, but your element is "vehMarker". Link to comment
Callum Posted July 25, 2012 Share Posted July 25, 2012 Change 'vehMark' to 'vehMarker'. You should understand it, quite a simple problem. Link to comment
AlexWo Posted July 25, 2012 Author Share Posted July 25, 2012 Ok I changed it to vehMarker.. Now it sais: Bad argument @ ' addEventHandler' [Expected element at argument 2, got boolean] PS: Sry for annoying you with such easy problems. Link to comment
Castillo Posted July 25, 2012 Share Posted July 25, 2012 local vehMarker = createMarker ( 312, 1824, 18, "cylinder", 1.5, 0, 0, 255, 150 ) addEventHandler ( "onMarkerHit", vehMarker, openVehicleSpawnServer ) function spawnVehicleServer ( ) local x,y,z = getElementPosition(source) local myVeh = createVehicle(525,x+5,y,z) if myVeh then warpPedIntoVehicle(source,myVeh) outputChatBox("Fahrzeug erfolgreich gespawnt",source,0,153,0,true) else outputChatBox("Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!",source,190,160,050) end end addEvent ("SpawnVehicleServer",true) addEventHandler ("SpawnVehicleServer",root,spawnVehicleServer) P.S: You have the function: "openVehicleSpawnServer", right? Link to comment
AlexWo Posted July 25, 2012 Author Share Posted July 25, 2012 Yes and now I have the problem Bad argument @'addEventHandler' [Expected function at argument 3, got nil] Link to comment
Castillo Posted July 25, 2012 Share Posted July 25, 2012 Can you post your complete script? Link to comment
Callum Posted July 25, 2012 Share Posted July 25, 2012 ... You clearly didn't compile this code yourself. Ask the author. Link to comment
AlexWo Posted July 25, 2012 Author Share Posted July 25, 2012 Yes it's right but I thought maybe it works like this. I just have the server and the meta data. carspawner-server.lua : local vehMarker = createMarker ( 312, 1824, 18, "cylinder", 1.5, 0, 0, 255, 150 ) addEventHandler ( "onMarkerHit", vehMarker, openVehicleSpawnServer ) function spawnVehicleServer ( ) local x,y,z = getElementPosition(source) local myVeh = createVehicle(525,x+5,y,z) if myVeh then warpPedIntoVehicle(source,myVeh) outputChatBox("Fahrzeug erfolgreich gespawnt",source,0,153,0,true) else outputChatBox("Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!",source,190,160,050) end end addEvent ("SpawnVehicleServer",true) addEventHandler ("SpawnVehicleServer",root,spawnVehicleServer) the meta.xml file : <meta> <info author="Alex" name="carspawn" version="1.0" type="script"/> <script src="carspawn-server.lua" type="server"/> </meta> And the problem I still have is : Bad argument @'addEventHandler' [Expected function at argument 3, got nil] Link to comment
Castillo Posted July 25, 2012 Share Posted July 25, 2012 local vehMarker = createMarker ( 312, 1824, 18, "cylinder", 1.5, 0, 0, 255, 150 ) function spawnVehicleServer ( thePlayer ) local x, y, z = getElementPosition ( thePlayer ) local myVeh = createVehicle ( 525, x + 5, y, z ) if ( myVeh ) then warpPedIntoVehicle ( thePlayer, myVeh ) outputChatBox ( "Fahrzeug erfolgreich gespawnt", thePlayer, 0, 153, 0, true ) else outputChatBox ( "Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!", thePlayer, 190, 160, 50 ) end end addEventHandler ( "onMarkerHit", vehMarker, spawnVehicleServer ) That'll spawn the vehicle when a player hits the marker. Link to comment
AlexWo Posted July 25, 2012 Author Share Posted July 25, 2012 Ok thank you guys It works now like I want it but I have 1 last question. How to make that if a player spawns a vehicle and than hit the marker a second time his first vehicle disappears. I hope you understand what i mean. Link to comment
Castillo Posted July 25, 2012 Share Posted July 25, 2012 You must make a table to store all vehicles. local vehMarker = createMarker ( 312, 1824, 18, "cylinder", 1.5, 0, 0, 255, 150 ) local vehicles = { } function spawnVehicleServer ( thePlayer ) if ( isElement ( vehicles [ thePlayer ] ) ) then destroyElement ( vehicles [ thePlayer ] ) end local x, y, z = getElementPosition ( thePlayer ) vehicles [ thePlayer ] = createVehicle ( 525, x + 5, y, z ) if ( vehicles [ thePlayer ] ) then warpPedIntoVehicle ( thePlayer, vehicles [ thePlayer ] ) outputChatBox ( "Fahrzeug erfolgreich gespawnt", thePlayer, 0, 153, 0, true ) else outputChatBox ( "Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!", thePlayer, 190, 160, 50 ) end end addEventHandler ( "onMarkerHit", vehMarker, spawnVehicleServer ) Link to comment
Al3grab Posted July 26, 2012 Share Posted July 26, 2012 Hi I started scripting 2 days ago and I have a problem with my CarSpawner-server data. local vehMarker = createMarker( 312, 1824, 18, "Cylinder", 1.5, 0, 0, 255, 150) addEventHandler("onMarkerHit",vehMark,openVehicleSpawnServer) local x,y,z = getElementPosition(source) local myVeh = createVehicle(525,x+5,y,z) if myVeh then warpPedIntoVehicle(source,myVeh) outputChatBox("Fahrzeug erfolgreich gespawnt",source,0,153,0,true) else outputChatBox("Fahrzeugspawn fehlgeschlagen, kontaktiere den Scripter/Hoster!",source,190,160,050) end end addEvent ("SpawnVehicleServer",true) addEventHandler ("SpawnVehicleServer",root,spawnVehicleServer) this is the server code and everytime when I start the script I get ' expected near 'end' I know its an easy script but it would be cool if you guys could help me Thank you! Xaiberalex Please use ( lua ) button instead of ( Code ) , and good luck ! 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