Jump to content

AlexWo

Members
  • Posts

    67
  • Joined

  • Last visited

Everything posted by AlexWo

  1. Yes I could, but the problem is the server don't shows any Errors.... just that the script is working fine..... so maybe I made a mistake in the script or thats isn't working in the way I did.... IDK
  2. I made this script today but it's not working. Client-Side: teleporter = { createMarker( 1742, -1944, 13.5, "cylinder", 1.5, 0, 255, 255) createMarker( 1745, -1944, 13.5, "cylinder", 1.5, 0, 255, 255) } local Teleports = { "LosSantos", "LasVenturas", "SanFierro" } addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) for _, marker in ipairs ( teleporter ) do addEventHandler ( "onClientMarkerHit", marker, onMarkerHit ) addEventHandler ( "onClientMarkerLeave", marker, onMarkerLeave ) end end ) function createTeleportGui ( ) MainGui = guiCreateWindow (408,203,240,349,"Teleporter",false) guiWindowSetSizable ( MainGui, false ) TeleportGrid = guiCreateGridList(14,32,180,256,false,MainGui) guiGridListSetSelectionMode(TeleportGrid,2) _teleports = guiGridListAddColumn(TeleportGrid,"Teleport",0.85) Teleport = guiCreateButton(15,305,96,35,"Teleport",false,MainGui) guiSetFont(Teleport,"clear-normal") Leave = guiCreateButton(128,305,96,35,"Leave",false,MainGui) guiSetFont(Leave,"clear-normal") for index, teleport in ipairs(Teleports) do local row = guiGridListAddRow (TeleportGrid) guiGridListSetItemText ( TeleportGrid, row, _teleports, tostring(Teleports), false, false ) end end function onMarkerHit(hitElement) if hitElement == localPlayer then createTeleportGui() if MainGui then guiSetVisible(MainGui,true) showCursor(true) guiSetInputEnabled(true) setElementFrozen(localPlayer,true) end end end end addEventHandler ( "onClientGUIClick", root, function ( ) if ( source == Teleport ) then local row,col = guiGridListGetSelectedItem ( TeleportGrid ) if ( row and col and row ~= -1 and col ~= -1 ) then local teleportName = guiGridListGetItemText(TeleportGrid, row, 1) if teleportName == "LosSantos" then triggerServerEvent("spawnLosSantos",localPlayer,teleportName) elseif teleportName == "LasVenturas" then triggerServerEvent("spawnLasVenturas",localPlayer,teleportName) elseif teleportName == "SanFierro" then triggerServerEvent("spawnSanFierro",localPlayer, teleportName) end else outputChatBox("Error, Please select a Teleport of the list.",255,0,0) end elseif (source == Leave) then triggerEvent("closeWindow", localPlayer ) end end ) addEventHandler("onClientGUIDoubleClick", root, function () if ( source == TeleportGrid ) then local row,col = guiGridListGetSelectedItem(TeleportGrid) if (row and col and row ~= -1 and col ~= -1) then local teleportName = guiGridListGetItemText(TeleportGrid, row, teleportName) if teleportName == "LosSantos" then triggerServerEvent("spawnLosSantos",localPlayer,teleportName) elseif teleportName == "LasVenturas" then triggerServerEvent("spawnLasVenturas",localPlayer, teleportName) elseif teleportName == "SanFierro" then triggerServerEvent("spawnSanfierro",localPlayer, teleportName) end end end end ) function onMarkerLeave ( leaveElement ) if ( leaveElement == localPlayer ) then triggerEvent("closeWindow", localPlayer ) end end addEvent ( "closeWindow", true ) addEventHandler ( "closeWindow", root, function ( ) guiSetVisible ( MainGui, false ) showCursor ( false ) guiSetInputEnabled ( false ) setElementFrozen ( localPlayer, false ) end Server-Sider: local x,y,z local LosSantos local LasVenturas local SanFierro addEvent("spawnLosSantos", true) addEventHandler("spawnLosSantos", root, function() setElementPosition ( localPlayer, 1544, -1352, 329 ) triggerClientEvent("closeWindow", root) end ) addEvent("spawnLasVenturas", true) addEventHandler("spawnLasVenturas", root, function() setElementPosition ( localPlayer, 1996, 1588, 26) triggerClientEvent("closeWindow", root) end ) addEvent("spawnSanFierro", true) addEventHandler("spawnSanFierro", root, function() setElementPosition ( localPlayer, -1790, 567, 332) triggerClientEvent("closeWindow", root) end ) Maybe you will find a mistake in it...
  3. I have a vehiclespawner script and I want to add that if a player enters the marker for the vehiclespawner the server checks his/her Team and if the team is "Police", he/she can spawn a vehicle. Client Side: markers = { createMarker ( 308, 1813, 17, 'cylinder', 1.5, 255, 0, 0, 255 ), createMarker ( 213, 1911, 17, 'cylinder', 1.5, 255, 0, 0, 255 ) } local vehicles = { "Patriot", "Sanchez", "Barracks", "Hydra", "Hunter" } addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) for _, marker in ipairs ( markers ) do addEventHandler ( "onClientMarkerHit", marker, onMarkerHit ) addEventHandler ( "onClientMarkerLeave", marker, onMarkerLeave ) end end ) function createVehGui ( ) MainGui = guiCreateWindow(408,203,240,349,"Spawn bike",false) guiWindowSetSizable ( MainGui, 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 function onMarkerHit ( hitElement ) if ( hitElement == localPlayer ) then createVehGui ( hitElement ) if ( MainGui ~= nil ) then guiSetVisible ( MainGui, true ) showCursor ( true ) guiSetInputEnabled ( true ) setElementFrozen ( hitElement, true ) 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 == "Patriot" then triggerServerEvent("spawnPatriot",localPlayer,vehicleName) elseif vehicleName == "Sanchez" then triggerServerEvent("spawnSanchez",localPlayer,vehicleName) elseif vehicleName == "Barracks" then triggerServerEvent("spawnBarracks",localPlayer, vehicleName) elseif vehicleName == "Hydra" then triggerServerEvent("spawnHydra",localPlayer, vehicleName) elseif vehicleName == "Hunter" then triggerServerEvent("spawnHunter",localPlayer, vehicleName) end else outputChatBox("Error: Please, select a vehicle of list.",255,0,0) end elseif (source == Cancel) then triggerEvent("closeWindow", localPlayer ) end end ) addEventHandler("onClientGUIDoubleClick", root, function () if ( source == VehGrid ) then local row,col = guiGridListGetSelectedItem(VehGrid) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(VehGrid, row, vehicleName) if vehicleName == "Patriot" then triggerServerEvent("spawnPatriot",localPlayer,vehicleName) elseif vehicleName == "Sanchez" then triggerServerEvent("spawnSanchez",localPlayer, vehicleName) elseif vehicleName == "Barracks" then triggerServerEvent("spawnBarracks",localPlayer, vehicleName) elseif vehicleName == "Hydra" then triggerServerEvent("spawnHydra",localPlayer, vehicleName) elseif vehicleName == "Hunter" then triggerServerEvent("spawnHunter",localPlayer, vehicleName) end end end end ) function onMarkerLeave ( leaveElement ) if ( leaveElement == localPlayer ) then triggerEvent("closeWindow", localPlayer ) end end addEvent ( "closeWindow", true ) addEventHandler ( "closeWindow", root, function ( ) guiSetVisible ( MainGui, false ) showCursor ( false ) guiSetInputEnabled ( false ) setElementFrozen ( localPlayer, false ) end ) I think at the fuction onMarkerHit there has to be localPlayer = getPlayerTeam ( source ) if ( playerTeam = "Police" ) then But I don't know.... I tried it once but I failed....
  4. Hey Guys, I have a Vehiclespawner and I want that I have multiple marker's for the script at different locations. Here ist the Script: Client: local marker = createMarker(308, 1813, 17, 'cylinder', 1.5, 255, 0, 0, 255) local vehicles = {"Patriot", "Sanchez", "Barracks", "Hydraa", "Hunter"} function createVehGui () MainGui = guiCreateWindow(408,203,240,349,"Spawn bike",false) guiWindowSetSizable ( MainGui, 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", marker, function ( hitElement ) if ( hitElement == localPlayer ) then createVehGui ( hitElement ) if ( MainGui ~= nil ) then guiSetVisible ( MainGui, true ) showCursor ( true ) guiSetInputEnabled ( true ) setElementFrozen ( hitElement, true ) 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 == "Patriot" then triggerServerEvent("spawnPatriot",localPlayer,vehicleName) elseif vehicleName == "Sanchez" then triggerServerEvent("spawnSanchez",localPlayer,vehicleName) elseif vehicleName == "Barracks" then triggerServerEvent("spawnBarracks",localPlayer, vehicleName) elseif vehicleName == "Hydraa" then triggerServerEvent("spawnHydraa",localPlayer, vehicleName) elseif vehicleName == "Hunter" then triggerServerEvent("spawnHunter",localPlayer, vehicleName) end else outputChatBox("Error: Please, select a vehicle of list.",255,0,0) end elseif (source == Cancel) then triggerEvent("closeWindow", root ) end end ) addEventHandler("onClientGUIDoubleClick", root, function () if ( source == VehGrid ) then local row,col = guiGridListGetSelectedItem(VehGrid) if (row and col and row ~= -1 and col ~= -1) then local vehicleName = guiGridListGetItemText(VehGrid, row, vehicleName) if vehicleName == "Patriot" then triggerServerEvent("spawnPatriot",localPlayer,vehicleName) elseif vehicleName == "Sanchez" then triggerServerEvent("spawnSanchez",localPlayer, vehicleName) elseif vehicleName == "Barracks" then triggerServerEvent("spawnBarracks",localPlayer, vehicleName) elseif vehicleName == "Hydraa" then triggerServerEvent("spawnHydraa",localPlayer, vehicleName) elseif vehicleName == "Hunter" then triggerServerEvent("spawnHunter",localPlayer, vehicleName) end end end end ) addEventHandler("onClientMarkerLeave", marker, function () triggerEvent("closeWindow", root ) end ) addEvent("closeWindow", true) addEventHandler("closeWindow", root, function () guiSetVisible(MainGui, false) showCursor(false) guiSetInputEnabled(false) setElementFrozen(localPlayer, false) end ) At the top of the script I want to have more marker with different locations added. I hope you understand what I mean. It would be nice if somebody could help me Thank you Xaiberalex
  5. Hi guys I have a script where I can write "/placespeaker" a speaker get placed on the map and than some music starts playing. But now I want to attach the music to a vehicle. The problem is I can't find the element for the music. Server: function createSpeaker(thePlayer) local x, y, z = getElementPosition(thePlayer) car = createVehicle(470, x, y, z-1) speakerObject = createObject(2229, x, y, z-1) attachElements ( speakerObject, car, 0, 0, 2 ) outputChatBox("Succesfully created a speaker!", thePlayer, 0, 250, 0) triggerClientEvent(root, "playTheSound", root, x, y, z) attachElements( , speakerObject, 0, 0, 2 ) end addCommandHandler("placespeaker", createSpeaker) function deleteSpeaker(thePlayer) if (isElement(speakerObject)) then destroyElement(speakerObject) outputChatBox("Succesfully destroyed", thePlayer, 0, 250, 0) triggerClientEvent("stopTheSound", root) else outputChatBox("Object is not created.", thePlayer, 250, 0, 0) end end addCommandHandler("destroyspeaker", deleteSpeaker) Client: local url = "http://a.tumblr.com/tumblr_m316nasa2R1rnvv34o1_r1.mp3" function playTheSound(x, y, z) sound = playSound3D(url, x, y, z) end addEvent("playTheSound", true) addEventHandler("playTheSound", root, playTheSound) function stopTheSound(x, y, z) stopSound(sound) end addEvent("stopTheSound", true) addEventHandler("stopTheSound", root, stopTheSound) at the server-script side line no. 8 ... I don't know what the "SOUND" element is named. Maybe you guys can help me.... Xaiberalex
  6. Client: function onResourceStart() local sound = playSound3D("sounds/Avicii.mp3", 373.14, -125.21, 1001, true) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onResourceStart) Meta: "Alex" name="RoundMusic" version="1.0.0" type="script"/> everytime when I start the script it sais : Couldn't find the script music/Avicii.mp3 for resource speaker
  7. Yes ok but I meaned that I want that a player got freezed with his car when he arrives at a checkpoint
  8. Client: ---------------------------------------------------------------------------------------------------------------------------------- --Tug TABLE ---------------------------------------------------------------------------------------------------------------------------------- local tugTable = { [1]={-1336, -513, 15}, [2]={-1411, -552, 15}, [3]={-1442, -122, 15}, [4]={-1263, 36, 15}, [5]={-1203, 28, 15}, [6]={-1239, -8, 15}, [7]={-1567, -431, 7}, [8]={-1428, -312, 6}, [9]={-1549, -453, 6} --<----- LA ULTIMA LINEA DE TABLA NO LLEVA COMA } ---------------------------------------------------------------------------------------------------------------------------------- --GET TUG LOCATION ---------------------------------------------------------------------------------------------------------------------------------- function getTugLocation(ID) if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end local x, y, z = tugTable[ID][1], tugTable[ID][2], tugTable[ID][3] local marker = createMarker(x,y,z,"checkpoint",10,10,235,250,150) local blip = createBlipAttachedTo(marker,19,2,10,235,250,225) function rewardPlayer (hitPlayer) if hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then if getElementVelocity(getPedOccupiedVehicle(hitPlayer)) <= 2 then if getElementModel(getPedOccupiedVehicle(hitPlayer)) == 583 then playSoundFrontEnd (11) triggerServerEvent("DriverGiveMoney",getLocalPlayer(),math.random(80,100)) if #tugTable == tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver")) then setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",1) else setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))+1) end blipsAttached = getAttachedElements (source) for i,blips in ipairs (blipsAttached) do if getElementType (blips) == "blip" then destroyElement(blips) end end if isElement (source) then destroyElement(source) end getTugLocation(tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))) end else outputChatBox ("*You're going very fast!",hitPlayer,10,235,250) end end end addEventHandler("onClientMarkerHit",marker,rewardPlayer,hitPlayer) addEventHandler("onClientVehicleExit",getRootElement(), function (leaveElement) if leaveElement == getLocalPlayer() then if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end end end) end ---------------------------------------------------------------------------------------------------------------------------------- --ON CLIENT VEHICLE ENTER ---------------------------------------------------------------------------------------------------------------------------------- addEventHandler("onClientVehicleEnter",getRootElement(), function (thePlayer) if getElementModel(source) == 583 and getElementModel(thePlayer) == 16 and thePlayer == getLocalPlayer() then outputChatBox ("Now You Can Go To The Airport For Job",10,235,250) getTugLocation(1) setElementData(thePlayer,"SAMR.jobs_civilian_train_driver",1) end end) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Tug GUI ----------------------------------------------------------------------------------------------------------------------------- function tugCreateTugGUI() tug_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Tug Mission",true) memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Welcome to the Cargo job, please take a Tug and go to the next Marker",true,tug_window_main) tug_window_main_button_accept = guiCreateButton(0.52,0.85,0.45,0.1,"Acept",true,tug_window_main) tug_window_main_button_decline = guiCreateButton(0,0.85,0.45,0.1,"Decline",true,tug_window_main) showCursor (true) end addEvent ("tugCreateTugGUI",true) addEventHandler ("tugCreateTugGUI",getResourceRootElement(getThisResource()),tugCreateTugGUI) ----------------------------------------------------------------------------------------------------------------------------- --DESTROY Tug GUI ----------------------------------------------------------------------------------------------------------------------------- function tugDestroyTugGUI() destroyElement(tug_window_main) tug_window_main = false showCursor (false) end ----------------------------------------------------------------------------------------------------------------------------- --ON tug WINDOW CLICK ----------------------------------------------------------------------------------------------------------------------------- function tugOnTugWindowClick() if source == tug_window_main_button_accept then triggerServerEvent ("tugCreateTug",getLocalPlayer()) tugDestroyTugGUI () elseif source == tug_window_main_button_decline then tugDestroyTugGUI () end end addEventHandler("onClientGUIClick",getRootElement(),tugOnTugWindowClick) Server ----------------------------------------------------------------------------------------------------------------------------- --CREATE Tug STUFF ----------------------------------------------------------------------------------------------------------------------------- function tugCreateTugStuff() tug_marker_request = createMarker(-1546,-441,6,"arrow",2, 225, 225, 0, 150 ) blip2 = createBlip (-1546,-441,6,40) end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),tugCreateTugStuff) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Tug ----------------------------------------------------------------------------------------------------------------------------- function tugCreateTug () theTug = createVehicle (583,-1545,-430,6,40) setElementModel(source, 16) outputChatBox ("*The Tug is behind you.",source,10,235,250) end addEvent ("tugCreateTug",true) addEventHandler ("tugCreateTug",getRootElement(),tugCreateTug) ---------------------------------------------------------------------------------------------------------------------------------- --GIVE MONEY ---------------------------------------------------------------------------------------------------------------------------------- addEvent ("DriverGiveMoney",true) addEventHandler ("DriverGiveMoney",getRootElement(), function (theMoney) givePlayerMoney(source,theMoney) end) ---------------------------------------------------------------------------------------------------------------------------------- --CREATE Tug GUI ---------------------------------------------------------------------------------------------------------------------------------- function tugCreateTugGUI(hitElement) if source == tug_marker_request then triggerClientEvent (hitElement,"tugCreateTugGUI",getRootElement()) end end addEventHandler ("onMarkerHit",getRootElement(),tugCreateTugGUI)
  9. Hi guys I have a job and I want that if a player with the vehicle arrive at the marker he get frozed for 3 seconds. I already tried to put a timer into the script but it doesn't work Client file ---------------------------------------------------------------------------------------------------------------------------------- --Tug TABLE ---------------------------------------------------------------------------------------------------------------------------------- local tugTable = { [1]={-1336, -513, 15}, [2]={-1411, -552, 15}, [3]={-1442, -122, 15}, [4]={-1263, 36, 15}, [5]={-1203, 28, 15}, [6]={-1239, -8, 15}, [7]={-1567, -431, 7}, [8]={-1428, -312, 6}, [9]={-1549, -453, 6} --<----- LA ULTIMA LINEA DE TABLA NO LLEVA COMA } ---------------------------------------------------------------------------------------------------------------------------------- --GET TUG LOCATION ---------------------------------------------------------------------------------------------------------------------------------- function getTugLocation(ID) if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end local x, y, z = tugTable[iD][1], tugTable[iD][2], tugTable[iD][3] local marker = createMarker(x,y,z,"checkpoint",10,10,235,250,150) local blip = createBlipAttachedTo(marker,19,2,10,235,250,225) function rewardPlayer (hitPlayer) if hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then if getElementVelocity(getPedOccupiedVehicle(hitPlayer)) <= 2 then outputChatBox ("You arrived succesfully!",hitPlayer,10,235,250) if getElementModel(getPedOccupiedVehicle(hitPlayer)) == 583 then playSoundFrontEnd (11) triggerServerEvent("DriverGiveMoney",getLocalPlayer(),math.random(80,100)) if #tugTable == tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver")) then setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",1) else setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))+1) end blipsAttached = getAttachedElements (source) for i,blips in ipairs (blipsAttached) do if getElementType (blips) == "blip" then destroyElement(blips) end end if isElement (source) then destroyElement(source) end getTugLocation(tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))) end else outputChatBox ("*You're going very fast!",hitPlayer,10,235,250) end end end addEventHandler("onClientMarkerHit",marker,rewardPlayer,hitPlayer) addEventHandler("onClientVehicleExit",getRootElement(), function (leaveElement) if leaveElement == getLocalPlayer() then if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end end end) end ---------------------------------------------------------------------------------------------------------------------------------- --ON CLIENT VEHICLE ENTER ---------------------------------------------------------------------------------------------------------------------------------- addEventHandler("onClientVehicleEnter",getRootElement(), function (thePlayer) if getElementModel(source) == 583 and getElementModel(thePlayer) == 16 and thePlayer == getLocalPlayer() then outputChatBox ("Now You Can Go To The Airport For Job",10,235,250) getTugLocation(1) setElementData(thePlayer,"SAMR.jobs_civilian_train_driver",1) end end) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Tug GUI ----------------------------------------------------------------------------------------------------------------------------- function tugCreateTugGUI() tug_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Tug Mission",true) memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Welcome to the Cargo job, please take a Tug and go to the next Marker",true,tug_window_main) tug_window_main_button_accept = guiCreateButton(0.52,0.85,0.45,0.1,"Acept",true,tug_window_main) tug_window_main_button_decline = guiCreateButton(0,0.85,0.45,0.1,"Decline",true,tug_window_main) showCursor (true) end addEvent ("tugCreateTugGUI",true) addEventHandler ("tugCreateTugGUI",getResourceRootElement(getThisResource()),tugCreateTugGUI) ----------------------------------------------------------------------------------------------------------------------------- --DESTROY Tug GUI ----------------------------------------------------------------------------------------------------------------------------- function tugDestroyTugGUI() destroyElement(tug_window_main) tug_window_main = false showCursor (false) end ----------------------------------------------------------------------------------------------------------------------------- --ON tug WINDOW CLICK ----------------------------------------------------------------------------------------------------------------------------- function tugOnTugWindowClick() if source == tug_window_main_button_accept then triggerServerEvent ("tugCreateTug",getLocalPlayer()) tugDestroyTugGUI () elseif source == tug_window_main_button_decline then tugDestroyTugGUI () end end addEventHandler("onClientGUIClick",getRootElement(),tugOnTugWindowClick) Server file: ----------------------------------------------------------------------------------------------------------------------------- --CREATE Tug STUFF ----------------------------------------------------------------------------------------------------------------------------- function tugCreateTugStuff() tug_marker_request = createMarker(-1546,-441,6,"arrow",2, 225, 225, 0, 150 ) blip2 = createBlip (-1546,-441,6,40) end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),tugCreateTugStuff) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Tug ----------------------------------------------------------------------------------------------------------------------------- function tugCreateTug () theTug = createVehicle (583,-1546,-441,6,40) setElementModel(source, 16) outputChatBox ("*The Tug is behind you.",source,10,235,250) end addEvent ("tugCreateTug",true) addEventHandler ("tugCreateTug",getRootElement(),tugCreateTug) ---------------------------------------------------------------------------------------------------------------------------------- --GIVE MONEY ---------------------------------------------------------------------------------------------------------------------------------- addEvent ("DriverGiveMoney",true) addEventHandler ("DriverGiveMoney",getRootElement(), function (theMoney) givePlayerMoney(source,theMoney) end) ---------------------------------------------------------------------------------------------------------------------------------- --CREATE Tug GUI ---------------------------------------------------------------------------------------------------------------------------------- function tugCreateTugGUI(hitElement) if source == tug_marker_request then triggerClientEvent (hitElement,"tugCreateTugGUI",getRootElement()) end end addEventHandler ("onMarkerHit",getRootElement(),tugCreateTugGUI) I think there have to be a timer in the Client file...
  10. Ok hey guys I found a pilot job and I downloaded it. Then I started making my own job( I just chaged some data in the "pilotjob-script". Well now my Job is working but if im running both jobs at the same time on my server and I take one of this jobs , both jobs start I don't know exactly why but for example If I take my job then its starts my job and the plane job to my player. Here is the original "Pilot job script" Server: ----------------------------------------------------------------------------------------------------------------------------- --CREATE Plane STUFF ----------------------------------------------------------------------------------------------------------------------------- function planeCreatePlaneStuff() plane_marker_request = createMarker(-1146.98,-240.68,13.14,"arrow",2, 225, 225, 0, 150 ) blip2 = createBlip (-1146.98,-240.68,13.14,5) end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),planeCreatePlaneStuff) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Plane ----------------------------------------------------------------------------------------------------------------------------- function planeCreatePlane () thePlane = createVehicle (553,-1163.93,-269.41,17.15) outputChatBox ("*The Plane is behind you.",source,10,235,250) end addEvent ("planeCreatePlane",true) addEventHandler ("planeCreatePlane",getRootElement(),planeCreatePlane) ---------------------------------------------------------------------------------------------------------------------------------- --GIVE MONEY ---------------------------------------------------------------------------------------------------------------------------------- addEvent ("jobsTrainDriverGiveMoney",true) addEventHandler ("jobsTrainDriverGiveMoney",getRootElement(), function (theMoney) givePlayerMoney(source,theMoney) end) ---------------------------------------------------------------------------------------------------------------------------------- --CREATE Plane GUI ---------------------------------------------------------------------------------------------------------------------------------- function planeCreatePlaneGUI(hitElement) if source == plane_marker_request then triggerClientEvent (hitElement,"planeCreatePlaneGUI",getRootElement()) end end addEventHandler ("onMarkerHit",getRootElement(),planeCreatePlaneGUI) Client: ---------------------------------------------------------------------------------------------------------------------------------- --Plane TABLE ---------------------------------------------------------------------------------------------------------------------------------- local planeTable = { [1]={1324.92,1581.27,9.82}, [2]={350.09,2537.41,15.73}, [3]={-1349.78,-233.62,13.14}, [4]={1650.08,-2441.07,12.55}--<----- LA ULTIMA LINEA DE TABLA NO LLEVA COMA } ---------------------------------------------------------------------------------------------------------------------------------- --GET PLANE LOCATION ---------------------------------------------------------------------------------------------------------------------------------- function getPlaneLocation(ID) if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end local x, y, z = planeTable[iD][1], planeTable[iD][2], planeTable[iD][3] local marker = createMarker(x,y,z,"checkpoint",10,10,235,250,150) local blip = createBlipAttachedTo(marker,19,2,10,235,250,225) function rewardPlayer (hitPlayer) if hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then if getElementVelocity(getPedOccupiedVehicle(hitPlayer)) <= 2 then outputChatBox ("You arrived succesfully!",hitPlayer,10,235,250) if getElementModel(getPedOccupiedVehicle(hitPlayer)) == 553 then playSoundFrontEnd (11) triggerServerEvent("jobsTrainDriverGiveMoney",getLocalPlayer(),math.random(700,800)) if #planeTable == tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver")) then setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",1) else setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))+1) end blipsAttached = getAttachedElements (source) for i,blips in ipairs (blipsAttached) do if getElementType (blips) == "blip" then destroyElement(blips) end end if isElement (source) then destroyElement(source) end getPlaneLocation(tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))) end else outputChatBox ("*You're going very fast!",hitPlayer,10,235,250) end end end addEventHandler("onClientMarkerHit",marker,rewardPlayer,hitPlayer) addEventHandler("onClientVehicleExit",getRootElement(), function (leaveElement) if leaveElement == getLocalPlayer() then if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end end end) end ---------------------------------------------------------------------------------------------------------------------------------- --ON CLIENT VEHICLE ENTER ---------------------------------------------------------------------------------------------------------------------------------- addEventHandler("onClientVehicleEnter",getRootElement(), function (thePlayer) if getElementModel(source) == 553 and getElementModel(thePlayer) == 61 and thePlayer == getLocalPlayer() then outputChatBox ("Now You Can Go To Diferents Airports For Delivery",10,235,250) getPlaneLocation(1) setElementData(thePlayer,"SAMR.jobs_civilian_train_driver",1) end end) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Plane GUI ----------------------------------------------------------------------------------------------------------------------------- function planeCreatePlaneGUI() plane_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Plane Missions",true) memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Hello im Robbie, please take the plane and go to the next airport",true,plane_window_main) plane_window_main_button_accept = guiCreateButton(0.52,0.85,0.45,0.1,"Acept",true,plane_window_main) plane_window_main_button_decline = guiCreateButton(0,0.85,0.45,0.1,"Decline",true,plane_window_main) showCursor (true) end addEvent ("planeCreatePlaneGUI",true) addEventHandler ("planeCreatePlaneGUI",getResourceRootElement(getThisResource()),planeCreatePlaneGUI) ----------------------------------------------------------------------------------------------------------------------------- --DESTROY Plane GUI ----------------------------------------------------------------------------------------------------------------------------- function planeDestroyPlaneGUI() destroyElement(plane_window_main) plane_window_main = false showCursor (false) end ----------------------------------------------------------------------------------------------------------------------------- --ON plane WINDOW CLICK ----------------------------------------------------------------------------------------------------------------------------- function planeOnPlaneWindowClick() if source == plane_window_main_button_accept then triggerServerEvent ("planeCreatePlane",getLocalPlayer()) planeDestroyPlaneGUI () elseif source == plane_window_main_button_decline then planeDestroyPlaneGUI () end end addEventHandler("onClientGUIClick",getRootElement(),planeOnPlaneWindowClick) Now my Changed Job: Server: ----------------------------------------------------------------------------------------------------------------------------- --CREATE Plane STUFF ----------------------------------------------------------------------------------------------------------------------------- function planeCreatePlaneStuff() plane_marker_request = createMarker(816,856,13,"arrow",2, 225, 225, 0, 150 ) blip2 = createBlip (816,856,12.7,56) end addEventHandler ("onResourceStart",getResourceRootElement(getThisResource()),planeCreatePlaneStuff) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Plane ----------------------------------------------------------------------------------------------------------------------------- function planeCreatePlane () thePlane = createVehicle (406,832,832,13) setElementModel(source, 260) outputChatBox ("*The Dumper is behind you.",source,10,235,250) end addEvent ("planeCreatePlane",true) addEventHandler ("planeCreatePlane",getRootElement(),planeCreatePlane) ---------------------------------------------------------------------------------------------------------------------------------- --GIVE MONEY ---------------------------------------------------------------------------------------------------------------------------------- addEvent ("jobsTrainDriverGiveMoney",true) addEventHandler ("jobsTrainDriverGiveMoney",getRootElement(), function (theMoney) givePlayerMoney(source,theMoney) end) ---------------------------------------------------------------------------------------------------------------------------------- --CREATE Plane GUI ---------------------------------------------------------------------------------------------------------------------------------- function planeCreatePlaneGUI(hitElement) if source == plane_marker_request then triggerClientEvent (hitElement,"planeCreatePlaneGUI",getRootElement()) end end addEventHandler ("onMarkerHit",getRootElement(),planeCreatePlaneGUI) Client: ---------------------------------------------------------------------------------------------------------------------------------- --Plane TABLE ---------------------------------------------------------------------------------------------------------------------------------- local planeTable = { [1]={683,977,-12.7}, [2]={633,950,-34}, [3]={600,820,-43}, [4]={500,926,-29}, [5]={813,844,11}, [6]={835,1116,32}, [7]={350,900,22}, [8]={835,1116,32}--<----- LA ULTIMA LINEA DE TABLA NO LLEVA COMA } ---------------------------------------------------------------------------------------------------------------------------------- --GET PLANE LOCATION ---------------------------------------------------------------------------------------------------------------------------------- function getPlaneLocation(ID) if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end local x, y, z = planeTable[iD][1], planeTable[iD][2], planeTable[iD][3] local marker = createMarker(x,y,z,"checkpoint",10,10,235,250,150) local blip = createBlipAttachedTo(marker,19,2,10,235,250,225) function rewardPlayer (hitPlayer) if hitPlayer == getLocalPlayer() and isPedInVehicle(hitPlayer) then if getElementVelocity(getPedOccupiedVehicle(hitPlayer)) <= 2 then outputChatBox ("You arrived succesfully!",hitPlayer,10,235,250) if getElementModel(getPedOccupiedVehicle(hitPlayer)) == 406 then playSoundFrontEnd (11) triggerServerEvent("jobsTrainDriverGiveMoney",getLocalPlayer(),math.random(80,100)) if #planeTable == tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver")) then setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",1) else setElementData(hitPlayer,"SAMR.jobs_civilian_train_driver",tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))+1) end blipsAttached = getAttachedElements (source) for i,blips in ipairs (blipsAttached) do if getElementType (blips) == "blip" then destroyElement(blips) end end if isElement (source) then destroyElement(source) end getPlaneLocation(tonumber(getElementData(hitPlayer,"SAMR.jobs_civilian_train_driver"))) end else outputChatBox ("*You're going very fast!",hitPlayer,10,235,250) end end end addEventHandler("onClientMarkerHit",marker,rewardPlayer,hitPlayer) addEventHandler("onClientVehicleExit",getRootElement(), function (leaveElement) if leaveElement == getLocalPlayer() then if isElement (marker) then destroyElement(marker) end if isElement (blip) then destroyElement(blip) end end end) end ---------------------------------------------------------------------------------------------------------------------------------- --ON CLIENT VEHICLE ENTER ---------------------------------------------------------------------------------------------------------------------------------- addEventHandler("onClientVehicleEnter",getRootElement(), function (thePlayer) if getElementModel(source) == 406 and getElementModel(thePlayer) == 260 and thePlayer == getLocalPlayer() then outputChatBox ("Now You Can Go To Diferents Airports For Delivery",10,235,250) getPlaneLocation(1) setElementData(thePlayer,"SAMR.jobs_civilian_train_driver",1) end end) ----------------------------------------------------------------------------------------------------------------------------- --CREATE Plane GUI ----------------------------------------------------------------------------------------------------------------------------- function planeCreatePlaneGUI() plane_window_main = guiCreateWindow (0.3,0.2,0.4,0.5,"Plane Missions",true) memo1 = guiCreateMemo (0.15,0.2,0.7,0.5,"Hello im Robbie, please take the plane and go to the next airport",true,plane_window_main) plane_window_main_button_accept = guiCreateButton(0.52,0.85,0.45,0.1,"Acept",true,plane_window_main) plane_window_main_button_decline = guiCreateButton(0,0.85,0.45,0.1,"Decline",true,plane_window_main) showCursor (true) end addEvent ("planeCreatePlaneGUI",true) addEventHandler ("planeCreatePlaneGUI",getResourceRootElement(getThisResource()),planeCreatePlaneGUI) ----------------------------------------------------------------------------------------------------------------------------- --DESTROY Plane GUI ----------------------------------------------------------------------------------------------------------------------------- function planeDestroyPlaneGUI() destroyElement(plane_window_main) plane_window_main = false showCursor (false) end ----------------------------------------------------------------------------------------------------------------------------- --ON plane WINDOW CLICK ----------------------------------------------------------------------------------------------------------------------------- function planeOnPlaneWindowClick() if source == plane_window_main_button_accept then triggerServerEvent ("planeCreatePlane",getLocalPlayer()) planeDestroyPlaneGUI () elseif source == plane_window_main_button_decline then planeDestroyPlaneGUI () end end addEventHandler("onClientGUIClick",getRootElement(),planeOnPlaneWindowClick) Hope you can help me PS: My changed job is working fine
  11. 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.
  12. 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]
  13. Yes and now I have the problem Bad argument @'addEventHandler' [Expected function at argument 3, got nil]
  14. 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.
  15. 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
  16. 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
×
×
  • Create New...