Rolplay
-
Posts
41 -
Joined
-
Last visited
Posts posted by Rolplay
-
-
12 hours ago, Dutchman101 said:
For this you will really need an API, information about that can be found in this earlier topic (my reply): https://forum.multitheftauto.com/topic/128283-play-music-from-online-radioyoutube-in-car/
Unfortunately there's no other way. Except for maybe finding a public API (so you don't have to do all that work of setting up your own), i have seen a few suitable ones in the past.. but they all went away over time. So you'll have to search.
I don't really unrestand what should i do. Just copy those 2 php codes to a html file or what?
-
Hi! I want to make a youtube radio to my server. I don't want to use browser, just playSound3D. Does anyone have any experience? I know i have to use API for convert, but i don't really know other languages than lua. Ty for reply.
-
Hi! I want to know, it is possible to calculate horsepower in mta:sa? I want to make a hp based tuning-system, and thats an important part. How can i do it?
-
-
Hi! I use @Ren_712's object-viewer resource for my cars, and i have a problem with using shaders. I want to apply a light shader to the car, which turns on only the vehiclelights128 texture without the lights.
Here is my shader:
#include "mta-helper.fx" float gMultiplier = 0; sampler Sampler0 = sampler_state { Texture = (gTexture0); MinFilter = Linear; MagFilter = Linear; }; struct VSInput { float3 Position : POSITION0; float2 TexCoord : TEXCOORD0; }; struct PSInput { float4 Position : POSITION0; float2 TexCoord : TEXCOORD0; }; PSInput VertexShaderFunction(VSInput VS) { PSInput PS = (PSInput)0; PS.Position = MTACalcScreenPosition ( VS.Position ); PS.TexCoord = VS.TexCoord; return PS; } float4 PixelShaderFunction(PSInput PS) : COLOR0 { float4 color = tex2D(Sampler0, PS.TexCoord); color = color*gMultiplier; return color; } technique tec0 { pass P0 { VertexShader = compile vs_2_0 VertexShaderFunction(); PixelShader = compile ps_2_0 PixelShaderFunction(); } }
And here is my client script, which turn on the light.
local animShads = {} local lights = 0 function updateLights(myElementRT2) if lights == 0 then setVehicleOverrideLights( myElementRT2, 1 ) if animShads[myElementRT2] then destroyElement(animShads[myElementRT2][1]) animShads[myElementRT2] = nil end elseif lights == 1 then local shad = dxCreateShader("shader2.fx") animShads[myElementRT2] = {shad,0} iprint(animShads) engineApplyShaderToWorldTexture( shad, tex_reverse, myElementRT2) end end local last = 0 function updateMultipliers() local cur = getTickCount()-last last = getTickCount() for k,v in pairs(animShads) do --iprint(v[2]) v[2] = v[2] + cur/1000 dxSetShaderValue(v[1],"gMultiplier",v[2]) if v[2] >= 1 then destroyElement(v[1]) setVehicleOverrideLights(k, 2 ) setVehicleHeadLightColor(k,0,0,0) animShads[k] = nil --setVehicleHeadLightColor(veh,0,0,0) end end end addEventHandler("onClientRender",root,updateMultipliers) if myElement then if lights == 0 then lights = 1 elseif lights == 1 then lights = 0 else lights = 0 end local myElementRT = exports.object_preview:getRenderTarget() iprint(myElementRT) updateLights(myElementRT) end end
PS.: I think this is not the script's fault because its work fine with normal cars which spawned on world.
-
Hi+! I want to make diesel smoke from the exhaust but i don't know how. I already made a script which replaces the smoke texture, but that is not perfect , because the game uses the def. Smoke texture for the exhaust and the wheel smoke, so if is change the exhaust smoke to black, the wheel smoke changes too.
-
Hi! I just started to make a hud-system, but i can't resume my system, because i'dont know, how to make this:
I have a stickman png, and i want to make an injury system.I want to make if the player hits a car, jump from high ground etc... the player break their bones, and it's visible on the stickman, and the player can't kick, punch shoot etc.
What functions i need to use? Ty all
-
I think, the car separate is too hard for me, i never heard about tables so its very hard for now
-
5 hours ago, The_GTA said:
I see that it is the same problem many times so let's look at one examplein line 29:
if (info.indicator_left_on == true) then
Do you know about Lua tables? You don't have any "info" variable inside of this function. I think you meant to call the getVehicleIndicatorLights function with the vehicle of the local player as argument and then store the result into a local "info" variable. Try doing that at the top of that function.
Then there are many followup errors because you try to look at invalid variables like "shader_left". You forgot to create those shaders inside of the info table between like 18 and 19. And then you have to use those variable from inside the vehicle indicator light info of any vehicle table.
I recommend you to try using Lua tables! Lua tables are essential for good Lua scripters.
Thank you, i try to make that.
While i was working, i found a bug. The script changing the texture when the indicator turned on, but if it was off, there are a black texture. In small indicators that is indiscernible but in bigger indicators it is very "ugly".
U can see, if the script is'nt running, there is the texture, but if i start the script that going to black.
-
So hi again!
I try to make the separatem but i cant do perfect.
This is the left side:
local indicator_blink_duration_ms = 333; -- time in milliseconds that the indicator should blink. local vehicle_indicator_lights = { engineApplyShaderToWorldTexture(shader_right, "p", n); engineApplyShaderToWorldTexture(shader_left, "l", n); }; 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; vehicle_indicator_lights[vehicle] = info; return info; end local function vehicle_left_down() seat = getPedOccupiedVehicleSeat(localPlayer) if seat then if seat and seat==0 then triggerServerEvent("onVehicleTurnOnIndicator", root, "left") end if (info.indicator_left_on == true) then triggerServerEvent("onVehicleTurnOffIndicator", root, "left") end end end bindKey("mouse1", "down", vehicle_left_down) function destroy() if (getElementType(source) == "vehicle") then if (vehicle_indicator_lights[vehicle] == true) then engineRemoveShaderToWorldTexture(shader_right, "p", n) engineRemoveShaderToWorldTexture(shader_left, "l", n) vehicle_indicator_lights[source] = nil; end end end addEventHandler("onClientElementDestroy", root, destroy ) function left_indicator() local now = getTickCount(); for _,info in pairs(vehicle_indicator_lights) do local vehicle = info.vehicle; if (indicator_left_on) then local passed_time_ms = now - info.indicator_left_start; local period = 1 - math.floor(( passed_time_ms / indicator_blink_duration_ms ) % 2); dxSetShaderValue(shader_left, "intensity", 1); if (period == 0) then dxSetShaderValue(shader_left, "intensity", 0); end end end -- TODO: add the same for the right indicator. end addEventHandler("onClientRender", root, left_indicator) addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(left_indicator) if (left_indicator == "left") then info.indicator_left_on = true; info.indicator_left_start = getTickCount(); end end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(left_indicator) if (left_indicator == "left") then dxSetShaderValue(shader_left, "intensity", 0); info.indicator_left_on = false; end end );
-
16 minutes ago, The_GTA said:
Hint: we need to move the code from the key "up" handler into the key "down" handler somehow.
Thank you, i made it The last part is the separate
+1: can you help me edit the shader, for fade in and fade out effect? Is that possible? I mean the texture appears smooth.
-
I found the bug, i have a line what i made for debug a bug. Without this if i left the car, and dont release the key button, the indicator is working.
seat = getPedOccupiedVehicleSeat(localPlayer) if seat then
So my idea is this: Turn on with mouse click and turn off with click again. Can u give me a function for this?
And now, i try to make the car indicator logic separated
-
EDIT: We tested it again, and its visible, but only visible for other car drivers and passengers.
-
So i tested the client-server communication with my friend, but he dont see the indicator. Only works on client side, why?
-
11 minutes ago, The_GTA said:
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.
I dont really understand what i need to do,so i updated my indicator_left and indicator_right code with this:
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 );
And this is what i got:
function left_indicator() local now = getTickCount(); seat = getPedOccupiedVehicleSeat(localPlayer) for _,info in pairs(vehicle_indicator_lights) do local vehicle = info.vehicle; if seat and seat==0 then if (indicator_left_on) then --functions end else dxSetShaderValue(shader_left, "intensity", 0); end end end
It is good?
And if i add this to my code:
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;
I need to delete this?
local indicator_blink_duration_ms = 333; -- 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;
And what do you mean in this? : -- TODO: create the left and right shaders and put them into the table.
-- TODO: destroy the left and right shaders if vehicle_indicator_lights[source] is a table.
I dont really understand how tables are working
-
2 minutes ago, The_GTA said:
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.
local indicator_blink_duration_ms = 333; -- 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() triggerServerEvent("onVehicleTurnOnIndicator", root, "left") end bindKey("mouse1", "down", vehicle_left_down) local function vehicle_left_up() triggerServerEvent("onVehicleTurnOffIndicator", root, "left") end bindKey("mouse1", "up", vehicle_left_up) function left_indicator() local now = getTickCount(); seat = getPedOccupiedVehicleSeat(localPlayer) if seat and seat==0 then 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); local vehicle = getPedOccupiedVehicle (localPlayer) if vehicle then dxSetShaderValue(shader_left, "intensity", 1); end if (period == 0) then dxSetShaderValue(shader_left, "intensity", 0); end end else dxSetShaderValue(shader_left, "intensity", 0); end -- TODO: add the same for the right indicator. end addEventHandler("onClientRender", root, left_indicator) addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(left_indicator) if (left_indicator == "left") then indicator_left_on = true; indicator_left_start = getTickCount(); end end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(left_indicator) if (left_indicator == "left") then dxSetShaderValue(shader_left, "intensity", 0); indicator_left_on = false; end end );
This is the code of left side.
-
So, the syncing is technically finished, right? I dont know, because i'm waiting my friend to check.
For now, please can you help me in "how to allow indicator lights for each vehicle separately?"
+1
local enabledVehicleMod = {} addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function () for index, value in ipairs (elements) do if tostring(index) ~= tostring(value) then changeVehicleMod (value[1], value[2]) end end for i=1 , 10000 do if not enabledVehicleMod[i] then enabledVehicleMod[i] = 1 end end end) function changeVehicleMod (filename,id) if id and filename then if getVehicleNameFromModel(id) then if fileExists("vehicle/"..filename..".txd") then txd = engineLoadTXD("vehicle/"..filename..".txd", id ) engineImportTXD(txd, id) end if fileExists("vehicle/"..filename..".dff") then dff = engineLoadDFF("vehicle/"..filename..".dff", id ) engineReplaceModel(dff, id) end else outputChatBox("asd") end end end
I have this vecihle import and works perfectly whit all cars, but if i want to import my own car it is not working
Error code: https://imgur.com/ytasGYP
-
6 minutes ago, The_GTA said:
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.
I need to complete my original onclientrender with this, or i need to write an another?
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 );
-
Ohh, i think i understand but not 100% from this
Server:
addEvent("onVehicleTurnOnIndicator", true); addEventHandler("onVehicleTurnOnIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerClientEvent ( "onClientVehicleTurnOnIndicator", vehicle, right_indicator) 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 );
Client(key handler):
local function vehicle_right_down() triggerServerEvent("onVehicleTurnOnIndicator", root,right_indicator) end bindKey("mouse2", "down", vehicle_right_down) local function vehicle_right_up() triggerServerEvent("onVehicleTurnOffIndicator", root,right_indicator) end bindKey("mouse2", "up", vehicle_right_up)
Client(event):
addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(right_indicator) indicator_right_on = true; indicator_right_start = getTickCount(); end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(right_indicator) dxSetShaderValue(shader_right, "intensity", 0); indicator_right_on = false; end );
Buuuuut, it is not working, so i failed again
- 1
-
51 minutes ago, Rolplay said:
Ohh, thank you! I try to understand that.
I copied the server-side from here, and make this on client side:
function right_indicator() local now = getTickCount(); seat = getPedOccupiedVehicleSeat(localPlayer) if (indicator_right_on) then local passed_time_ms =-- local period = -- local vehicle = -- if vehicle then dxSetShaderValue(shader_right, "intensity", 1,vehicle); triggerServerEvent("onVehicleTurnOnIndicator", root,right_indicator) end if (period == 0) then dxSetShaderValue(shader_right, "intensity", 0,vehicle); triggerServerEvent("onVehicleTurnOffIndicator", root,right_indicator) end end end addEventHandler("onClientRender", root, right_indicator) addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(right_indicator) function right_indicator() local now = getTickCount(); seat = getPedOccupiedVehicleSeat(localPlayer) if (indicator_right_on) then local passed_time_ms =-- local period = -- local vehicle = -- if vehicle then dxSetShaderValue(shader_right, "intensity", 1,vehicle); triggerServerEvent("onVehicleTurnOnIndicator", root,right_indicator) end if (period == 0) then dxSetShaderValue(shader_right, "intensity", 0,vehicle); triggerServerEvent("onVehicleTurnOffIndicator", root,right_indicator) end end end );
I found a lot of mistakes, and i recreate, this is my script now:
Server-side of right indicator:
addEvent("onVehicleTurnOnIndicator", true); addEventHandler("onVehicleTurnOnIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerClientEvent ( "onClientVehicleTurnOnIndicator", vehicle, right_indicator) 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 );
Client-side of left indicator event:
addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(right_indicator) local now = getTickCount(); if (indicator_right_on) then local passed_time_ms = ... local period = 1 - ... local vehicle = getPedOccupiedVehicle (localPlayer) if vehicle then dxSetShaderValue(shader_right, "intensity", 1); end end end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if (indicator_right_on) then local passed_time_ms = ... local period = 1 - .... if (period == 0) then dxSetShaderValue(shader_right, "intensity", 0); end end end );
-
Ohh, thank you! I try to understand that.
I copied the server-side from here, and make this on client side:
function right_indicator() local now = getTickCount(); seat = getPedOccupiedVehicleSeat(localPlayer) if (indicator_right_on) then local passed_time_ms =-- local period = -- local vehicle = -- if vehicle then dxSetShaderValue(shader_right, "intensity", 1,vehicle); triggerServerEvent("onVehicleTurnOnIndicator", root,right_indicator) end if (period == 0) then dxSetShaderValue(shader_right, "intensity", 0,vehicle); triggerServerEvent("onVehicleTurnOffIndicator", root,right_indicator) end end end addEventHandler("onClientRender", root, right_indicator) addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(right_indicator) function right_indicator() local now = getTickCount(); seat = getPedOccupiedVehicleSeat(localPlayer) if (indicator_right_on) then local passed_time_ms =-- local period = -- local vehicle = -- if vehicle then dxSetShaderValue(shader_right, "intensity", 1,vehicle); triggerServerEvent("onVehicleTurnOnIndicator", root,right_indicator) end if (period == 0) then dxSetShaderValue(shader_right, "intensity", 0,vehicle); triggerServerEvent("onVehicleTurnOffIndicator", root,right_indicator) end end end );
-
I tryed this, but didn't work.
addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerServerEvent ( "onVehicleTurnOnIndicator", vehicle, right_indicator) end end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerServerEvent ( "onVehicleTurnOffIndicator", vehicle, right_indicator) end end );
GN
-
Like this?
addEvent("onVehicleTurnOnIndicator", true); addEventHandler("onVehicleTurnOnIndicator", root, function(rightindicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerClientEvent ( client, "onClientVehicleTurnOnIndicator", client) end end ); addEvent("onVehicleTurnOffIndicator", true); addEventHandler("onVehicleTurnOffIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (client) if vehicle then triggerClientEvent ( client, "onClientVehicleTurnOffIndicator", client) end end );
-
14 minutes ago, The_GTA said:
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.
My serverside look like this now:
addEvent("onVehicleTurnOnIndicator", true); addEventHandler("onVehicleTurnOnIndicator", root, function(rightindicator) local vehicle = getPedOccupiedVehicle (localPlayer) if vehicle then triggerClientEvent ( playerSource, "onClientVehicleTurnOnIndicator", playerSource) end end ); addEvent("onVehicleTurnOffIndicator", true); addEventHandler("onVehicleTurnOffIndicator", root, function(right_indicator) local vehicle = getPedOccupiedVehicle (localPlayer) if vehicle then triggerClientEvent ( playerSource, "onClientVehicleTurnOnIndicator", playerSource) end end );
Any my client side is like this:
function left_indicator() --right side turn on and turn off function end addEventHandler("onClientRender", root, left_indicator) addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(left_indicator) end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(left_indicator) end ); function right_indicator() --right side turn on and turn off function end addEventHandler("onClientRender", root, right_indicator) addEvent("onClientVehicleTurnOnIndicator", true); addEventHandler("onClientVehicleTurnOnIndicator", root, function(right_indicator) end ); addEvent("onClientVehicleTurnOffIndicator", true); addEventHandler("onClientVehicleTurnOffIndicator", root, function(right_indicator) end );
It is good?
[HELP]Setting up mtasa-webradio api by botder
in Scripting
Posted
Hi! I found this api a few days ago by @botder.
I downloaded Docker Desktop and change directory in powershell to webradio's folder, typing in the api key and start it, but it isn't work. Someone can help me to setup this api fine?
https://github.com/botder/mtasa-webradio
Thanks!