
xXMADEXx
Members-
Posts
2,718 -
Joined
-
Last visited
Everything posted by xXMADEXx
-
Try using something like this: table.sort(PTable, function(a,b) return aend) (from http://lua-users.org/wiki/TableLibraryTutorial)
-
This wouldn't matter, because the "vipTeam" variable is only called when a player is logged in. Are there any errors in /debugscript 3?
-
Try using this, although, I didn't test it. -- Server: -- create your colshape function onColEvent( p ) if ( getElementType ( p ) == "vehicle" ) then p = getVehicleOccupant ( p ) end if ( not isElement ( p ) ) then return end if ( eventName == "onColShapeHit" ) then setElementData ( p, "isClientInProtectedArea", true ) else setElementData ( p, "isClientInProtectedArea", false ) end triggerClientEvent ( p, "onClientProtectedAreaEventChange", p, eventName ) end addEventHandler ( "onColShapeHit", CSSZ1, onColEvent ) addEventHandler ( "onColShapeLeave", CSSZ1, onColEvent ) -- client addEventHandler ( "onClientPlayerDamage", root, function ( ) if ( getElementData ( source, "isClientInProtectedArea" ) ) then cancelEvent ( ) end end ) addEvent ( "onClientProtectedAreaEventChange", true ) addEventHandler ( "onClientProtectedAreaEventChange", root, function ( e ) if ( e == "onColShapeHit" and not isRender ) then render = true addEventHandler ( "onClientRender", root, onClientRender ) elseif ( e == "onColShapeLeave" ) then render = false end end ) local isRender = false local sWidth,sHeight = guiGetScreenSize() function onClientRender ( ) if ( not isRender ) then removeEventHandler ( "onClientRender", root, onClientRender ) end dxDrawText("Protected Area Comp",sWidth*0.668, sHeight*0.952, sWidth*0.715, sHeight*0.997,tocolor(0,255,0,255),1.0,"pricedown","left","bottom",false,false,false) end
-
There's nothing wrong with that loop... Maybe something that's inside of it?
-
[SOLVED] Apply velocity to vehicle synced with server
xXMADEXx replied to Einheit-101's topic in Scripting
Yea you're right... I recommend using getTickCount() and sending the event every about 3 seconds to prevent major lag. -
Unless you know the basics of Lua and you're a math genius, you're probably not going to figure it out.
-
[SOLVED] Random info pulled from XML/Getting Players Veh ID
xXMADEXx replied to TheGamingMann's topic in Scripting
You need to put them into a table, and you can use this function: function table.rand ( tb ) local d = { } for i, v in pairs ( tb ) do table.insert ( d, v ) end return d [ math.random ( #d ) ] end Example: local data = { 900, 950, 364981, 3591, 5953, 1656, 5621 } local value1 = table.rand ( data ) local value2 = table.rand ( data ) local value3 = table.rand ( data ) outputChatBox ( table.concat ( { value1, value2, value3 }, " | " ) ) -
[SOLVED] Apply velocity to vehicle synced with server
xXMADEXx replied to Einheit-101's topic in Scripting
I would do something similar to this: local ButtonStates = { a = false, d = false } function bindKeys( k, s) if ( k == "a" ) then if ( s == "down" ) then if ( ButtonStates.a ) then return end ButtonStates.a = true addEventHandler("onClientRender",root,onRender_a) else endButtStates.a = false end elseif ( k == "d" ) then if ( s == "down" ) then if ( ButtonStates.d ) then return end ButtonStates.d = true addEventHandler("onClientRender",root,onRender_d) else endButtStates.d = false end end end bindKey ( "A", "both", bindKeys) bindKey ( "D", "both", bindKeys) function onRender_a ( ) if ( not ButtonStates.a or not isPedInVehcle(localPlayer) ) then ButtonStates.a = false return removeEventHandler("onClientRender",root,onRender_a ) end local c = getPedOccupiedVehicle ( localPlayer ) local sx, sy, sz = getElementRotation ( c ) setElementRotation ( c, sx, sy + 0.1, sz ) end function onRender_d ( ) if ( not ButtonStates.d or not isPedInVehcle(localPlayer) ) then ButtonStates.d = false return removeEventHandler("onClientRender",root,onRender_d) end local c = getPedOccupiedVehicle ( localPlayer ) local sx, sy, sz = getElementRotation ( c ) setElementRotation ( c, sx, sy - 0.1, sz ) end -
If you're looking for a long-term coder, it's not going to happen. Most experienced/good scripters have their own servers to look after.
-
Lol, thanks.
-
You had all sorts of errors... function chatdis( ) cancelEvent() outputChatBox("#E3E8B7The chat has been disabled by (localPlayerName)",source,255,0,0) addEventHandler("onPlayerChat",getRootElement(),chatdis) end function chaten( ) outputChatBox("#E3E8B7The chat has been enabled by (localPlayerName)",getRootElement(),255,0,0) removeEventHandler("onPlayerChat",getRootElement(),chatdis) end addCommandHandler("myname", function() local localPlayerName = getPlayerName(getLocalPlayer()) end ) addCommandHandler("chatoff",chatdis) addCommandHandler("chaton",chaten)
-
Thanks for the replies, everyone. Really appreciate it.
-
Thank the MTA team for the compiler, I just made the speed faster
-
Thanks!
-
Overview Hello everyone, and thank you for viewing my new compilers topic. So, today I was getting bored, so I started compiling some of my scripts and realized how long it takes, especially if you have an entire gamemode, and none of the scripts are compiled, and you need to compile them all before you upload them to the server. So, I decided to make a new compiler that loops threw your Lua files, and will compile them all at once. This can take a while to compile all of the scripts because it has to upload it to https://luac.multitheftauto.com/ then compile and redownload it, however, it will always be faster than compiling each file one by one. How to use it - First, you need to make sure that "Whole Server Compiler.exe" and "luac_mta.exe" are in the same directory (Preferably in a folder on your desktop) - Next, you need to copy your gamemode resources into another folder on your desktop (Desktop files are the only place luac_mta.exe can access your files that I found) - Open Whole Server Compiler.exe, and it will ask you to confirm and then it'll start to compile your scripts Information Download: http://www.mediafire.com/download/45soi ... mpiler.zip Source Code: http://www.mediafire.com/download/n6yea ... mpiler.zip Virus Scan: https://www.virustotal.com/en/file/5339 ... /analysis/ Interface language: English Programming Language: Visual Basic Last Update:21/03/2014 | 01:03 UTC-07:00 To-Do - Make the meta.xml files update when the program is ran Special Thanks - SoRa: He uploaded the original compiler interface, which I looked to the source code of to learn how to use luac_mta.exe, but didn't take any of the code - MTA Team: Creating the compiler Notice This application has been tested on the following: - Windows 8.1 (64 bit) - Windows 7 (64 bit) If you have a different system/operating system that isn't listed, please send me a private messages telling me your operating system and if the application works.
-
Also, SolidSnake14 isn't the only scripter on this forum.
-
Try this function toggleInvis ( thePlayer ) if getElementAlpha( thePlayer ) == 0 then setElementAlpha ( thePlayer, 255) else setElementAlpha ( thePlayer, 0 ) end end addCommandHandler ( "god", toggleInvis )
-
Well, recently I've also been learning C#. I made a pretty cool program that sorts your music, here is the source code if you want to learn off of it using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.IO; using System.Collections; namespace Music_Sorter { class Program { public static void startApplication(Boolean doConfigs) { String user = Environment.UserName; String directory = "C:\\Users\\" + user + "\\Music"; if (doConfigs) { Console.Title = "Music Organizer - " + user; Console.WriteLine("Please be sure all of your .mp3 files are in your music directory... When you're ready, press any key. (Music directory: { 0 })", directory); Console.ReadKey(); } Console.WriteLine("\nGathering music..."); string[] ListFiles = Directory.GetFiles(directory, "*.mp3"); if (ListFiles.Length == 0) { Console.WriteLine("No music files found. Press any key to continue."); Console.ReadKey(); Environment.Exit(0); return; } Console.WriteLine("The MP3 files that were found are ("+ListFiles.Length+" songs): "); for (int i = 0; i < ListFiles.Length; i++) { Console.WriteLine(ListFiles[i].ToString()); } Console.WriteLine("\n\nPlease type Y to continue, or R to refresh the list. Any other key will kill the application."); String text = Console.ReadLine().ToLower(); if (text != "y" && text != "r") { Console.WriteLine("Killing application..."); Environment.Exit(0); return; } if (text == "r") { Console.WriteLine("\n\n\n\nRefreshing list..."); Program.startApplication(false); return; } Console.WriteLine("Continuing with orgaization...."); int unknownSong = 0; ArrayList unknownSongs = new ArrayList(); unknownSongs = new ArrayList(); for (int i = 0; i < ListFiles.Length; i++) { TagLib.File file = TagLib.File.Create(ListFiles[i]); //String genre = file.Tag.genre; string[] artists = file.Tag.Artists; String Album = file.Tag.Album; String artist = ""; String title = file.Tag.Title; Boolean isUnknown = false; for (int i2 = 0; i2 < artists.Length; i2++) { if (i2 == 0) { artist = artists[i2]; } else { artist = artist + ", " + artists[i2]; } } if (title == null || title.Replace(" ", "") == "") { title = "Unknown (" + unknownSong + ")"; unknownSong++; isUnknown = true; } if (artist == null || artist.Replace(" ", "") == "") { artist = "Unknown"; isUnknown = true; } if (Album == null || Album.Replace(" ", "") == "") { Album = "Unknown"; isUnknown = true; } foreach (char c in Path.GetInvalidFileNameChars()) { Album = Album.Replace(c, '_'); title = title.Replace(c, '_'); artist = artist.Replace(c, '_'); } String path = directory + "\\Organized Music\\" + artist + "\\" + Album; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = path + "\\" + title; if (File.Exists(path + ".mp3")) { int whileID = 0; String tempPath = "Unknown" + path; while (File.Exists ( tempPath + ".mp3" ) ) { //if (whileID == 0) //{ tempPath = path + "(" + whileID + ")"; //} whileID++; } path = tempPath; } Console.WriteLine("\n\nMoving: " + ListFiles[i] + "\nTo: " + path + ".mp3"); File.Move(ListFiles[i], path + ".mp3"); if (isUnknown) { unknownSongs.Add(path+".mp3"); } } Console.WriteLine ( "\n\n\n" ); if (unknownSongs.Count > 0) { Console.WriteLine(unknownSongs.Count + " songs failed to be identified. List: \n"); for (int i = 0; i < unknownSongs.Count; i++) { Console.WriteLine(i + ". " + unknownSongs[i]); } } else { Console.WriteLine("All songs have been successfully organized!"); } Console.ReadKey(); } static void Main() { startApplication(true); } } } You have to import this library though.
-
You can check the element data (or whatever you set to the players job), and if they have a job, you can use this script that I made for personal use: local confirm = {} local callback = nil local args = nil local sx, sy = guiGetScreenSize ( ) confirm.window = guiCreateWindow( ( sx / 2 - 324 / 2 ), ( sy / 2 - 143 /2 ), 324, 143, "Confirm", false) confirm.text = guiCreateLabel(10, 35, 304, 65, "", false, confirm.window) guiSetVisible ( confirm.window, false ) guiSetFont(confirm.text, "default-bold-small") guiLabelSetHorizontalAlign(confirm.text, "left", true) guiWindowSetSizable ( confirm.window, false ) confirm.yes = guiCreateButton(10, 100, 108, 25, "Confirm", false, confirm.window) confirm.no = guiCreateButton(128, 100, 108, 25, "Deny", false, confirm.window) function onConfirmClick( ) if ( source ~= confirm.yes and source ~= confirm.no ) then return end removeEventHandler ( "onClientGUIClick", root, onConfirmClick ) guiSetVisible ( confirm.window, false ) local v = false if ( source == confirm.yes ) then v = true end callback ( v, unpack ( args ) ) args = nil callback = nil end function askConfirm ( question, callback_, ... ) if ( not callback_ or type ( callback_ ) ~= "function" ) then return false end guiSetVisible ( confirm.window, true ) guiSetText ( confirm.text, tostring ( question ) ) callback = callback_ args = { ... } addEventHandler ( "onClientGUIClick", root, onConfirmClick ) guiBringToFront ( confirm.window ) return true end e.x. askConfirm ( "Would you like to quit your current job?", function ( bool ) if not bool then return end outputChatBox("You have quit your job!") end )
-
Did you port forward? Try the command "openports" in console.
-
I've Checked interpolateBetween's Examples but Really long and didn't understand them well, could you give an simple example ? please. inerpolateBetween is kind of an advanced function... This is what I use in my login though: local intData = { start = { 0, 0 }, _end = { 485, 231 }, startTime = nil, endTime = nil, alpha = 0 } -- this is in onClientRender if not intData.startTime then intData.startTime = getTickCount ( ) intData.endTime = getTickCount ( ) + 1500 intData.isDone = false end if ( isOpen ) then local now = getTickCount ( ) local elapsedTime = now - intData.startTime local duration = intData.endTime - intData.startTime local progress = elapsedTime / duration local start = intData.start local _end = intData._end local w, h, _ = interpolateBetween ( start[1], start[2], 0, _end[1], _end[2], 0, progress, "OutBounce" ) and to make the shadow when the cursor is over DX text, you can use: getCursorPosition check the x and y axis, and if it's in the text, then draw a dx text in the background, behind the current text. https://community.multitheftauto.com/index.php?p= ... ls&id=7970 -> This resource may help you
-
-- server function loginPlayer(username,password) if not (username == "") then if not (password == "") then local account = getAccount ( username, password ) if ( account ~= false ) then logIn (source, account, password) exports["TopBarChat"]:sendClientMessage ("#0000FF* #FFFFFFYou have sucessfully logged in!",source,255,255,255,true) triggerClientEvent ( source, "onClientPlayerLoginFromServer", source ) else exports["TopBarChat"]:sendClientMessage ("#0000FF* #FFFFFFError! Wrong username and/or password!",source,255,255,255,true) end end end end addEvent("onRequestLogin",true) addEventHandler("onRequestLogin",getRootElement(),loginPlayer) -- client addEventHandler("onClientGUIClick",RegisterLogin_Window, function(b) if b == "left" then if source == LoginButton then username = guiGetText(LoginUsername) password = guiGetText(LoginPass) triggerServerEvent("onRequestLogin",getLocalPlayer(),username,password) xmlFileHandler() end end end) addEvent("onClientPlayerLoginFromServer",true) addEventHandler("onClientPlayerLoginFromServer",root,function() showCursor ( false ) guiSetVisible ( theLoginWindow, false ) end )
-
Make sure to read the forum topic