csontih Posted November 21, 2021 Share Posted November 21, 2021 function startJob() outputChatBox("Teszt Munka", 0, 255, 0) local vehMark = createMarker(1617.6962890625, 2368.6525878906, 10.8203125,"cylinder") function vehicleSpawner(hitElement,matchingDimension) if getElementType(hitElement) == "player" then if getPedOccupiedVehicle(hitElement) == false then local x,y,z = getElementPosition(hitElement) local veh = createVehicle(578, 255, 255, 255) warpPedIntoVehicle(hitElement,veh) end end end addEventHandler("onMarkerHit",vehMark,vehicleSpawner) When i go into the Marker, nothing happens, can someone help? Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 2 hours ago, csontih said: When i go into the Marker, nothing happens, can someone help? Hello csontih, have you tried looking into your scripting debug console? You can open it up by logging in as admin into your MTA server and executing /debugscript 3 Your startJob function is missing an end tag. Try placing one after the call to oututChatBox, like... function startJob() outputChatBox("Teszt Munka", root, 0, 255, 0) end Your call to outputChatBox is missing the visibleTo parameter. I "fixed" it in the above script. Link to comment
csontih Posted November 21, 2021 Author Share Posted November 21, 2021 Still not working.. Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 (edited) 2 minutes ago, csontih said: Still not working.. What is the debug console output? Could you please either execute the "/debugscript 3" command or look for the debug script log file inside of your MTA server folder? Is your code running serverside or clientside? Please put the contents of your meta.xml file. Edited November 21, 2021 by The_GTA Link to comment
csontih Posted November 21, 2021 Author Share Posted November 21, 2021 <meta> <script src="sourceC.lua" type="client" cache="false" /> <script src="sourceS.lua" type="server" /> <file src="Roboto.ttf" /> </meta> The debugscript 3 only shows INFO: Save peds Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 The code you posted does originate from sourceS.lua? What exactly should your code do? Provide a brief description of what it should do and the steps that you are doing to test it. Link to comment
csontih Posted November 21, 2021 Author Share Posted November 21, 2021 - The code i posted is sourceC.lua - The function would be that: When i go into the blue marker, a vehicle spawns. (but when i go into the marker right now, nothing happens.. That is the problem) Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 (edited) 2 minutes ago, csontih said: - The code i posted is sourceC.lua The code you posted is supposed to go into sourceS.lua because it does use server-side functions and events (warpPedIntoVehicle and onMarkerHit). Since you are executing warpPedIntoVehicle on players and players are synchronized-with-the-server elements, this function usage is designated for server-side only. Edited November 21, 2021 by The_GTA Link to comment
csontih Posted November 21, 2021 Author Share Posted November 21, 2021 Now it's working, but puts me and the car in the middle of the nothing :,D And i want to do that the marker only shows when i'm in the job. Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 22 minutes ago, csontih said: And i want to do that the marker only shows when i'm in the job. What kind of job? Explain the type and the background behind it. Link to comment
csontih Posted November 21, 2021 Author Share Posted November 21, 2021 It's a container delivery job, i want the marker to spawn, when i start the job. function startJob() outputChatBox("You started the job!", 255, 255, 255) destroyElement(pickupMarker) pickupMarker = createMarker(pickupPos[1], pickupPos[2], pickupPos[3] - 3.7, "cylinder", 4, 255, 162, 0, 200) destroyElement(pickupBlip) pickupBlip = createBlip(pickupPos[1], pickupPos[2], pickupPos[3] - 3.7, 0, 2, 255, 162, 0) Roboto = dxCreateFont("Roboto.ttf", 12) addEventHandler("onClientRender", root, renderMarkerInfo) addEventHandler("onClientMarkerHit", root, markerHandler) How could i do that in SourceS? Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 2 minutes ago, csontih said: How could i do that in SourceS? You have not yet defined the classification of said job. How should the server and client know that a player has the job? You have got two options: use ACL along with internal MTA server accounts use a custom Lua table based job registry After doing the classification, you can spawn markers according to job synchronization data between server and client. Link to comment
csontih Posted November 21, 2021 Author Share Posted November 21, 2021 use a custom Lua table based job registry <- <- <- <- I want to use a custom Lua table based job registry. Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 (edited) -- SERVER local job_registry = {} local function _get_player_jobinfo(player) local info = job_registry[player]; if (info) then return info; end; info = {}; info.current_job = false; job_registry[player] = info; return info; end addEventHandler("onPlayerQuit", root, function() job_registry[source] = nil; end ); function setPlayerJob(player, jobname) local jobinfo = _get_player_jobinfo(player); if (jobinfo.current_job == jobname) then return; end jobinfo.current_job = jobname; outputDebugString("* Set job: " .. getPlayerName(player) .. " -> " .. tostring(jobname)); triggerClientEvent(player, "onClientPlayerSetJob", player, jobname); end -- CLIENT local current_job = false; local pickupMarker = false; local pickupBlip = false; addEvent("onClientPlayerSetJob", true); addEventHandler("onClientPlayerSetJob", root, function(jobname) if not (source == localPlayer) then return; end; if (jobname) then outputChatBox("* Job changed to " .. jobname .. "!"); else outputChatBox("* You are now job-less."); end if (current_job) then if (pickupMarker) then destroyElement(pickupMarker); pickupMarker = false; end if (pickupBlip) then destroyElement(pickupBlip); pickupBlip = false; end end current_job = jobname; if (jobname == "container delivery") then pickupMarker = createMarker( --[[ TODO ]] ); pickupBlip = createBlip( --[[ TODO ]] ); addEventHandler("onClientMarkerHit", pickupMarker, function(hitElement) if not (hitElement == localPlayer) then return; end; -- TODO: do some jobby stuff, synchronize with the server using events. end ); end end ); Hope this helps! Use it as general idea and extend the script. EDIT: fixed a bug in _get_player_jobinfo (21.11.2021 13:14 GMT+1) Edited November 21, 2021 by The_GTA Link to comment
The_GTA Posted November 21, 2021 Share Posted November 21, 2021 Just now, csontih said: Thank you! You're welcome! 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