
NeXTreme
Members-
Posts
117 -
Joined
-
Last visited
Everything posted by NeXTreme
-
You can use a shader. Download this resosurce: https://community.multitheftauto.com/index.php?p= ... ls&id=2730 It contains a shader called "texreplace.fx". Add that shader as a "file" in your meta.xml, along with the png image you wish to use for the moon, then use this code in a client-sided script to replace the moon: texShader = dxCreateShader ( "texreplace.fx" ) moonTexture = dxCreateTexture("yourMoonImage.png") -- Replace the filename to your image's file obviously dxSetShaderValue(texShader,"gTexture",moonTexture) engineApplyShaderToWorldTexture(texShader,"coronamoon") Enjoy.
-
Here's a few tutorials on general LUA for ya http://www.dev-hq.net/3-Lua
-
Perhaps I will, I'd like this function very much, could be used for a few things
-
To rephrase the question, I need a function to find the chatbox scroll position, some value that indicates how much the chatbox is scrolled (client side obviously).
-
Is there a possibility to get the scroll of the chatbox? There's so much stuff you can get from getChatboxLayout, but you cannnot get the scroll of the chat. Quite dissapointing. Anyways, is there a function that does this which I haven't yet discovered, if not, is it possible to make a custom function to do this with decent precision, or is it just plain impossible?
-
True. I don't see such a big problem in this unless you have a really huge script. In my own resource, players have to download around 152kb of scripts every time they connect. I obviously don't delete images or sounds, or the size would increase to over 3MB. In my opinion those 152kb are downloaded almost instantaniously, even with a slower connection speed. Would also like to hear some other opinion about this.
-
You are right, SDK. I tried it as much as I could, tried to reconnect within in that half a second it takes me to download all scripts. It seems to work, I'll add it to the topic
-
Protect your client-sided code This is a short tutorial on how to "protect" your client-sided scripts, using very basic LUA code. Like any other protection method, it isn't 100% secure, so combining this method with compiling or similar is recommended. Now, if you're scripting yourself, you know the importance of having your scripts safe. We don't want anyone to steal our code, right? And, even though users can only steal client-sided code (since it's downloaded to their computer), it can give you a headache when you see another server using similar scripts. Compiling only gets you so far, it's fairly easy to decompile any script and extract some chunks of code from it. While not perfect, it makes it easier for that person to "make" the script themselves; sometimes you can decompile the whole code, and it will work flawlessly. With the release of MTA 1.1, this method became possible (cheers to MTA developers for that ). There is a simple way of "preventing the scripts from downloading to the player's PC". Okay, don't hold me for that literaly. The scripts still get downloaded, but the user can't find them in his downloaded resources folder. How? Well, here's the "magic" behind it. Whenever the player joins your server, he downloads any necessary files, images, sounds, and also client-sided scripts (if he joined for the first time). Afterwards, the client-sided scripts are loaded, and from that moment on, they are no longer required on the player's hard drive. Why do they stay there? I don't know, seems like we're just offering others to steal them. How do we prevent that? Using simple LUA code, we delete the downloaded scripts after they are loaded into memory. It is as simple as it sounds. Anyone looking in the folder of your resource won't find any scripts. It is VERY IMPORTANT to place this code client-side, otherwise your original files that reside on the server will be deleted. Place the following code at the VERY END of your client script file. Replace the "script_name.lua" with the name of your client-sided script, of course. -- Delete file fileDelete("script_name.lua") * Thanks to SDK for pointing out this better solution, which is more failproof. Note: Using an event handler "onClientResourceStart" and cramming all delete functions in there also works, but if the player would disconnect before the entire script is downloaded, they would not get deleted. Hence you have to put a single fileDelete at the end of every lua file you have. The downside with this method is the scripts have to be redownloaded every time the player joins. If you have a small code, that's not such a problem. About 3000 lines of code takes up 157kb of space (in my own resource), and that's not alot to download in my opinion. As I mentioned earlier, it is a very simple method to remove the scripts after getting downloaded, and you could call it "protecting" your scripts. It's an efficient way of keeping your work from other players.
-
Mind if I also post my own grayscale shader on the community? It's a bit different than yours
-
I would like one too. If you are trying to get texture names of stuff like nitro, try checking the effects.fxp file. Using a simple search I found the texture for the nitro. As far as a full list, I have no idea where to get it.
-
I made a nitro shader myself. The color is customisable with a simple function, and can also be reset to the original. It doesn't look quite the same as original nitro, but I think it's very close.
-
I have of course triggered an event for everyone, but sometimes desync still occurs. Now obviously if you can't have "server-side physics", there should still be some way of making sync better, like, if some player had an average of 20 fps, his vehicle could move slower, and therefore cause desync. Same could occur with having a high ping or something, as the player would recieve the response from the server later than other players. The idea of server-sided function is that the server would ensure that every client would get it at the exact same time, and also ensure the vehicle (or ped) has moved correctly.
-
I've seen this "issue" being addressed in the Scripting section a lot, and I could certainly use it myself, too. The problem with setPedControlState is that it's only client-sided, which isn't that big of a deal in most cases. However, my recent project requires precise synchronization and having a client-sided function to toggle controls isn't really the best. Just last time I was testing a script with some people, and after a while the vehicle that the ped was controlling started to have major desync. It was driving for a bit, then quickly jumped to another location, etc. Now the difference with the server-sided function would be that it's fully controlled by the server, and therefore isn't affected by FPS for example. I've been able to achieve a very "hacky" workaround with elementData, and it does a decent job of keeping everything synced. I would, however, still like to see this function available server-side if possible. Regards, NeXTreme
-
If that is your svNone function, then you're trying to set a timer to call a client function from the server. You can only do that if you call an event to client script and set the timer there.
-
Yes. You can use setElementData to set the name for a ped. Then use dxDrawText on clientsided script and align it above the ped. Sorry, but no code from me
-
How to add an event: function doSomething(mode,returnedData) -- Do something with the "mode" and "returnedData" here end addEvent( "vehicleramps_PlayerSpawnedRamp",true) addEventHandler( "vehicleramps_PlayerSpawnedRamp", getRootElement(),doSomething)
-
Your problem might be in the mySQL database. Make sure the type of the upgrades column is TEXT. You should be fine by storing strings like "1158,1160" in a TEXT field, I've done it myself.
-
You can achieve the smooth effect with function like setElementRotation and setElementVelocity. Also take a look at these two functions, they're really useful with stuff like this. I've been using them for a few projects so far and they turned out great. https://wiki.multitheftauto.com/wiki/GetElementSpeed https://wiki.multitheftauto.com/wiki/SetElementSpeed
-
Well you weren't completely clear about what you want, imo... anyways... If you want to store vehicle upgrades into the mySQL database, you can convert a table of the current vehicle upgrades the vehicle has into a string and store that. Then, when you want to retrieve those upgrades and load them into a table again so you can add them to the vehicle, use the code I also posted. if data.upgrades then -- Assuming your data.upgrades is a string like "1158,1160" local upgrades = explode(",",data.upgrades) if upgrades then for upgrade in pairs( upgrades ) do addVehicleUpgrade( vehicle, upgrade ) end end end function explode(delimiter, text) local list = {}; local pos = 1 if string.find("", delimiter, 1) then outputDebugString("Delimiter matches empty string!") end while 1 do local first, last = string.find(text, delimiter, pos) if first then table.insert(list, string.sub(text, pos, first-1)) pos = last+1 else table.insert(list, string.sub(text, pos)) break end end return list end
-
It could work quite well with planes. Unfortunately I am using cars myself, so it would look unreal.
-
I would store the vehicle upgrades in mySQL database in a string, like this upgradeString = "1158,1160" For creating the string from a table of upgrades, use table.concat vehicleUpgrades = {1158,1160} upgradeString = table.concat(vehicleUpgrades,",") And to turn it back into a table upgradeString = "1158,1160" vehicleUpgrades = {} vehicleUpgrades = explode(",",upgradeString) function explode(delimiter, text) local list = {}; local pos = 1 if string.find("", delimiter, 1) then outputDebugString("Delimiter matches empty string!") end while 1 do local first, last = string.find(text, delimiter, pos) if first then table.insert(list, string.sub(text, pos, first-1)) pos = last+1 else table.insert(list, string.sub(text, pos)) break end end return list end
-
I'm also having a similar problem like this. Need a server-sided ped control function.... Well you could use a little hacky way, basically make the server estimate where the ped should be, and keep it syncing that position to all clients.
-
To see how close you are to an object, use getDistanceBetweenPoints3D ]To move objects around you could use moveObject