-
Posts
822 -
Joined
-
Last visited
-
Days Won
86
Everything posted by The_GTA
-
Hello NewMemberScript and welcome to our MTA scripting forums, could you please format your Lua code properly using the "<>" button in the richtext editor? Also please post in English because I cannot really understand your problem...
-
There is no "error" in your script. But could there be any other resource that forces "vehicle_name" to be shown?
-
Hint: you can calculate 1/2 plus the half of cosinus of a time-fraction multiplied by 2PI to get a wave-function between 0 and 1; by setting this value to the intensity shader variable you will get a "smooth" animation.
-
Hint: we need to move the code from the key "up" handler into the key "down" handler somehow.
-
Did you use the code template that I posted for the left indicator lights (onClientRender)? And then modified it like you did before to include the for-pairs loop? Because you did some changes to it regarding vehicle seats and stuff that are buggy.
-
You have to remove lines 3 and 6 because they don't belong here, but this seat-checking logic does belong into the bind key handler. Idea: you should only trigger the onVehicleTurn(...) events if the localPlayer is the driver of his vehicle. Well, you have to delete it, of course. You should replace that portion with the getVehicleIndicatorLights function as well as that global table as well as that onClientElementDestroy handler. You have to fill in the blanks of course. Take a look at the top of the script. You should see the code that creates the shaders. Use that code but put the shaders into the table instead (fieldsnames: shader_left, shader_right).
-
You need to use addEventHandler using the onClientGUIClick event to know when somebody presses any of the buttons. Assuming that you have read the tutorial I have posted, you then require a server-side account system. You can use the MTA provided one. Inside of the onClientGUIClick event handler you should send data to the server using the triggerServerEvent function. Let's call this new server event "onRequestPlayerLogin". Inside of said event handler you can use the "client" global variable with two event parameters "username" and "password" using the logIn function to perform the logging in. You should do it very simiilarly for the registration of users. Just that you use the addAccount function instead.
-
Alright. So let's recall what I said last time: We should start off with changing the client-side only. Here is an idea: local vehicle_indicator_lights = {}; local function getVehicleIndicatorLights(vehicle) if (vehicle_indicator_lights[vehicle]) then return vehicle_indicator_lights[vehicle]; end local info = {}; info.indicator_left_on = false; info.indicator_left_start = false; info.indicator_right_on = false; info.indicator.right_start = false; info.vehicle = vehicle; -- TODO: create the left and right shaders and put them into the table. vehicle_indicator_lights[vehicle] = info; return info; end addEventHandler("onClientElementDestroy", root, function() if (getElementType(source) == "vehicle") then -- TODO: destroy the left and right shaders if vehicle_indicator_lights[source] is a table. vehicle_indicator_lights[source] = nil; end end ); addEventHandler("onClientRender", root, function() for _,info in pairs(vehicle_indicator_lights) do local vehicle = info.vehicle; -- TODO: update the left and right vehicle indicator light shaders. end end end ); -- TODO: update the remainder of the code to use the getVehicleIndicatorLights function: our onClient(...) events use the source global variable as vehicle element.
-
You should post the entire code so we can see what you have done. I cannot really tell what is missing otherwise. But have you added the check for left/right indicators in the event handlers, etc? We should first make sure that is working because the other step is much more difficult. Please open a new thread for this topic because it seems unrelated to this.
-
More tanks in server/Добавление танков на сервер
The_GTA replied to Military Guy's topic in Scripting
Hello [M]Province, since this is a scripting forum let's talk about how to create Rhino vehicle. You can use the createVehicle function for that, like... server-side: createVehicle(getVehicleModelFromName("Rhino"), 0, 0, 5) This will create a Tank in the middle of the map. The easiest way to test scripts is to use the runcode resource. Simply log in as admin to your server and start that resource. Then type /run into the chatbox to test Lua code! -
Hello Resulcan, welcome to our MTA scripting community Did you know about the MTA wiki? There is an article specifically about scripting the GUI. https://wiki.multitheftauto.com/wiki/Introduction_to_Scripting_the_GUI Could you please try doing that tutorial? If you have any questions then feel free to post them here!
-
It is always a good idea to compact your code as much as possible. But it does not matter if you use two onClientRender event handlers in this case
-
Very good job! That is exactly the code that we need. You actually understood what I said a 100% So the missing code on the clientside is just this: addEventHandler("onClientRender", root, function() local now = getTickCount(); if (indicator_right_on) then local passed_time_ms = now - indicator_right_start; local period = 1 - math.floor(( passed_time_ms / indicator_blink_duration_ms ) % 2); dxSetShaderValue(shader_right, "intensity", period); end -- TODO: add the same for the left indicator. end ); This is code that was adjusted for the right blinker because you seem to have written logic for that one. By the way, I recommend you to pass the indicator side as first argument to the onClientVehicleTurnOn/OffIndicator event, like this... local function vehicle_right_down() triggerServerEvent("onVehicleTurnOnIndicator", root, "right") end bindKey("mouse2", "down", vehicle_right_down) local function vehicle_right_up() triggerServerEvent("onVehicleTurnOffIndicator", root, "right") end bindKey("mouse2", "up", vehicle_right_up) because then we can use the same event for both the left and right hand side vehicle indicator lights. Good job so far! I tested the script and it works fine. Now try adding support for the left side indicator aswell. To check if the event was triggered for the right indicator, do... if (right_indicator == "right") then and use "left" for the other side.
-
You're welcome!
-
Hello FIY9AL, I think this is a working function, cool! What you could improve though is setting the internal fadeIn function to be a local function, like this: local function fadeIn() fadeCamera(player, true, fadeinTime, 0, 0, 0) end Then the function does not leak to the global namespace. If we were to discuss the user friendliness, I could argue that you'd reorder function arguments so that player is the first argument and then default the waitTime and fadeinTime argument to be the same as fadeoutTime (of course multiply waitTime by 1000 to get ms time). This is because then you could simply write: eyeBlink(player, 0.5)
-
What is now [= the code you created in the quoted post above] inside of the client event handlers of onClientVehicleTurnOn/OffIndicator should go back into the onClientRender like we had when we finished the first two steps. The reason is: you must update the shader each game frame which is executed by onClientRender. I never said that you should copy the code out of the onClientRender event but the key handlers (the code inside of bindKey( a, b, function() CODE end ) ). The idea is that you enable the shader by execution of the events. When you set the variable "indicator_right_on" to true and set the start time of the right indicator then you enabled the shader, in the script that we had after the first two points. Then to disable the shader you simply set indicator_right_on to false. So I am going to repeat myself here... but:
-
Looks like an orthographic projection from the top of the GTA:SA world down into the center, instead of the typical frustum-based perspective projection. Unfortunately there is no API inside of MTA to change the camera projection mode. Maybe you could hack it using shaders?
-
Hey \\Virus//, sure come to this forum with a new topic and I will answer all of your questions. Glad to hear that you are using Visual Studio Code. I have tried it once and it is a nice editor. But since it has a MTA SA Lua Code extension, that is even greater than my personal pick which is SciTE! Feel free to tell us about your experience with that editor
-
Haha, no no! That is not what you should do Let me explain. Inside the client events you should do what you previously did inside of the vehicle_left, vehicle_right key handlers! This is how your vehicle indicator scripts is executed on every game client on the server if one of them steers the vehicle left or right. Then you have to use triggerServerEvent inside of the vehicle_left and vehicle_right key handlers to send either onVehicleTurnOnIndicator or onVehicleTurnOffIndicator events, depending on if the key is pressed down or not. Imagine it like this: So try moving around the code on the client-side. What is now inside the key handlers should be put into the onClientVehicleTurnOn/OffIndicator event handlers. Then add new code into the bind key handlers to call the server events.
-
You really seem to do baby steps, don't you? ? I hope you do learn Lua this way, but I did a tiny mistake: remove the first argument to triggerClientEvent and set the (now) second argument to (in your case) vehicle. Honestly, I just try to play along with your code, even if you invent things! I helped you by putting the indicator type into the triggerClientEvent. addEvent("onVehicleTurnOnIndicator", true); addEventHandler("onVehicleTurnOnIndicator", root, function(rightindicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerClientEvent ( "onClientVehicleTurnOnIndicator", vehicle, rightindicator) end end ); addEvent("onVehicleTurnOffIndicator", true); addEventHandler("onVehicleTurnOffIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerClientEvent ( "onClientVehicleTurnOffIndicator", vehicle, right_indicator) end end ); So this is the server-side portion of the script. Look at my advice again and try looking into the triggerServerEvent function for the client-side. I am going to sleep now and will most likely be back tomorrow evening.
-
I have not looked into the script much but you have to know who is eligible for the special wheels and then store that in a table on the server. Then also store what wheels they picked. I mentioned the event functions before. It really is not easy to get into, especially since that script is so huge and honestly not very well documented. I don't think that the difficulty is in the Lua language, but rather the questionable design of the code that you are dealing with.
-
Np, here is an idea: local row = math.floor(i / 6); local column = ( i % 6 ); Then you can multiply row with pixel height, column with pixel width of rectangle.
-
You actually just need this on the clientside: addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(left_indicator) end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(left_indicator) end ); On the server-side you have to replace playerSource with client, replace localPlayer with client. Then you also used the wrong client event in the second event handler.
-
You create the first two on the clientside, the second two on the server-side. For example like this: client-side: addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(indicator_side) -- source is the vehicle for which we turn on the indicator lights end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(indicator_side) -- similar to above. end ); The serverside should be made similar, but for the onVehicle version of events. For the onClient ones, yes.
-
No problem! I hope that you get it sorted out. Hopefully you were not scammed by some guy who promised you a feature. If you want scripting advice for implementing it yourself feel free to ask in this thread. Then I will guide you.