Jump to content

The_GTA

Helpers
  • Posts

    822
  • Joined

  • Last visited

  • Days Won

    86

Everything posted by The_GTA

  1. Please take a look at the following MTA source code: https://github.com/multitheftauto/mtasa-blue/blob/e11685cab4beb7958ab202261f9c9d9b4ce71e58/Server/mods/deathmatch/logic/CVehicleManager.cpp#L14 You see that the max passengers have to be known to the server so that it can synchronize the player entering and leaving vehicles. Since the server does not have access to the game files the MTA team has implemented it as a static table. If you were to change the seat count on the client-side then you still could not enter the vehicle because the server would never know about the real seat count. Here be dragons if you change the model to a vehicle with less seats than what the server expects. It could severely cripple the game experience of your server users. Please select a vehicle model with the same seat count instead.
  2. I personally don't think this is a very good idea because the game does cache the amount of passengers in various game structures (model info, vehicle struct, seat info structures). This could cause game stability issues, like what should happen if you replace a vehicle with four seats where two players sit on seat 3 and 4? Are you asking just hypothetically or because you tried?
  3. This is a very strange error. Did you replace the "getRootElement" function? Can you share the entire resource scripts? What about the global "root" variable instead of calling "getRootElement"?
  4. client-side local function open_van_door() setVehicleComponentPosition(source, "bocne_dvere", 0.1, -1.275, 0) end addEvent("onClientVanDoorOpen", true); addEventHandler("onClientVanDoorOpen", root, open_van_door, false); local function close_van_door() setVehicleComponentPosition(source, "bocne_dvere", 0, 0, 0) end addEvent("onClientVanDoorClose", true); addEventHandler("onClientVanDoorClose", root, close_van_door, false); addCommandHandler("dvere", function() local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then return outputChatBox("ERROR: Musíš sedieť vo vozidle!") end triggerServerEvent("onRequestVanDoorOpen", vehicle); end) addCommandHandler("dvereclose", function() local vehicle = getPedOccupiedVehicle(localPlayer) if not vehicle then return outputChatBox("ERROR: Musíš sedieť vo vozidle!") end triggerServerEvent("onRequestVarDoorClose", vehicle); end) triggerServerEvent("onPlayerReady", resourceRoot); server-side local vans = {}; local function get_van_info(veh) local existing = vans[veh]; if (existing) then return existing; end; local van = {}; van.vehicle = veh; van.is_door_closed = true; return van; end addEvent("onRequestVanDoorOpen", true); addEventHandler("onRequestVanDoorOpen", root, function() local info = get_van_info(source); if (info.is_door_closed) then triggerClientEvent("onClientVanDoorOpen", source); info.is_door_closed = false; end end ); addEvent("onRequestVanDoorClose", true); addEventHandler("onRequestVanDoorClose", root, function() local info = get_van_info(source); if not (info.is_door_closed) then triggerClientEvent("onClientVanDoorClose", source); info.is_door_closed = true; end end ); addEvent("onPlayerReady", true); addEventHandler("onPlayerReady", resourceRoot, function() -- TODO: open the van doors for the client on all vans that we know about, using a for-loop and triggerClientEvent(client, "onClientVanDoorOpen", ...) end, false ); Implementing the handler for "onPlayerReady" is left for you as an exercise. It is important so that new players that join also see open van doors.
  5. Because there is no MTA event for enabling ghost modes on vehicles you cannot easily disable it by script. What you could do though is disable the right to use functions through ACl.xml. Typically the functions setElementCollidableWith and setElementCollisionsEnabled are used to disable collisions. If you disable these functions for every other resource you could prevent ghost mode activation, the lazy way I spent some time looking around MTA community resources and could find no such PM system that works by "ID". This is because the MTA API does not work with IDs. I am pretty sure that you can easily create such a system yourself. Especially if you are talking about chat bubbles you can use the function getScreenFromWorldPosition to easily find where to display your chat bubble. Hope that I could help!
  6. Is the problem that the resource does just replace the text but not the surrounding plate texture? Then you could take a look at the following thread: WASSIm. did provide a really interesting answer. There are texture of vehicles called "plateback1", "plateback2", "plateback3" which should be replaced using shaders.
  7. If it is not inside of your script it looks like a custom event inside of a map system resource. I don't think it is inside any of the standard MTA server resource. What other resources do you have running on your server? Do any of the resources look like map resources with custom scripts?
  8. I have extended and fixed your script according to my points I posted above. There are comments in the script to help you explain. Please take your time to read the comments and learn from the code because it is well made and you should always follow these guidelines when creating server system scripts (like account systems): -- Warp points for jails. local warps = { { 2,2577.3100585938, -1329.7434082031, 1058.2553710938 }, { 2,2573.6740722656, -1353.0935058594, 1058.2553710938 }, { 2,2581.5959472656, -1343.3308105469, 1054.0562744141 } } -- Do the actual jailing. local function onPlayerWantedLevelChange(source, level) local acc = getPlayerAccount(source); if (isGuestAccount(acc)) then return; end; local rnd = math.random( 1, #warps ) if ( level == 1 ) then setPedWeaponSlot ( source, 0 ) fadeCamera(source,false, 1.0) setTimer(fadeCamera, 1000, 1,source,true) setTimer ( setElementInterior, 1000, 1, source, warps[rnd][1], warps[rnd][2], warps[rnd][3], warps[rnd][4], warps[rnd][5], warps[rnd][6], warps[rnd][7], warps[rnd][8] ) triggerClientEvent(source, "jailTime1", source) setTimer( function(freeman) if isElement(freeman) then fadeCamera(freeman,false, 1.0) setTimer(fadeCamera, 1000, 1,freeman,true) setTimer (setElementPosition, 1000, 1, freeman, 1803.2666015625, -1575.6591796875, 13.408905029297 ) setElementInterior ( freeman, 0 ) updatePlayerWantedLevel ( freeman, 0 ) end end,1000*20,1,source) end end -- Use this function always if you want to set wanted level. function updatePlayerWantedLevel(player, level) -- Uncomment this if you want to jail only players that have a change in wanted level. --if (getPlayerWantedLevel(player) == level) then return true; end; local success = setPlayerWantedLevel(player, level); if not (success) then return false; end; onPlayerWantedLevelChange(player, level); return true; end -- Save jail system variables. local function savePlayerAccount(player, account) local wantedLevel = getPlayerWantedLevel (player) setAccountData(account, "wlevel", wantedLevel) -- Uncomment this if you want to clean up wanted level on save. --setPlayerWantedLevel(player, 0) end -- Set wanted level to player that we remember in his account. local function loadPlayerAccount(player, acc) local wantedLevel = getAccountData(acc, "wlevel") setTimer (updatePlayerWantedLevel,500,1,player,wantedLevel) end -- Remember jail system variables if player logs out. local function onPlayerLogout(account) savePlayerAccount(source, account); end addEventHandler("onPlayerLogout", root, onPlayerLogout); -- Remember jail system variables if player leaves the server. local function onQuit() local acc = getPlayerAccount(source) if not isGuestAccount(acc) then savePlayerAccount(source, acc); end end addEventHandler("onPlayerQuit", getRootElement(), onQuit) -- Jail players that log in. local function onLogin(_, acc) local acc = getPlayerAccount(source) loadPlayerAccount(source, acc); end addEventHandler("onPlayerLogin", getRootElement(), onLogin) -- Remember the jail system variables if resource stops. local function onResourceStop() for m,n in ipairs(getElementsByType("player")) do local acc = getPlayerAccount(n); if not (isGuestAccount(acc)) then savePlayerAccount(n, acc); end end end addEventHandler("onResourceStop", resourceRoot, onResourceStop, false); -- Jail all players that are on server when resource starts up. local function onResourceStart() for m,n in ipairs(getElementsByType("player")) do local acc = getPlayerAccount(n); if not (isGuestAccount(acc)) then loadPlayerAccount(n, acc); end end end onResourceStart(); Feel free to ask any questions about it
  9. So you have mentioned that you have maybe used the wrong event here. I think you have assumed partially right because you want to set wanted levels using account data but this data is only available after login. So if you set wanted level data after player logged in he will never be teleported. What you are missing is another event handler when you set the wanted level. After you set the wanted level you must execute the same code you posted above. I recommend that you turn the event handler into a separate named local function and use it in both cases If you share your complete code we could assist you in implementing that.
  10. Glad to hear that you got it solved. I was sleeping at that time so I could not respond quickly enough.
  11. Hello pbradjan1994, did you know that a period (".") cannot be put into name of settings? It says so in the documentation: https://wiki.multitheftauto.com/wiki/Get I recommend changing the period for a dash ("-") so that the error could get fixed Remember to also change this for any call of set aswell. Since I do not have access to all relevant portions of your script I cannot know what further errors would be inside. Feel free to ask more questions with further details.
  12. Hello djharbi2, did you know that you can use shaders to replace ingame textures? With shaders you can write text into a DX render-target and then attach it to a shader that would replace your license plate texture! With this technique you can create a custom license plate GUI like in your picture above. Here are some hints to lead you in the right direction: dxCreateRenderTarget - create the dynamic texture where you can draw text on dxDrawText - draw your own text onto the license plate dxDrawRectangle - you can fill that blue color on the left side with this function dxCreateShader - you have to create a shader that would replace the license plate texture of your vehicle dxSetShaderValue - function to attach your render-target with custom text to the license plate shader engineApplyShaderToWorldTexture - to attach your shader to the vehicle texture Have you already looked at the resource community for sample scripts? It is always a good idea to learn from already existing code customvehplate - seems to do what you want; you just have to adjust it to fit your style + extend for GUI! Feel free to post any questions. - Martin
  13. Hello SoManyTears, I was unable to find any substantial issue in your script so I tried it on my local server and it worked. Here are my questions: have you set a server-side wanted level for your player element? if you set a client-side wanted level then this server-side script will not trigger have you logged in while having a wanted level of 1? If you have logged in prior to that then you will not be teleported The teleport is weird tho. Maybe because I don't have the entire resource. I got teleported somewhere into the air with no solid ground underneath my feet You can use the following runcode command to help you debug this script: run setPlayerWantedLevel(getPlayerFromName("SoManyTears"), 1)
  14. Hello ivan8065, yes we can help you add server-synchronization for your sliding doors script. Could you please post your client-side script so that we can work on it?
  15. Good points, majqq! Let me comment on your details. Indeed the integer loop is 100% equivalent to ipairs. Under the hood ipairs calls a function for each iteration to receive the next item while the integer loop is pure Lua bytecode. One could ask why did the Lua developer not optimize ipairs in the compiler to be a simple integer loop? Clearly he did not care about performance. So I argument that Lua was not designed to be performant. But don't get me wrong: due to per-frame event handlers you clearly need good performance or else you could destroy somebody's gameplay experience with bad scripts! I think it has been a good idea to replace the colshape with the getElementsWithinRange function. Since OP did not ask about optimizations I was sticking to the script for simplicity's sake. Thank you for pointing it out because OP seems to like your improvement.
  16. Yes, I see no problem in the code.
  17. Hello enzoDs, you seem to know about the functions toJSON and fromJSON, don't you? If you have any problems with using these functions then please explain and we will help you
  18. Let me help you a little bit. Please replace your client-side script with this: client-side function setTimeClientSide (timehour,timeminute) setTime(timehour,timeminute) end addEvent( "eventSetTimeOnJoin", true ) addEventHandler( "eventSetTimeOnJoin", localPlayer, setTimeClientSide ) triggerServerEvent("playerIsReady", localPlayer) I have got years of experience in making MTA resources and this client synchronization is a common issue I faced.
  19. addCommandHandler("wv", function(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) for index, value in ipairs(getElementsWithinColShape(colshape, "vehicle")) do if (getElementData(value, "uid") == 0) then setVehicleLocked ( value, true ) outputChatBox("lock", player, 220, 220, 0) break -- only one car. end end end) The line that I added is line 7. If you have a way to get the real "uid" by player then please modify that if-condition.
  20. How do you want to decide which car they player "needs" or wants to close? Does the player have a list of cars that he owns?
  21. I think that Bartje has given you a really good script. Using the recommended script you can create a "remote car key" script where you lock all vehicles that are close to your player. Let me help you by fixing it: addCommandHandler("wv", function(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) for index, value in ipairs(getElementsWithinColShape(colshape, "vehicle")) do setVehicleLocked ( value, true ) outputChatBox("lock", player, 220, 220, 0) end end)
  22. Good solution! Sorry if my reply were a little confusing because I tried to understand the scope of your problem. But if you just want to use the standard game time system then this should work. But you made one tiny mistake: you used the event "onPlayerJoin" for the clientside addEventHandler call, should have been "eventSetTimeOnJoin". clientside script: function setTimeClientSide (timehour,timeminute) setTime(timehour,timeminute) end addEvent( "eventSetTimeOnJoin", true ) addEventHandler( "eventSetTimeOnJoin", localPlayer, setTimeClientSide ) EDIT: there is a race condition in your script if the client has not loaded the Lua files yet but you trigger the eventSetTimeOnJoin anyway. To fix that you have to trigger a server event "onPlayerReady" at the end of your clientside script, then add this event "onPlayerReady" on the server-side + attach the server-side event handler, previously from "onPlayerJoin", you made to that.
  23. Thank you for posting the code. So let me summarize what I understand: no matter what state of the V zoom, you want things to spawn at the same position the problem is that if your camera zooms out the object is closed to the player than what you want you probably want an offset starting from the player and not from the camera position So what about this code? I have changed line 3 from csx, csy, csz to x, y, z + 0.5 ... local x, y, z = getElementPosition(player) local direction = Vector3(ctx - csx, cty - csy, ctz - csz); direction:normalize(); local start_x, start_y, start_z = interpolate_position( x, y, z + 0.5, direction, 10 ); local object = createObject ( 1600, start_x, start_y, start_z)
  24. Could you please show your code? I cannot help you based purely on explanation because your implementation does matter for error detection.
×
×
  • Create New...