undefined Posted April 24, 2014 Share Posted April 24, 2014 (edited) Hi guys. Im work on the new mission. But i have a problem. It's say; WARNING: mission/mission_s.lua:3: Bad argument @ 'setCameraTarget' What is the problem? Server-Side Part function mission() setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) setTimer(function() setCameraTarget(source,source) end,5000,1) end addEventHandler("onPlayerLogin", getRootElement(), function() mission(source) end) And how to create all vehicle? vehicle = { [470] = { -2508.3, 741.59998, 34.9, 0, 0, 180},---Patriot--- [470] = { -2508.3, 741.59998, 34.9, 0, 0, 180},---Patriot--- [470] = { -2508.3, 741.59998, 34.9, 0, 0, 180},---Patriot--- [470] = { -2508.3, 741.59998, 34.9, 0, 0, 180},---Patriot--- ---------------------------------------------------------------- [433] = { -2490.8999, 741.4, 35.6, 0, 0, 180},---Barrack--- [433] = { -2486.3999, 741.4, 35.6, 0, 0, 180},---Barrack--- [433] = { -2482.0001, 741.4, 35.6, 0, 0, 180},---Barrack--- [433] = { -2477.8000, 741.4, 35.6, 0, 0, 180},---Barrack--- ---------------------------------------------------------------- [500] = { -2473.3005, 741.2, 35.2, 0, 0, 180},---Mesa--- [500] = { -2468.8999, 741.2, 35.2, 0, 0, 180},---Mesa--- [500] = { -2464.6001, 741.2, 35.2, 0, 0, 180},---Mesa--- [500] = { -2460.3005, 741.2, 35.2, 0, 0, 180},---Mesa--- ---------------------------------------------------------------- [416] = { -2429.6001, 741.2, 34.7, 0, 0, 180},---Ambulance--- [416] = { -2425.1999, 741.2, 34.7, 0, 0, 180},---Ambulance--- [416] = { -2421.0005, 741.2, 34.7, 0, 0, 180},---Ambulance--- ---------------------------------------------------------------- [422] = { -2408, 741.2, 35, 0, 0, 180},---Bobcat--- [422] = { -2412, 741.2, 35, 0, 0, 180},---Bobcat--- [422] = { -2416, 741.2, 35, 0, 0, 180},---Bobcat--- ---------------------------------------------------------------- [540] = { -2405, 725, 35, 0, 0, 0},---Vincent--- [540] = { -2410, 725, 35, 0, 0, 0},---Vincent--- [540] = { -2415, 725, 35, 0, 0, 0},---Vincent--- [540] = { -2420, 725, 35, 0, 0, 0} ---Vincent--- } missionVehicle = createVehicle ( vehicle ) WARNING: mission/mission_s.lua:31: Bad argument @ 'createVehicle' Help pls. Edited April 26, 2014 by Guest Link to comment
myonlake Posted April 24, 2014 Share Posted April 24, 2014 You haven't defined the source for the timer, that is why. function mission( ) if ( not isElement( source ) ) or ( getElementType( source ) ~= "player" ) then return end setCameraMatrix( source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316 ) setTimer( function( source ) setCameraTarget( source, source ) end, 5000, 1, source ) end addEventHandler( "onPlayerLogin", root, mission ) For the second one, you have to loop through the whole table in order to do that. local vehicles = { { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- ---------------------------------------------------------------- { 433, -2490.8999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2486.3999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2482.0001, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2477.8000, 741.4, 35.6, 0, 0, 180 },---Barrack--- ---------------------------------------------------------------- { 500, -2473.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2468.8999, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2464.6001, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2460.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- ---------------------------------------------------------------- { 416, -2429.6001, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2425.1999, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2421.0005, 741.2, 34.7, 0, 0, 180 },---Ambulance--- ---------------------------------------------------------------- { 422, -2408, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2412, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2416, 741.2, 35, 0, 0, 180 },---Bobcat--- ---------------------------------------------------------------- { 540, -2405, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2410, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2415, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2420, 725, 35, 0, 0, 0 } ---Vincent--- } for i,data in pairs( vehicles ) do local vehicle = createVehicle( unpack( data ) ) vehicles[ i ].vehicle = vehicle end Link to comment
undefined Posted April 24, 2014 Author Share Posted April 24, 2014 (edited) Thank you, it's work perfectly but...? How to respawn vehicle toggleVehicleRespawn( vehicles, true ) setVehicleRespawnDelay( vehicles, 10000 ) setVehicleIdleRespawnDelay( vehicles, 60000 ) -------------------------------------- Im solved it... How to fix it? function mission ( thePlayer, seat ) if ( thePlayer ) and ( seat == 0 ) and ( source == vehicle ) then if not getElementData(source,"girdi") and not getAccountData(getPlayerAccount(source),"task") then local pveh = getPlayerOccupiedVehicle ( thePlayer ) setMarkerTarget(checkpoint,213.78820800781, 1903.7325439453, 16) a51blip = createBlip(213.78820800781, 1903.7325439453, 14.765625,31,2,255,0,0,255,1234,1000,source) setVehicleLocked ( pveh, true ) setElementData(source,"girdi",true) end end end addEventHandler ("onVehicleEnter", vehicle, mission)--This line is 120 WARNING: mission/mission_s.lua:120: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nill] Edited April 24, 2014 by Guest Link to comment
myonlake Posted April 24, 2014 Share Posted April 24, 2014 (edited) Place it after the point where it creates the vehicle and use the vehicle element as the first argument to those three. Here is a cool thing to make stuff easier for you. local vehicles = { { -- Mission 1 [ 470 ] = { -- Patriot { -2508.3, 741.59998, 34.9, 0, 0, 180 }, { -2508.3, 741.59998, 34.9, 0, 0, 180 }, { -2508.3, 741.59998, 34.9, 0, 0, 180 }, { -2508.3, 741.59998, 34.9, 0, 0, 180 } }, barracks = { { -2490.8999, 741.4, 35.6, 0, 0, 180 }, { -2486.3999, 741.4, 35.6, 0, 0, 180 }, { -2482.0001, 741.4, 35.6, 0, 0, 180 }, { -2477.8000, 741.4, 35.6, 0, 0, 180 } }, mesa = { { -2473.3005, 741.2, 35.2, 0, 0, 180 }, { -2468.8999, 741.2, 35.2, 0, 0, 180 }, { -2464.6001, 741.2, 35.2, 0, 0, 180 }, { -2460.3005, 741.2, 35.2, 0, 0, 180 } }, ambulance = { { -2429.6001, 741.2, 34.7, 0, 0, 180 }, { -2425.1999, 741.2, 34.7, 0, 0, 180 }, { -2421.0005, 741.2, 34.7, 0, 0, 180 } }, bobcat = { { -2408, 741.2, 35, 0, 0, 180 }, { -2412, 741.2, 35, 0, 0, 180 }, { -2416, 741.2, 35, 0, 0, 180 } }, vincent = { { -2405, 725, 35, 0, 0, 0 }, { -2410, 725, 35, 0, 0, 0 }, { -2415, 725, 35, 0, 0, 0 }, { -2420, 725, 35, 0, 0, 0 } } } } function loadMissionVehicles( missionID, vehicleName ) local missionID = missionID or 1 if ( not vehicles[ missionID ] ) then return end local function createMissionVehicle( vehicleID, vehicleName, vehicleData ) local vehicleName = tostring( vehicleName ) local vehicleModel = tonumber( vehicleName ) or getVehicleModelFromName( vehicleName ) if ( ( not tonumber( vehicleName ) ) and ( not vehicleModel ) ) or ( type( vehicleData ) ~= "table" ) then return end local vehicle = createVehicle( vehicleModel, unpack( vehicleData ) ) if ( vehicle ) then toggleVehicleRespawn( vehicle, true ) setVehicleRespawnDelay( vehicle, 10000 ) setVehicleIdleRespawnDelay( vehicle, 60000 ) setElementData( vehicle, "missions:vehicles.id", vehicleID, true ) setElementData( vehicle, "missions:vehicles.mission_id", missionID, true ) vehicles[ missionID ][ tonumber( vehicleName ) or vehicleName ][ vehicleID ].vehicle = vehicle return vehicle end return false end if ( not vehicleName ) then for vehicleName,theseVehicles in pairs( vehicles[ missionID ] ) do for id,vehicleData in pairs( theseVehicles ) do createMissionVehicle( id, vehicleName, vehicleData ) end end return true else if ( vehicles[ missionID ][ vehicleName ] ) then for id,vehicleData in pairs( vehicles[ missionID ][ vehicleName ] ) do createMissionVehicle( id, vehicleName, vehicleData ) end return true end end return false end if ( loadMissionVehicles( 1 ) ) then for _,models in pairs( vehicles[ 1 ] ) do for _,data in pairs( models ) do if ( isElement( data.vehicle ) ) then print( getVehicleName( data.vehicle ) ) end end end end You basically have a table which contains missions (the first level), then after that you have vehicle models, which you can name as vehicle model ID and name. It creates the vehicles inside those items. But yeah, this is some cool stuff and if you want to use this, go ahead. It is probably better to stick with your own code though, unless you know what the above script does. So, with your code I'd probably do something like the following. local vehicles = { { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- { 470, -2508.3, 741.59998, 34.9, 0, 0, 180 },---Patriot--- ---------------------------------------------------------------- { 433, -2490.8999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2486.3999, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2482.0001, 741.4, 35.6, 0, 0, 180 },---Barrack--- { 433, -2477.8000, 741.4, 35.6, 0, 0, 180 },---Barrack--- ---------------------------------------------------------------- { 500, -2473.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2468.8999, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2464.6001, 741.2, 35.2, 0, 0, 180 },---Mesa--- { 500, -2460.3005, 741.2, 35.2, 0, 0, 180 },---Mesa--- ---------------------------------------------------------------- { 416, -2429.6001, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2425.1999, 741.2, 34.7, 0, 0, 180 },---Ambulance--- { 416, -2421.0005, 741.2, 34.7, 0, 0, 180 },---Ambulance--- ---------------------------------------------------------------- { 422, -2408, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2412, 741.2, 35, 0, 0, 180 },---Bobcat--- { 422, -2416, 741.2, 35, 0, 0, 180 },---Bobcat--- ---------------------------------------------------------------- { 540, -2405, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2410, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2415, 725, 35, 0, 0, 0 },---Vincent--- { 540, -2420, 725, 35, 0, 0, 0 } ---Vincent--- } for i,data in pairs( vehicles ) do local vehicle = createVehicle( unpack( data ) ) if ( vehicle ) then toggleVehicleRespawn( vehicle, true ) setVehicleRespawnDelay( vehicle, 10000 ) setVehicleIdleRespawnDelay( vehicle, 60000 ) setElementData( vehicle, "missions:vehicles.id", i, true ) addEventHandler( "onVehicleEnter", vehicle, mission ) vehicles[ i ].vehicle = vehicle else outputDebugString( "Could not create vehicle ID " .. i .. ". Continuing...", 2 ) end end Edited April 24, 2014 by Guest Link to comment
myonlake Posted April 24, 2014 Share Posted April 24, 2014 How to fix it? function mission ( thePlayer, seat ) if ( thePlayer ) and ( seat == 0 ) and ( source == vehicle ) then if not getElementData(source,"girdi") and not getAccountData(getPlayerAccount(source),"task") then local pveh = getPlayerOccupiedVehicle ( thePlayer ) setMarkerTarget(checkpoint,213.78820800781, 1903.7325439453, 16) a51blip = createBlip(213.78820800781, 1903.7325439453, 14.765625,31,2,255,0,0,255,1234,1000,source) setVehicleLocked ( pveh, true ) setElementData(source,"girdi",true) end end end addEventHandler ("onVehicleEnter", vehicle, mission)--This line is 120 WARNING: mission/mission_s.lua:120: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nill Put the addEventHandler after the rest of the code inside the for-loop (like shown in my code, pretty much). Link to comment
undefined Posted April 24, 2014 Author Share Posted April 24, 2014 How to fix it? function mission ( thePlayer, seat ) if ( thePlayer ) and ( seat == 0 ) and ( source == vehicle ) then if not getElementData(source,"girdi") and not getAccountData(getPlayerAccount(source),"task") then local pveh = getPlayerOccupiedVehicle ( thePlayer ) setMarkerTarget(checkpoint,213.78820800781, 1903.7325439453, 16) a51blip = createBlip(213.78820800781, 1903.7325439453, 14.765625,31,2,255,0,0,255,1234,1000,source) setVehicleLocked ( pveh, true ) setElementData(source,"girdi",true) end end end addEventHandler ("onVehicleEnter", vehicle, mission)--This line is 120 WARNING: mission/mission_s.lua:120: Bad argument @ 'addEventHandler' [Expected element at argument 2, got nill Put the addEventHandler after the rest of the code inside the for-loop (like shown in my code, pretty much). I don't understand. (Do you speak Turkish?) or can you explain a little more? Link to comment
myonlake Posted April 24, 2014 Share Posted April 24, 2014 Can you show me your code, please (the one where you create the vehicles). Link to comment
undefined Posted April 24, 2014 Author Share Posted April 24, 2014 Ok. Im post the script on pm. 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