Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 30/03/20 in all areas

  1. 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.
    1 point
  2. Thanks for helping me out! I try to make this exercieses, and if i finished,i put a video here of the final version.
    1 point
  3. 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
    1 point
  4. veh = {} -- Table de veículos, cada veículo será indexado em determinado jogador. addCommandHandler ("carro", function (thePlayer, cmd) if (veh[thePlayer]) then -- Se o veículo do jogador já existe, então: destroyElement (veh[thePlayer]) -- Destrói o veículo. veh[thePlayer] = nil -- Remove o veículo da table. outputChatBox ("Seu carro VIP foi destruído.", thePlayer, 255, 255, 0) else -- Se o veículo não existe, então: local x, y, z = getElementPosition (thePlayer) veh[thePlayer] = createVehicle (602, x, y+3, z+1) -- Cria o veículo, próximo ao jogador. setVehicleColor (veh[thePlayer], 0, 0, 0) -- Torna o veículo preto. setElementData (veh[thePlayer], "owner", getAccountName (getPlayerAccount (thePlayer))) -- Coloca o login de quem criou o veículo como dono. outputChatBox ("Carro VIP criado.", thePlayer, 0, 255, 0) end end) addEventHandler ("onVehicleStartEnter", root, function (thePlayer, seat, jacked) -- Quando alguém tenta entrar em um veículo, ativa essa função. if (getElementModel (source) == 602) then -- Se o veículo que o jogador está tentando entrar for o modelo do carro VIP, então: if (isGuestAccount (getPlayerAccount(thePlayer))) then return cancelEvent() end -- Se o jogador estiver deslogado, nada acontece e ele nem entra no veículo. (a ação de entrada no veículo é cancelada) if (seat == 0) then -- Se o jogador está tentando entrar como motorista, então: if (not isObjectInACLGroup ("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ("VIPCARRO"))) then -- Se o jogador que está tentando entrar não estiver na ACL Group VIPCARRO, então: outputChatBox ("Você não tem permissão para dirigir veículos VIP.", thePlayer, 255, 0, 0) cancelEvent () -- Cancela a entrada no veículo. elseif (getElementData (source, "owner")) then -- Se o jogador está na ACL Group VIPCARRO e o carro tem um dono registrado, então: if not (getElementData (source, "owner") == getAccountName(getPlayerAccount(thePlayer))) then -- Se o jogador que está tentando entrar não for o dono do veículo, então: outputChatBox ("Você não pode dirigir este veículo pois ele não pertence a você.", thePlayer, 255, 0, 0) cancelEvent () -- Cancela a entrada no veículo. end end end end end) addEventHandler ("onPlayerQuit", root, function () -- Destroi o veículo criado pelo jogador quando ele desconecta do server. if (veh[source]) then destroyElement (veh[source]) veh[source] = nil end end)
    1 point
  5. https://community.multitheftauto.com/index.php?p=resources&s=details&id=5060
    1 point
  6. Hehe really funny. Thanks for posting. I am really bored right now in my house
    1 point
  7. @Megadreams I'm interested that you say it's a lot of extra work. Obviously you've already done a lot of work on this - so changing strategy is obviously difficult - and I've not really thought a huge amount about it so maybe it's different to how I expect, but... The key difference between transpiling and interpreting is that instead of parsing the SCM and then calling functions based on it, you need to generate code that calls the same functions from the SCM. I imagine that either way you end up writing a library of code that handles each operation, and that library could be almost identical between both systems. With the transpiling approach I'd guess that control flow might be the tricky bit - though I believe Lua now supports 'goto' which could help quite a bit (I'm not sure if MTA has updated Lua yet - I know it was being talked about). Anyway interesting stuff - keep us updated!
    1 point
  8. Hey now, I wouldn't say it's useless. There's a few ways of dealing with this, one is to use a render target and one is to use tables. Just think about it logically, you most likely have a table containing the items that should be rendered - right? When you scroll down, you'll want to remove the top-most item which is most likely gonna be the first item in your table. So, you store those removed items in a 2nd table in case the user decides to scroll back up. It's all a matter of playing around with offsets and whatnot. Though I believe using a render target would allow for the smoothest transition, it all depends on how you want to approach it.
    1 point
  9. For years we have been using openid as a login system to our wiki. Most OpenID providers have been ending their support or have moved on to newer versions. While we are planning to integrate the new OpenID Connect to our wiki we are also offering users a chance to recover their exisiting accounts. When we implemented OpenID we did so without requiring another valid e-mail address. Because of this most users in our wiki are without e-mail account. Therefore using the lost password feature is not an option. In order to recover your account you can simply post a request in this thread. There are however some rules because we do not want account hijacking. - Nicknames have to have a certain match between them - Forum account has to be at least of similar age as wiki account or older We will add your forum e-mail address to the account and use the lost password feature. So once we confirm here that your account has been reactivated, check your e-mail (including spam folder).
    1 point
  10. As far as I know phpbb3 uses the phpass framework. MD5 has been considered insecure for many years now. Any site still using it might as well simply use plain text.
    1 point
×
×
  • Create New...