Jump to content

Leaderboard

Popular Content

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

  1. function lockCar(player, cmd) local radius = 3 local x, y, z = getElementPosition(player) local vehiclesAround = getElementsWithinRange(x, y, z, radius, "vehicle") local vehicleElement = false if #vehiclesAround == 0 then outputChatBox("no vehicles around", player, 220, 220, 0) return end for i = 1, #vehiclesAround do vehicleElement = vehiclesAround[i] if getElementData(vehicleElement, "uid") and getElementData(vehicleElement, "uid") == 0 then setVehicleLocked(vehicleElement, true) outputChatBox("lock", player, 220, 220, 0) break end end end addCommandHandler("wv", lockCar) Here you go, i also changed loop to faster, and we don't need colshape to get vehicles around. (+problem is that, that you create colshape and never delete it)
    2 points
  2. 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.
    1 point
  3. El error se entiende como: no se pudo llamar al resource sql. Ya que no esta el resource iniciado o contiene errores que impiden que inicie correctamente.
    1 point
  4. 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>
    1 point
  5. 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!
    1 point
  6. 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!
    1 point
  7. Faça uma API no site que verifique se exista login e se a senha esta correta, assim que ela estiver pronta voce faz um script chamando ela no servidor. *Porque uma API? Resposta simples, assim voce pode utilizar o mesmo sistema de login do SITE sem perder tempo integrando DbConnect e gerando sistema de encrypt oque seria complexo. Em questao dos Status voce deve utilizar este sistema MTA PHP_SDK pelo menos e esse que eu utilizo no meu. $server = new Server('127.0.0.1', 22005); $auth = new Authentication('login', 'senha'); $mta = new Mta($server, $auth); $resposta = $mta->getResource('nome_do_resource')->call('nome_da_funcao', $arg1, $arg2, $arg3, ...); se sua função no servidor tiver argumentos deve ser preenchido ali o $arg1, $arg2... e a $resposta é oque a função que você chamou te retorna eo 'return' dela. exemplo $response = $mta->getResource('executaCalculo')->call('soma',5,5); -- funcao no servidor dentro do resource executaCalculo function soma(a,b) return (a+b) end -- $resposta = 10. tem outras questoes tambem voce deve verificar como o Meta(<export function="soma" type="server" http="true" />) para habilitar a funcao eo user que e um user somente para http. Espero ter ajudado.
    1 point
  8. 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.
    1 point
  9. i use browser, but that's not good, because cannot play copyrighted music :s
    1 point
  10. 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.
    1 point
  11. 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
    1 point
  12. local Key = 'L' -- addEventHandler("onPlayerJoin",root,function () bindKey (source,Key,"down",switchEngine) end) local function bindTheKeys() for _,player in ipairs(getElementsByType("player")) do bindKey (player,Key,"down",switchEngine) end end addEventHandler("onResourceStart",resourceRoot,bindTheKeys) try
    1 point
  13. 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?
    1 point
  14. 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.
    1 point
  15. I am not entirely sure, but it seems like you are trying to bind the keys to the server instead of the player. Maybe you are looking for another eventHandler. What about: addEventHandler ( "onPlayerJoin", getRootElement(), bindTheKeys )
    1 point
  16. 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.
    1 point
  17. 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
    1 point
  18. local colshape = createColSphere(tonumber(x), tonumber(y), tonumber(z), tonumber(radius)) If you create colshape, and not delete it it will stay on map until resource restart, wanna see? After using your command follow steps below. Execute this command in admin panel (Resources > Execute command) setDevelopmentMode(true) for client & server. And then, simply write: /showcol in chat. I've added additional element data check, so if vehicle doesn't have such element data, it wouldn't compare number with boolean. Besides, my version of code is somewhat faster, because of integer loop (you can't really see difference, but it's better to use it anyways) Source: https://springrts.com/wiki/Lua_Performance Why after all people use ipairs without sensible reason? I don't know, maybe because some of them lazy, or they don't even know that you can use int loop.
    1 point
  19. روح على الويكي روح الساينتكس , الارقيومنتس الي بين [ ] اختياري , تحطه او لا
    1 point
  20. Por favor la próxima vez que necesites ayuda de scripting en español usa la parte del foro correcta: https://forum.multitheftauto.com/forum/167-scripting/ Pero no hace falta crear otro hilo, supongo que algún staff moverá tu hilo a la sección correcta y obtendras una respuesta.
    1 point
  21. WARNING: Empresas/client.Lua:71: Bad argument @ "outputChatBox" [Expected string ar argument 1, got none] I solve it, thanks!
    1 point
  22. Eu vincularia ele à conta do jogador. "Jogador de login tal é o proprietário deste veículo"
    1 point
  23. Você quer definir um dono para o carro?
    1 point
  24. You'll need developers who are experienced in file optimization across sound, texture and model field. Those with knowledge in the fields can bring down all 85 of your 20mb sound files to just a few megabytes, or kilobytes, cut down polygons from 120k to 12k or effectively compress textures to barely no size while retaining most of the vital details. If your developer can do this, he can do it for the rest of the server's assets as well, which equals a very low download size for the server. And if these heavily optimized assets are frowned upon by players with high end computers, you can utilise a LOD system which lets users choose higher graphic settings for higher quality assets, but keeping the lowest LOD setting as default for newly joining players. Optimization is one thing, retopologising and recreation of assets is another. While the former destroys areas on the asset, it's by far a lot easier on development time and thus can get the desired result ready a lot sooner. TL;DR you'll need to find someone experienced in optimization of model, texture, sound files etc.
    1 point
  25. Vc precisa ativar o recurso de voz do servidor e então fazer um script que transmita sua voz somente para determinado jogador, já que por padrão ele transmite a todos que estiverem próximos de vc.
    1 point
  26. Si sigues necestiando ayuda mandame mensaje privado.
    1 point
  27. Lo más seguro es que si es nuevo en scripting, no sepa instalar dicho GM, si necesitas ayuda ponlo en este mismo comentario y te ayudare a instalarlo.
    1 point
  28. الكلينت مافيه ارقمنت للاعب, تكتب رسالتك على طول outputChatBox("test")
    0 points
×
×
  • Create New...