-
Posts
822 -
Joined
-
Last visited
-
Days Won
86
Everything posted by The_GTA
-
I think I understand. You want to display the seconds as double-digits, right? local seconds_text if (seconds < 10) then seconds_text = "0" .. seconds else seconds_text = tostring(seconds) end local minutes_and_seconds = minutes .. ":" .. seconds_text This script puts the time by minutes and seconds always in the format M:SS (1:08, 1:45, 5:12, 0:00, etc). Provided that seconds and minutes are integers which are not negative. Use the "minutes_and_seconds" variable for your drawing code.
-
local text if (seconds == 0) then text = minutes .. ":" .. seconds .. "0" else text = minutes .. ":" .. seconds end dxDrawText(text, screenW * 0.8443, screenH * 0.9148, screenW * 0.9740, screenH * 0.9769, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false) ??? What do you mean? Could you please explain in more detail? Doesn't the... dxDrawText(minutes..":"..seconds..milliseconds, screenW * 0.8443, screenH * 0.9148, screenW * 0.9740, screenH * 0.9769, tocolor(255, 255, 255, 255), 1.00, "default", "center", "center", false, false, false, false, false) ... script already display as 2:00 if seconds == 0 and milliseconds == 0? What do you mean if it "reaches 1:0"????
-
Hey, you have a really good instinct when it comes to foreign language support. It does not look like it is targeted for the Spanish subforums but the user has now replied in Spanish. To me it looks like automatic translation with the user being unaware that it was translated? He has even contacted me in Spanish using private messaging... I feel really sorry that I cannot speak his language though. Maicol, I am really sorry but I don't understand Spanish properly enough to assist you with scripting in general if you are just speaking Spanish. But I swear that I would have liked to help you if I were fluent in Spanish. If you can limit your problem description to English then maybe. Otherwise this conversation should be held with native Spanish speakers.
-
Hello Maicol, nice to meet you! MTA has built-in functionality to limit command-access to server accounts. In a default MTA server, players can register an account using the "/register" command. Then you can give access to special commands to this registered account inside of the ACL.xml file. You can find documentation on how to edit the file here: Acl - Multi Theft Auto: Wiki You can locate the file inside of the "deathmatch" folder of your MTA server. Example nodes: <acl name="admin"> ... <right name="command.auto" access="true" /> <right name="command.moto" access="true" /> </acl> <acl name="default"> ... <right name="command.auto" access="false" /> <right name="command.moto" access="false" /> </acl>
-
edit.lua -- Put configuration into _G the global variables so that they can be imported by compiled.lua config1 = "test" config2 = 42 ... compiled.lua -- Import the configuration as local variables. local config1 = config1 local config2 = config2 ... meta.xml <meta> <script src="edit.lua" type="server" /> <script src="compiled.lua" type="server" /> </meta> This is the pattern that I recommend based on your description. You chose an awkward topic title for such a specific problem.
-
There are limitations inside of MTA, like the inability to remove original game water zones, which make starting from the basics awkward. You could work around them by playing around with the sea water level in relation to your own customly-created water zones. If we are talking about replacing the models of the original map, you can pretty much do all of it. In recent updates MTA has received so much internal GTA SA feature exposition that you can load your own map. We are limited by certain strong engine constants like the size of the original map and the collision math precision. But I think that you could find your way around all the problems and create an enjoyable MTA map.
-
You're welcome. A big problem in your model is that you link the movement-speed of the spoiler to game FPS. This results in different speeds depending on computer performance. I recommend you to use getTickCount to get elapsed time in milliseconds and then divide it by 1000 to get the elapsed seconds. Then multiply it by a base-velocity to get the distance it should travel per second. Then change the mathematics accordingly inside spoiler_move clientside.lua .
-
Oh, excuse me for misunderstanding. You did not give accurate enough specification of which spoiler should move and whether there was only one vehicle on the server with the spoiler. Here is a better version. I cannot test it because you missed out on giving us your vehicle model. Please tell me if it works for you. ? clientside.lua local spoiler_status = {}; local function getVehicleSpoilerStatus(veh) local status = spoiler_status[veh]; if (status) then return status; end; status = {}; status.move_dir = false; spoiler_status[veh] = status; return status; end addEventHandler("onClientElementDestroy", root, function() if (getElementType(source) == "vehicle") then spoiler_status[source] = nil; end end ); addEvent("onClientSpoilerInformation", true); addEventHandler("onClientSpoilerInformation", root, function(desc) local info = getVehicleSpoilerStatus(source); --outputDebugString("received spoiler information"); info.move_dir = desc.move_dir; info.sX = desc.sX; info.sY = desc.sY; info.sZ = desc.sZ; end ); function spoiler_move() local vehicles = getElementsByType("vehicle"); for _,vehicle in ipairs(vehicles) do local status = getVehicleSpoilerStatus(vehicle) if status.move_dir == 1 then if status.sZ and status.sZ < 1.2 then status.sX = status.sX + 0; status.sY = status.sY - 0.006; status.sZ = status.sZ + 0.005; end --dxDrawRectangle(300, 300, 100, 100, tocolor(255, 0, 0, 255)); elseif status.move_dir == 0 then if status.sZ and status.sZ > 1 then status.sX = status.sX + 0; status.sY = status.sY + 0.012; status.sZ = status.sZ - 0.01; end --dxDrawRectangle(300, 300, 100, 100, tocolor(0, 255, 0, 255)); end if (status.sX) then -- Only works if vehicle is streamed in, but we keep a copy of the component position just in case. setVehicleComponentPosition(vehicle, "movspoiler_23.5_1800", status.sX, status.sY, status.sZ) end end end addEventHandler("onClientRender", root, spoiler_move) -- Cached network table. local net_desc = {}; local function synchronizeSpoilerStatus(veh, info) -- Transmit over the network. net_desc.move_dir = info.move_dir; net_desc.sX = info.sX; net_desc.sY = info.sY; net_desc.sZ = info.sZ; triggerServerEvent("onSpoilerInformation", veh, net_desc); end local function spoiler_control(key, state) local veh = getPedOccupiedVehicle(localPlayer); if (veh) and (getVehicleOccupant(veh, 0) == localPlayer) then local info = getVehicleSpoilerStatus(veh); if not (info.sX) then local sX, sY, sZ = getVehicleComponentPosition(veh, "movspoiler_23.5_1800"); if (sX) then info.sX, info.sY, info.sZ = sX, sY, sZ; end end if (key == "u") and not (info.move_dir == 0) then if (state == "down") then info.move_dir = 1; else info.move_dir = false; end elseif (key == "z") and not (info.move_dir == 1) then if (state == "down") then info.move_dir = 0; else info.move_dir = false; end end synchronizeSpoilerStatus(veh, info); end end bindKey("u", "both", spoiler_control); bindKey("z", "both", spoiler_control); addEventHandler("onClientVehicleExit", root, function(ped, seat) if not (seat == 0) then return; end; local info = getVehicleSpoilerStatus(source); info.move_dir = false; if (ped == localPlayer) then synchronizeSpoilerStatus(source, info); end end ); addEventHandler("onClientResourceStart", resourceRoot, function() triggerServerEvent("onPlayerReady_Spoiler", root); end ); serverside.lua -- TODO: add proper security to this script. local spoiler_status = {}; local ready_players = {}; local function sendSpoilerInformation(player, veh, desc) triggerClientEvent("onClientSpoilerInformation", veh, desc); end addEvent("onSpoilerInformation", true); addEventHandler("onSpoilerInformation", root, function(desc) spoiler_status[source] = desc; for m,n in pairs(ready_players) do if not (n == client) then sendSpoilerInformation(n, source, desc); end end end ); addEvent("onPlayerReady_Spoiler", true); addEventHandler("onPlayerReady_Spoiler", root, function() for veh,desc in pairs(spoiler_status) do sendSpoilerInformation(client, veh, desc); end ready_players[client] = true; end ); addEventHandler("onPlayerQuit", root, function() ready_players[source] = nil; end ); addEventHandler("onElementDestroy", root, function() if (getElementType(source) == "vehicle") then spoiler_status[source] = nil; end end ); Use the "u" and "z" keys to control spoiler movement.
-
function spoiler() local vehicles = getElementsByType("vehicle"); for _,vehicle in ipairs(vehicles) do local sX, sY, sZ = getVehicleComponentPosition(vehicle, "movspoiler_23.5_1800") if (sX) then if spoiler == 1 then -- warning: variable overlaps with function name if sZ < 1.2 then setVehicleComponentPosition(vehicle, "movspoiler_23.5_1800", sX, sY-0.006, sZ+0.005) end elseif spoiler == 0 then if sZ > 1 then setVehicleComponentPosition(vehicle, "movspoiler_23.5_1800", sX, sY+0.012, sZ-0.01) end end end end end addEventHandler("onClientRender", root, spoiler) This clientside approach works as long as you do not want special synchronized modifications to the spoiler placement.
-
Do you mind sharing your the entire serverside script so that we can take a look? Maybe there is a not-so-obvious scripting flaw that we can detect together.
-
Exactly. I think OP is confusing code that is scheduled to run in two minutes with code that is running at the time of timer creation. And then there is a time after timer creation and before timer execution where the error may be. I am interested in that time. The code inside the timer, the function() ... end part that is the first argument to setTimer, does not appear to be the root of the problem. I think you should show us that either thePlayer is a local variable that is set somewhere above your code and modified at a later point or use the recommended solution I posted above with the local warpPlayer variable.
-
Hello spaghetti1337, since you are not providing the entire code, for example the place where the "thePlayer" variable is being set, I can only guess. What if thePlayer is being overwritten with another player element while the timer is still ticking? You can fix it this way: do local warpPlayer = thePlayer -- the closure now has a new copy of the player element local x,y,z = getElementPosition(warpPlayer) --- I define the player's position here (this is before he is warping to the vehicle) local cloneveh = cloneElement ( vehicle, 2066.6848144531, -2496.1398925781, 13.546875 ) setElementRotation(cloneveh, 0,0, 89.148399353027) warpPedIntoVehicle ( warpPlayer, cloneveh ) setTimer (function() --- after 2 minutes I destroy the vehicle and trying to teleport back the player for his previous position destroyElement(cloneveh) setElementPosition(warpPlayer, x,y,z) end, 120000, 1) end This script does still have problems, for example it does not store the timer so that it could be stopped in case the player has left the server. You should take care of properly terminating invalid timed executions.
-
Yes, but the documentation is wrong. rasterType is just the first three bits of the 8bit unsigned char value. 0 - normal 1 - zbuf 2 - camera 4 - texture 5 - camera texture Values 3, 6 and 7 are invalid. I have correct documentation of the D3D9 native texture binary stream format in my OneNote documents. I could export it if there is real demand.
-
Yes, I do! I know exactly what causes it in the game logic/code and how to modify the game to restrict the texture loader without impacting the regular use.
-
I think that you are not considering the whole picture here. The optimizations performed by logic transformations itself will speed up the code. The compiler will warn the users if dx functions are provably used outside of onClientRender event handlers. The compiler will pick best internal representations for objects (strings, tables, etc) depending on their use (constant string, extensible string buffer, hash table vs. sortable-key table, etc). And much more! Consider that when looking forward or even wanting to support my compiler development.
-
I am willing to test against LuaJIT in the future. Do you have any benchmarks in mind that I can perform the speed comparisons on? I need good and isolated test scripts.
-
Let me explain to you how this might not be a bug from the perspective of RenderWare developers. Each texture can be one of the following types: normal, zbuf, camera, texture or camera texture. By loading a texture you are supposed to put pixels into the destination of a texture. In the normal or texture case, the target is a simple color buffer that can be mapped to triangles. In the camera texture case it is what we call render-targets inside MTA. But for the camera case, the destination is the camera itself. So you can see how loading a "camera" texture loads pixels into the backbuffer, directly. But I think that MTA might not have anticipated this. Thank you for sharing your thought!
-
Some time has passed and I would like to give you another update about the current point-of-research. As I have promised in the previous posts I did work on the lexer and have finished it. The lexer is the component of a program which turns human-friendly text into machine-driven data. As an example of its functionality I have made a small and simple XML parser that could rival even TinyXML, if finished. The context-free-grammar (CFG) production rules are as follows: S -> takefirst spaces (begdesc spaces)^0:1 xmlnode spaces xmlnode -> '<' spaces begtag:xmltagname spaces attributes spaces '/' spaces '>' xmlnode -> opentag spaces (child:[<1,e>xmlnode,spaces]|content:text)^0:1 spaces endtag opentag -> '<' spaces begtag:xmltagname spaces attributes spaces '>' endtag -> '<' spaces '/' spaces endtag:xmltagname spaces '>' attribute -> key:keyname spaces '=' spaces value:strtok attributes -> [<0,e>attribute,spaces] begdesc -> "<?xml" spaces attributes spaces '?' spaces '>' spaces -> '\n\r\t '^* name -> 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'^1:* xmltagname -> name keyname -> name text -> name (File Details: /testcompiler/src/lexing_tests.cpp (head) - eircompile (svn) - Eir Compile - OSDN) The lexer supports the following optimizations: single-step-optimization or undeniable-change-optimization: objects are passed directly into rules which promise to not modify it if they fail late-creation-optimization: objects are only created at the point at which are they first really needed Suffice to say I am very convinced that writing rules for the lexer is better than writing the lexing in C++ code. Not only do you not trash the C++ stack using weird method names but the lexer does use internal optimized allocator-based data structures. --- I am working on Lua CFG rules but I am not confident enough to share them yet. Instead I want to talk about the next big thing in what makes up a compiler for computers: object-based calculations. Previously I have already mentioned the calculation dependency graph system which is just another way to phrase it. To put text into executable form you need to lex, interpret and calculate it. Interpreting is the way of applying a template with calculatory meaning to language structures. For example, lets look at how we would implement the Lua + operator (proof-of-concept): typedef variant <bool, number, object*> TValue; // garbage-collector-ref since it has a pointer to object ... operator + (TValue left, TValue right) { if (left.index == 0 && right.index == 0 || left.index == 1 && right.index == 1) { return ( left.value + right.value ); // bool and number are compiler built-ins } else if (left.index == 2 || right.index == 2) { return object_add( left.value, right.value ); // call into support library of object type (managed by compiler) } else { throw; } } In Lua code each local-declaration or slot in a Lua table is a TValue. A TValue either a boolean, number of pointer to Lua dynamic data. Lua dynamic data is traditionally either a string, table, closure, state or userdata. What does it mean to "apply a template"? Think about the fact that the lexer is putting out a tree of language objects which stand in relation to each other. For example we have the statement: a + b. We set left = a and right = b. Then inside of the calculatory tree we replace the + node with the proof-of-concept code we see above, binding the variable "a" to the name "left" and "b" to the name "right". Then we can further calculate the tree because we know meaning behind "if"-nodes and "+" nodes that connect to compiler-internal types. The code you see above is a proof-of-concept for my proprietary object language that will be used inside the compiler. While it may look very similiar to C or C++ it will be different in the following ways: there are no strict type bindings, calculations are performed in no strict order other than what correctness requires, types depend on the platform or support library availability, etc.
-
Please put the barprogress variable and use the script I gave you as template. Put the following line and other drawing code... dxDrawImage(botX+sizeX+343, botX2+sizeX2+701, 592/100*barprogress, 6, 'assets/progress_bar.png', 0, 0, 0, tocolor(43, 171, 226, 255), true) ... into the onClientRender event handler which is about line 13 of my script. Also, do not use dxDrawImage without dxCreateTexture.
-
... addEventHandler("onClientTransferBoxProgressChange", root, function(size, total) barprogress = ( size / total ) end ) addEventHandler("onClientTransferBoxVisibilityChange", root, function(vis) barvisible = vis end ) barvisible = isTransferBoxVisible()
-
You have to put this code into the last Lua file or create a new one. To make sure everything has loaded you can put it inside of a resource-start event handler. It depends on whether your code is running clientside or serverside.
-
local objects = getElementsByType("object") local offx = 0 local offy = 0 local offz = 800 for m,n in ipairs(objects) do local x,y,z = getElementPosition(n) setElementPosition(n, x+offx, y+offy, z+offz) end
-
From your description I understand that you want to draw a progress bar using DX functions. Yes, you can do that! Please take a look at the wiki page of the dxDrawImage function. There you will see that it has to be put inside of an onClientRender event handler to function. I recommend you to put at least two rectangles: one for the background of the loading bar and another for the region that fills it out. local barx = 100 local bary = 100 local barw = 100 local barh = 20 local barvisible = true local barprogress = 0.5 local barbgcolor = tocolor(255, 255, 255, 255) local barfillcolor = tocolor(255, 0, 0, 255) addEventHandler("onClientRender", root, function() if not (barvisible) then return end dxDrawRectangle( barx, bary, barw, barh, barbgcolor ) dxDrawRectangle( barx, bary, math.floor(barw * barprogress), barh, barfillcolor ) end );
-
Hello RandomRambo, have you tried using dxDrawImage with a transparent alpha value for color? You can load an image using dxCreateTexture at load-time of your resource and use the texture handle in a dxDrawImage call. This will allow you to draw the background image transparent instead of simple rectangles. Not using dxCreateTexture is not recommended.