-
Posts
822 -
Joined
-
Last visited
-
Days Won
86
Everything posted by The_GTA
-
Hello Fabioxps, what have you coded so far? Can you share it with us?
-
I looked into your script and indeed there is no code to synchronize the wheels across game clients. This means that your script was created to display custom wheels only on your local client, not the whole game server. I am really sorry but this is fact. In order to add wheel synchronization you have to perform big changes to the script. For starters you have to share the donation information across all game clients and with that the wheel picks of said donators. Then you can use the "loadWheel" function; for example it was used in line 257, file donator_c.Lua loadWheel(wheels[wheelManager.id][2],wheels[wheelManager.id][3],wheels[wheelManager.id][4]) The functions that you are going to need are the MTA event functions, like triggerServerEvent, triggerClientEvent, addEvent, addEventHandler, etc.
-
Hello \\Virus//, I tried looking into your resource but the resource contains too many Lua files and that is making it too difficult. Are you sure that the issue is contained within that resource even? Have you tried contacting the author of the resource to check for this issue? Maybe this issue is supposed to be by-design?
-
Hello SoManyTears did you know that the clientside version of getPlayerWantedLevel does just return the wanted level of you, not other players? Think of every game client to be an isolated box that just returns data from the local game, if not otherwise requested through client-server interaction. What you have to do to fix this is transfer the wanted level of each player on-change to every other player. You can either monitor for wanted level change on the client and then send a server-event or monitor on the server using a timer + for all players loop. You must make sure that you only send the wanted level on a real change because you would otherwise kill the bandwidth of your server Hopefully this helps!
-
Hello Bleff, do you have a resource called "tents"? This resource is required by your script and it is not running. Could you see if it exists and start it?
-
Hello Rolplay, I see that other people attempted to help by posting their own solutions to light indicators. While it is quite interesting, let's continue with the mentioned points: for this point you have to create a server-side Lua script! open up that meta.xml file and add the following line inside the <meta> node: <script src="server.Lua" type="server" /> Then you have to create a server.Lua file in the resource. If you want to synchronize data between the server and game client you have to use MTA events. The necessary functions for that are addEvent, addEventHandler, triggerServerEvent and triggerClientEvent. In the game client we have four actions: turning on the left/right indicator, turning off the left/right indicator. Thus we want to create events that represent those actions: onVehicleTurnOnIndicator, onVehicleTurnOffIndicator, onClientVehicleTurnOnIndicator, onClientVehicleTurnOffIndicator. Then we have to use triggerServerEvent with the mentioned event names as first argument to tell the server that the vehicle indicator light should turn on. Then the server can tell all players about the event using the onClient eventname. here we require more book-keeping than previously: for every vehicle we should store the parameters left indicator on, right indicator on, left indicator start time, right indicator start time, left indicator shader, right indicator shader (shaders only on the clientside). Thus we need to create a table called "vehicle_indicator_lights" on both the server-side and the client-side. Using the events we created in point 1 we write data directly into the table instead of global variables. Hopefully you can follow my points. Feel free to ask questions. If you don't get them done by the weekend I will help you out with the synchronization bit I am not available all the time due to work and social life. But if I am away from the forums it means that I will return to your issue as soon as possible! So don't let yourself get confused.
-
This is not that hard. If the player was already inside of the rectangle then you can remember his last position inside it and just reset him back to that position, like... local last_valid_player_pos = {}; local shape; -- the colshape. setTimer( function() for m,n in ipairs(getElementsByType("player")) do if (isElementWithinColShape(n, shape)) then last_valid_player_pos[n] = { getElementPosition(n) }; else local last_valid_pos = last_valid_player_pos[n]; if (last_valid_pos) then setElementPosition(n, unpack(last_valid_pos)); end end end end, 1000, 0 ); If you want to handle vehicles aswell then you have to extend the script. You also should handle the case if the script is started when the player was never inside the rectangle.
-
Hello matin, this looks like a mathematical problem. What you want to calculate is the line intersection between the player position and a 2D rectangle. But I don't know where exactly the player should be dragged back to. Do you want push the player toward the center of the rectangle? Or do you want to pick the closest distance to the rectangle?
-
No, you just have to replace the 1 within the original script with something more fitting. I don't want to give it away, it is the point of the exercise, it is really easy, but you have to understand how Lua scripting works. Let's say that I did the groundwork already. Hint #1: the variable period is a number that switches between 1 and 0 in 500ms time distances.
-
Then you need to patch the freeroam resource using the hasObjectPermissionTo function across all functions (giveMeWeapon, etc) so that the ACL priviledges are honored.
-
Hello DigDim, did you know that MTA's Lua functions require different arguments on client-side than on server-side despite being shared functions? outputChatBox ("function TagStaffInvisible Chamada", thePlayer) Here you have used "thePlayer" as second parameter to outputChatBox but that is wrong. You can just remove that parameter because it is executed on the client and on every client there is only one chatbox. Did you also know that you can use the /debugscript command in the MTA client to find out about errors in your script?
-
Hello iwalidza, if you want to have the camera move around in a circle around a point then you can simply use the math.sin and math.cos functions of Lua in combination with MTA's setCameraMatrix function local cam_move_start = getTickCount(); local cam_radius = 50; local cam_move_circle_duration = 15000; local cam_move_angle_start = 0; local cam_movearound_point_x = 0; local cam_movearound_point_y = 0; local cam_movearound_point_z = 0; local cam_height_offset = 20; local function get_camera_point_circular() local now = getTickCount(); local passed_time = now - cam_move_start; local progress_circle = passed_time / cam_move_circle_duration; local cam_current_angle = math.rad(cam_move_angle_start + progress_circle * 360); local cam_pos_x = cam_movearound_point_x + cam_radius * math.cos(cam_current_angle); local cam_pos_y = cam_movearound_point_y + cam_radius * math.sin(cam_current_angle); return cam_pos_x, cam_pos_y, cam_pos_z + cam_height_offset; end addEventHandler("onClientPreRender", root, function() local cam_pos_x, cam_pos_y, cam_pos_z = get_camera_point_circular(); setCameraMatrix(cam_pos_x, cam_pos_y, cam_pos_z, cam_movearound_point_x, cam_movearound_point_y, cam_movearound_point_z); end ); (code has not been tested) The math.cos and math.sin functions are used to model a circle in math. You should learn about those in your school math classes. Extended knowledge can be gained in University which I highly recommend to attend to! - Martin
-
I am back after sleeping (GMT+1). So let's hook up your functions to a key bind, shall we? Here is the improved sample code: improved shader code: texture Tex0 < string textureState="0,Texture"; >; float4x4 World; float4x4 View; float4x4 Projection; float4x4 WorldViewProjection; float Time; float intensity = 0; sampler Sampler0 = sampler_state { Texture = (Tex0); }; struct VSInput { float3 Position : POSITION; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct VSOutput { PSInput psInput; float4 Position : POSITION; }; VSOutput PassthroughVS(VSInput input) { VSOutput output; output.psInput.Diffuse = input.Diffuse; output.psInput.TexCoord = input.TexCoord; //-- Transform vertex position (You nearly always have to do something like this) output.Position = mul(float4(input.Position, 1), WorldViewProjection); return output; } float4 IndicatorMultiply(PSInput input) : COLOR0 { float4 texColor = tex2D(Sampler0, input.TexCoord); return texColor * intensity; } technique indicators { pass P0 { VertexShader = compile vs_2_0 PassthroughVS(); PixelShader = compile ps_2_0 IndicatorMultiply(); } }; client-side Lua code: local vehicleTXD = engineLoadTXD("car.txd"); engineImportTXD(vehicleTXD, 400); local vehicleDFF = engineLoadDFF("car.dff", 400); engineReplaceModel(vehicleDFF, 400); local shader_left = dxCreateShader("indicatorshader.fx"); local shader_right = dxCreateShader("indicatorshader.fx"); outputChatBox("Loaded indicator lights shader and car model!"); for m,n in ipairs(getElementsByType("vehicle")) do if (getElementModel(n) == 400) then engineApplyShaderToWorldTexture(shader_right, "p", n); engineApplyShaderToWorldTexture(shader_left, "l", n); end end -- Starting time in milliseconds for the indicators. local indicator_blink_duration_ms = 500; -- time in milliseconds that the indicator should blink. local indicator_left_on = false; -- is the left indicator on? local indicator_left_start; local indicator_right_on = false; local indicator_right_start; local function vehicle_left_down() indicator_left_on = true; indicator_left_start = getTickCount(); end bindKey("vehicle_left", "down", vehicle_left_down) local function vehicle_left_up() dxSetShaderValue(shader_left, "intensity", 0); indicator_left_on = false; end bindKey("vehicle_left", "up", vehicle_left_up) -- TODO: add key binds for the right indicator. addEventHandler("onClientRender", root, function() local now = getTickCount(); if (indicator_left_on) then local passed_time_ms = now - indicator_left_start; local period = 1 - math.floor(( passed_time_ms / indicator_blink_duration_ms ) % 2); -- TODO: write 1 to intensity if the blinker is on, write 0 if the blinker if off. -- the blinker is off if the variable "period" is 0, the blinker is on if it is 1. dxSetShaderValue(shader_left, "intensity", 1); end -- TODO: add the same for the right indicator. end ); -- TODO: make sure the logic is synchronized across clients. -- TODO: make sure that each vehicle has its own indicator blinking start time, on/off switch, shader; right now each vehicle shares the same indicator logic. I did some non-trivial improvement on the shader code so that it reads from the GTA:SA texture instead of a fixed color. Seeing that you have some trouble coding in Lua I have helped you out again. The Lua code is not done yet. There are several exercises left for you: how do you implement blinking to the left indicator? (easy) how do you implement the indicator light for the right indicators? (easy) how to synchronize the indicator lights across multiple game clients? (medium) how to allow indicator lights for each vehicle separately? (hard) Try doing the above exercises to finish your indicator lights script. I think that you should be able to do the first two points. If you have any trouble further down the line then feel free to ask
-
Sure! You can use the dxSetShaderValue function to set a float value "intensity" and define it as global in the HLSL script. Then you can multiply the color with it inside of the "IndicatorMultiply" pixel shader function. In your client.Lua script you set intensity to 0 if the indicator lights are disabled and to 1 if they are enabled. Use the bindKey function with the "vehicle_left" and "vehicle_right" controls in combination with the intensity shader variable to achieve that. I have not investigated which of "p" or "l" is the left or right indicator texture. I would be very thankful if you could investigate and answer this question for us.
-
The script just works if you put the car.dff (copcarla.dff) and car.txd (copcarla.txd) into the resource because "p" and "l" are inside of the car.txd file, like shown in Magic.TXD above. meta.xml <meta> <file src="indicatorshader.fx" type="client" /> <file src="car.dff" type="client" /> <file src="car.txd" type="client" /> <script src="client.Lua" type="client" /> </meta>
-
Does the freeroam resource even check the player ACL for permission? No, it does not. If you use the freeroam GUI then either everyone gets the weapons or nobody. Do you really need the F1 GUI in your server?
-
I have hacked together a little HLSL sample script for you. It is up to you to actually implement indicator light logic to this: indicatorshader.fx texture Tex0; float4x4 World; float4x4 View; float4x4 Projection; float4x4 WorldViewProjection; float Time; sampler Sampler0 = sampler_state { Texture = (Tex0); }; struct VSInput { float3 Position : POSITION; float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Diffuse : COLOR0; float2 TexCoord : TEXCOORD0; }; struct VSOutput { PSInput psInput; float4 Position : POSITION; }; VSOutput PassthroughVS(VSInput input) { VSOutput output; output.psInput.Diffuse = input.Diffuse; output.psInput.TexCoord = input.TexCoord; //-- Transform vertex position (You nearly always have to do something like this) output.Position = mul(float4(input.Position, 1), WorldViewProjection); return output; } float4 IndicatorMultiply(PSInput input) : COLOR0 { return float4(1, 1, 0, 1); } technique indicators { pass P0 { VertexShader = compile vs_2_0 PassthroughVS(); PixelShader = compile ps_2_0 IndicatorMultiply(); } }; client.Lua local vehicleTXD = engineLoadTXD("car.txd"); engineImportTXD(vehicleTXD, 400); local vehicleDFF = engineLoadDFF("car.dff", 400); engineReplaceModel(vehicleDFF, 400); local shader = dxCreateShader("indicatorshader.fx"); outputChatBox("Loaded indicator lights shader and car model!"); for m,n in ipairs(getElementsByType("vehicle")) do if (getElementModel(n) == 400) then engineApplyShaderToWorldTexture(shader, "p", n); engineApplyShaderToWorldTexture(shader, "l", n); end end As you can see the script uses the Landstalker vehicle as an example. Just spawn a Landstalker and start the resource. You should see the indicator lights in yellow color. Take a look at the MTA wiki to find out more about shaders. You can find really cool effects over there!
-
Hello Rolplay, I have checked out the mod with Magic.TXD and the TXD does contain the following indicator textures named "p" and "l": In order to apply special effects to these textures I recommend using the engineApplyShaderToWorldTexture function with textures named "p" and "l". With this function you can multiply the color of the indicator lights to make it brighter or darker depending on your style But you have to know how to code in HLSL to do this. Learning shader languages is really worth it!
-
This is getting pretty shady ? ??? But sorry I cannot recommend any reliable MP3 conversion service that will continue to exist and has a HTTP API.
-
Yes. If you typed /testcmd into the chat you would see that (you did). Looking at string representations of variables is a daily driver for debugging MTA:SA Lua scripts.
-
Good idea! Honestly I would prefer if there was a direct MTA function for checking this, but sometimes we have to create makeshift solutions like this which approximate the issue just right
-
No idea how you got an error message about "account" but here is my attempt at fixing your script: function switchEngine ( playerSource) local theVehicle = getPedOccupiedVehicle ( playerSource ) if theVehicle and getVehicleController ( theVehicle ) == playerSource then local uid = getElementData(theVehicle, "uid") local state = getVehicleEngineState(theVehicle) outputChatBox("Driver", playerSource, 220, 220, 0) setVehicleEngineState(theVehicle,true) elseif not theVehicle then outputChatBox("you are not in car", playerSource, 220, 220, 0) else outputChatBox("Not driver", playerSource, 220, 220, 0) end end addEvent ( "switchEngine", true ) addEventHandler( "switchEngine", root, switchEngine ) function bindTheKeys (playerSource) bindKey ( playerSource, "L", "down", switchEngine ) end addCommandHandler("engine",bindTheKeys) addEventHandler ( "onPlayerJoin", getRootElement(), function() bindTheKeys(source) end) I have fixed the last line because you should not use the same function for event handlers and bind key handlers. Does that fix the underlying issue?
-
Wow, I must have been pretty tired. True, that is the problem OP was talking about But I strongly discourage: slapztea should not use the same function for binding keys and event handling.
-
I think you can use the bone positions of the player to check if his hand is pointing upwards. Does that suit your use case well enough? https://wiki.multitheftauto.com/wiki/GetPedBonePosition You should calculate the direction of the ped weapon arm and see if it reaches a certain angle in comparison to the ground plane I guess.
-
I cannot see what line of code this refers to, thus I assume this is an entirely different issue. Could you post the related code?