![](https://forum.multitheftauto.com/uploads/set_resources_22/84c1e40ea0e759e3f1505eb1788ddf3c_pattern.png)
Dealman
Members-
Posts
1,421 -
Joined
-
Last visited
-
Days Won
1
Everything posted by Dealman
-
I wouldn't necessarily call it wasting my time, I'm sure other readers might find it useful. @Amir: If you truly wanna learn not to use other people's scripts, you should start searching for information. Programming and scripting isn't much other than trial and error, really. For example, you need to plan ahead before you start scripting. Use both these forums, the MTA Wiki and Google for inspiration, even if the tutorial you're looking at is written for C++ or whatever language - you can always adapt it for Lua. For example to make a replay system think of it like this; 1. You need to capture the behaviour of a vehicle; 1a) You'll want to save the position of the vehicle 1b) You'll want to save the rotation of the vehicle 1c) You'll want to save the velocity of the vehicle (may not be necessary) Okay so you know this so far - position, rotation and velocity. A quick glance at the MTA Wiki and you'll find these functions do exactly what you want; getElementPosition getElementRotation getElementVelocity 2. Now that you have the necessary functions to record the behaviour of a vehicle; how do we go about doing this? 2a) Timers. Would a timer be a logical choice? No, because it has a minimum interval of 50ms - which may result in a choppy replay. 2b) What would the best option be for smooth and accurate capture? Obviously, onClientRender comes to mind since at 60 FPS you'll be executing the code every ~16ms. So now you know when to capture these values, but where do we store all the values? Obviously inside of a table - you can either use one table or like I did, a separate table for every value(position, rotation and velocity). How do we store values inside of a table? If we didn't know this, we'd head onto Google and search for "lua insert value table" or something similar - immediately we'd find that this is what we want; table.insert(theTable, theValue) ---- This is the kind of way you have to go about doing things. You might also want to write it down, sort of like brainstorming. You'd be surprised how many professional programmers do brainstorming before they go ahead and find a solution that fits their needs.
-
To make a minimap like that you'll need to convert their 3D space onto a 2D plane, if you do some Google searches I'm sure you'll find quite a bit of information on how to accomplish this. As for the replay, I wrote something similar for testing purposes a while ago. Basically, what you need to do is store the position and rotation of the vehicle in a table. You then loop through this table. You can check out my testing script if you want, do note however that I wrote this a long time ago and never finished it. Nor do I intend to. Also, this was merely written for testing purposes. As such, this code has not been refactored and is not optimized in any way shape or form. How to use: 1. Start the resource. 2. Start race, and pick whatever map you want. 3. The recording starts once the race state is changed to "running". 4. It records for 15 seconds. 5. Use the command /startreplay to start the replay. (Go back to the starting position first) Server.lua Client.lua
-
As was stated before, objects do not have any specified amount of health. You'll need to design your own health system to achieve this. Personally I would use element data for this as you already have the functions and events necessary.
-
Why not just add an or check? if(getTeamName(getPlayerTeam(pla)) == "Psycho Mans Gang" or getTeamName(getPlayerTeam(pla)) == "Staff") then
-
Error(6): Attempt to perform arithmetic on a boolean value
Dealman replied to cuervox123's topic in Scripting
It's really self explanatory. A boolean value is either true or false. You're attempting to do some math calculations with a boolean value. For example; local x = false print(x+10) This would return the same error. Of course you can't do false+10 or true+10. The debug will tell you exactly on what line this error occurs - go from there. -
"uk-height-1-1"> "uk-vertical-align uk-text-center uk-height-1-1"> "uk-vertical-align-middle" style="width: 250px;"> "uk-margin-bottom" width="140" height="120" src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAxNi4wLjQsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjwhRE9DVFlQRSBzdmcgUFVCTElDICItLy9XM0MvL0RURCBTVkcgMS4xLy9FTiIgImh0dHA6Ly93d3cudzMub3JnL0dyYXBoaWNzL1NWRy8xLjEvRFREL3N2ZzExLmR0ZCI+DQo8c3ZnIHZlcnNpb249IjEuMSIgaWQ9IkViZW5lXzEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB3aWR0aD0iMTQwcHgiIGhlaWdodD0iMTIwcHgiIHZpZXdCb3g9Ii0yOS41IDI3NS41IDE0MCAxMjAiIGVuYWJsZS1iYWNrZ3JvdW5kPSJuZXcgLTI5LjUgMjc1LjUgMTQwIDEyMCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8ZyBvcGFjaXR5PSIwLjciPg0KCTxwYXRoIGZpbGw9IiNEOEQ4RDgiIGQ9Ik0tNi4zMzMsMjk4LjY1NHY3My42OTFoOTMuNjY3di03My42OTFILTYuMzMzeiBNNzkuNzg4LDM2NC4zNTVIMS42NTZ2LTU3LjcwOWg3OC4xMzJWMzY0LjM1NXoiLz4NCgk8cG9seWdvbiBmaWxsPSIjRDhEOEQ4IiBwb2ludHM9IjUuODYsMzU4LjE0MSAyMS45NjIsMzQxLjIxNiAyNy45OTUsMzQzLjgyNyA0Ny4wMzIsMzIzLjU2MSA1NC41MjQsMzMyLjUyMyA1Ny45MDUsMzMwLjQ4IA0KCQk3Ni4yMDMsMzU4LjE0MSAJIi8+DQoJPGNpcmNsZSBmaWxsPSIjRDhEOEQ4IiBjeD0iMjQuNDYyIiBjeT0iMzIxLjMyMSIgcj0iNy4wMzQiLz4NCjwvZz4NCjwvc3ZnPg0K" alt=""> "uk-panel uk-panel-box uk-form"> "uk-form-row"> -- Create 2 alert messages which are hidden by default --> "display: none;" class="uk-alert uk-alert-danger" id="loginErrorAlert">Login Failed! Invalid username and/or password. "display: none;" class="uk-alert uk-alert-success" id="loginSuccessAlert">Login Successful! -- Create an input field for the username --> "uk-width-1-1 uk-form-large" type="text" id="usernameField" placeholder="Username" maxlength="24"/> "uk-form-row"> -- Create an input field for the password --> "uk-width-1-1 uk-form-large" type="password" id="passwordField" placeholder="Password" maxlength="24"/> "uk-form-row"> -- Create a button to trigger the login events --> "uk-width-1-1 data-uk-button uk-button-primary uk-button-large" onclick="triggerLoginEvent()">Login "uk-form-row uk-text-small"> -- Create a checkbox for remembering the password (Not Implemented) --> "uk-float-left">type="checkbox"> Remember Me -- Create a link for password recovery (Not Implemented) --> "uk-float-right uk-link uk-link-muted">Forgot Password?
-
This is a decompiled script, and as such you should know by now that you won't get a lot of help here.
-
I recall there's a way to reproduce it. One of the communities I used to play with had a ghost car script for their DM server, and if you ran a command that blows up all cars during countdown(race gamemode) this would happen to the ghost car - but not the players.
-
While this is true, compiled code does load faster - it does not actually execute any faster. For MTA, this is hardly an issue - and as such, around these forums compiling your scripts has become more of a way to prevent unauthorized access rather than optimization.
-
He asked for help to decompile some scripts, not for an entire gamemode. There's no need to exaggerate like that, come on. @kewiiNNN: You have to realize that people compile their scripts for a reason, to prevent unwanted modifications. Some people spend many hours on their creations, and as such don't want unauthorized people to access their code and possibly re-distribute it. If you want any chance at accessing the source code, you'll want to contact the original author and ask him/her. No-one here is gonna help you to decompile something that isn't yours.
-
Aye, and it's a good reason as well. I've simply stuck with pascal case since I've been working with C#
-
I think a lot of those frameworks look similar, as for the differences I think they're pretty much the same to some extent. One of the biggest differences I can think of is that Bootstrap doesn't natively support responsive(you need to add it manually) widgets whereas UIKit does. As for the error I'm not quite sure, I don't ever get any error or warnings from the browser at all. So I assumed it didn't have any debug messages yet.
-
Since the addition of the CEF Browser in MTA 1.5, I've been using it quite a bit. And I've recently begun looking into creating various interfaces using this instead of the traditional CEGUI or DirectX functions. And since my HTML and CSS knowledge is rather limited at the moment - I looked into the possibility of adding a UI Framework. I'm glad to report that it's a very easy thing to do. And you can access this framework's features from a separate resource. Download: MTA Community Download (V1.0.0) Installation: Just "install" it like any other resource. It comes pre-packages as a .zip file for compression so all you have to do is place it inside the resources folder, refresh and start it. That's all you have to do! How To Use: In order to use this from an external resource, you'll have to provide MTA with the proper location of the CSS and JS files. A very simple example would look like this; <html> <head> <link rel="stylesheet" href="http://mta/UIKit/css/uikit.gradient.css"/> <script src="http://mta/UIKit/js/jquery.js"></script> <script src="http://mta/UIKit/js/uikit.js"></script> </head> <body> <div class="uk-panel uk-panel-box uk-text-center"> <h1>Hello MTA Community!</h2> <p>This is just a little example. You can now create local webpages for use within MTA using the wonderful UIKit Framework!</p> <button class="uk-button uk-button-danger uk-button-large" type="button">Cancel</button> <button class="uk-button uk-button-success uk-button-large" type="button">Accept</button> </div> </body> </html> And it would look something like this; Example Screenshot(1920x1080) Available Stylesheets: uikit.almost-flat.css uikit.almost-flat.min.css uikit.gradient.css uikit.gradient.min.css uikit.css uikit.min.css For further information on how to use this, I suggest you visit their website! UIKit Homepage
-
Don't get us wrong, just because we provide criticism doesn't mean we don't appreciate you releasing your work. I'm personally always glad to see people releasing their work - whether WIP or finished. There's always someone out there which will make some use of it in one way or another. I wrote this tutorial a little while ago to try and help people organize their code structure properly. It might be something you'll find helpful. Not only will keeping it clean help yourself, but also others should you decide to release it.
-
All he said was that the code isn't organized, and he's right. Trying to read and figure out how the code is working when you're not even using indentation can be a pain. It was just some criticism, no need to jump to name calling The variable names for your buttons are nonsensical and just random names. You should try and keep it simple. For example if a button sets their team, name it something logical such as "buttonSetPlayerTeamUSA" instead of "yoi_button1". Of course, people write differently, but if you're planning to release stuff you might want to look into cleaning it up a bit to avoid such criticism
-
You didn't read my post at all did you? Go to the website I linked in my quote, there you can execute Lua code, whether for testing or whatnot. Post this code in there; local sX, sY, wX, hY = 480, 240, 969, 570; -- Paste the absolute values here local sourceWidth = 1920; -- Change those to the source values. local sourceHeight = 1080; -- Change those to the source values. local nSX, nSY, nWX, nHY = (sX/sourceWidth), (sY/sourceHeight), (wX/sourceWidth), (hY/sourceHeight); for i=0, 47 do print(""); -- This is just to clear the print window, so you don't get confused what to copy. end print(tostring(nSX).."*screenX, "..tostring(nSY).."*screenY, "..tostring(nWX).."*screenX, "..tostring(nHY).."*screenY"); Then replace this local sX, sY, wX, hY = 480, 240, 969, 570; -- Paste the absolute values here With whatever absolute values you have. Do this for each rectangle, text and whatnot. When you run the code on that website it will return the relative value - which is what you want. It's simply a matter of copy and paste. Also you're still trying to use 1980x1080. It should be 1920x1080.
-
Of course it wouldn't output anything from an empty table, that's what KariiiM said. Whether it's not defined or empty, both would return nil errors. Only difference being the actual error.
-
Could you post the new, updated code?
-
And you base this on what? It all depends on how it's set up. If you use setElementData and leave it as default - it will sync between all players. If you use triggerClientEvent you can simply trigger it for one client. All the server has to do is trigger the event, the client takes care of the rest of the event. While both work, I sincerely doubt triggerClientEvent uses "more CPU" than setElementData.
-
You'd be much better of simply using Google instead of these forums for that. Simply search for things like "Free UI template", "Free photoshop interface" and such things.
-
Well, first of all it's 1920x1080 and not 1980x1080. Secondly, I'd suggest you follow this method instead; Thirdly, the reason it doesn't look the same for you is because of the way you're doing the math. A 200 pixel transition is less on a 1920x1080 resolution than on for example a 1280x720 resolution.
-
I totally forgot about that one The bounding box is the area of the text, if you use the GUI Editor this is seen as pink lines. Anything that goes outside of this area will not be seen.
-
By creating a render target, anything outside of the specified area can be cut off. dxCreateRenderTarget
-
I went ahead and wrote a little interactive example for you. I tried to comment it all the best I could, hopefully you can learn from it. Basically, what you need is trigonometric calculations. Trigonometry is very confusing at first, but once you start picking it up it's a lot of fun as you can make a lot of interesting stuff with it. If you want to read up on trigonometry, I would highly recommend the video lessons available for free over at Khan Academy. How To Use: There are two commands to use this script, so if you wanna change values you have to do that in the script itself. The variables should be rather self-explanatory. Type /SpawnObject to spawn the two objects (center and outer) Type /ToggleCamera to toggle an overhead camera based on the center object's position Client.lua
-
I wrote this a long time ago however, so there's plenty of cleaning and optimizations to be done.