Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 05/08/17 in Posts

  1. I'll give you some functions, if you don't know how to do it, just reply. First, you'll have to use getCursorPosition. If you have the cursor's position, you have to use some math, to calculate if that position is between the text's pos and the text's pos + width. If it's, you can just output the current text in your forcycle.
    2 points
  2. When are you trying to use this function?
    2 points
  3. Debugging Do you know what debugging is? You might think you do, but unfortunately (in my opinion) only ~15% of the scripters in the community do know the full definition of it. Many people think that debugging code is the same as looking in to the Debug Console and waiting for warning + errors to show up. That's indeed debugging and yet it never provide all information you need to build your scripts. It only can say what goes wrong at a certain line. With other words, the Debug Console by default will only show a limited amount of mistakes you have made in your code. So what is next? You fixed all warnings and errors and yet it doesn't work. You start with making your code visible! I guess 70% would think: Making code visible? Ehhh how??? Let me write it down a little bit different: By using Debug Information making the behaviour of the code visible. I guess 50% would think: Eh what? behaviour of code????? Let me give you an example. Example: (1) outputDebugString("the script has started") -- < this is a debug line if true then outputDebugString("code works here") -- < this is a debug line else outputDebugString("code shouldn't be working here") -- < this is a debug line end Debug console "the script has started" "code works here" The debug console is NOT information for players, it is information for YOU developers! BTW this is a debug line outputDebugString("test") -- < this is a debug line In this case it is just a piece of code that shows information in the debug console. Example: (2) local playerName1 = "snake1" local playerName2 = "cow" if playerName1 == playerName2 then outputDebugString("players playerName1 and playerName2 do share the same name. Name: " .. tostring(playerName1)) -- < this is a debug line else outputDebugString("players playerName1 and playerName2 do NOT share the same name. playerName1: " .. tostring(playerName1) .. ", playerName2: " .. tostring(playerName2)) -- < this is a debug line end Debug console "players playerName1 and playerName2 do NOT share the same name. playerName1: snake1, playerName2: cow" Easy isn't? The concept behind this debug method is to see what the code does / doesn't execute. Is this method handy? It is actually the very basic of debugging, for code that doesn't contain any errors/warnings. I would say it is handy and it is a very powerful method too. It is also handy for people who do not know how to script. If you want people to help you with your code, but you do not know what is wrong with it. You can add those debug lines and point out to where the code stops working. This will make it more efficient for you and the scripter to work out the problem, because the scripter knows where to look. How much debug lines do you have to add to your script? 1? 10? 100? 1000? You could start with around 100 debug lines and as you learn how to script, you can reduce it to 10+ debug lines. Too much debug lines are not always good, because they will give you too much information and it will cost time to manually filter them. So I recommend you to remove some of them afterwards. When you are finished with the tested code, you can remove 90+% of them. Feel free to disable them instead of removing them, if you know that you are going to need them again. For complex code, I use around 25 debug lines, SO DON'T HOLD BACK! Render events It is strongly recommended to remove debug lines that are executed on onClientRender/render events when you are finished with your code. Because that can have influence on the smooth fps.(It will not drop much of the fps, but it can make it feel unsmooth) Clearing the debug console? /cleardebug Know your tools: outputDebugString -- Show a message on the Debug Console bool outputDebugString ( string text, [ int level=3, int red=255, int green=255, int blue=255 ] ) --- outputConsole -- Show a message on the F8 panel. bool outputConsole ( string text ) -- client bool outputConsole ( string text, [ element visibleTo=getRootElement() ] ) -- server --- inspect -- Convert one mixed value to a string. string inspect ( mixed var ) --- print -- Show a message on the terminal / serverwindow / Debug Console. bool print ( string var1[, string var2, string var3...] ) --- tostring() -- Convert a value in to a string. (but for objects/elements, inspect works better) --- iprint -- Show a message on the terminal / serverwindow / Debug Console (convert multiple mixed values automatic to string, no need for tostring or inspect) bool iprint ( mixed var1[, mixed var2, mixed var3...] ) --- outputChatBox -- You can also debug with outputChatBox (even though it is less efficient) bool outputChatBox ( string text [, int r=231, int g=217, int b=176, bool colorCoded=false ] ) -- client bool outputChatBox ( string text [, element visibleTo=getRootElement(), int r=231, int g=217, int b=176, bool colorCoded=false ] ) -- server Debug message levels 0: Custom message 1: Error message 2: Warning message 3: Information message (default) Addition by @Hale https://wiki.multitheftauto.com/wiki/OutputDebugString Advanced tools: local line = debug.getinfo(1).currentline -- get the line of the script where the code has been executed. 1 = current function. (can be useful if you want to get the line where this function has been called from) https://www.lua.org/pil/23.1.html WIKI MTA: WIKI MTA debugging tutorial/information. https://wiki.multitheftauto.com/wiki/Debugging
    1 point
  4. Hello. Scince one year I want to publish this smartphone here. There is awesome smart with some base functions, what appeared in previous version. But customizing in settings now removed to make system style more interesting and minimalistic. Also removed lockscreen, because it was useless. What can you do basically with this phone? - Chatting with another players on the server, and send them stickers - Listen music by URL or your local, and switch timeline of the track (progressbar clickable) - Calculate something. Now calculator has history of calculations. - With application "Passport" you can see some information about you. Created for RP modes, but I dont know nothing about RP, and created it just for fun. - In settings you can change desktop image, change System Language [NEW], and read information about developers. - When phone updating, admins can check for updates phone on the air in system settings. Its available in "About" menu, on bottom of app - green text with current version as build. Of course, this resource has API for developers. With it you can: - Create your own applications for phone - Edit some phone settings - Add your own stickers for messenger - Add your own desktop images (276x445px) - Add your own system translations. In file "language.lua" you can find example and there you can add in table your prefered languages. - Manage notifications and etc. There are some pictures of system: Download: GitHub I would like to apologize about my code. Sometimes this is not readable, because it was written about year ago, when I was at school . I wont to optimize this working code, bcs I'm too lazy New Video: Demo (2016): Functions, what you can use to modify your system:
    1 point
  5. Forest generator 1.0.0 ---------------------------------------------------------- ---------------------------------------------------------- Use /forestgen <frency> (frequency is distance between trees) ---------------------------------------------------------- Settings fg_client.lua / generatorData - Generation settings fg_server.lua / treesList - Object settings Forest exported to .map file in root directory of script ---------------------------------------------------------- Download: https://community.multitheftauto.com/index.php?p=resources&s=details&id=14680
    1 point
  6. So, you'll have to use the returned variables. You have to add the 2 numbers to the position where you draw the image of the map.
    1 point
  7. Nem tudom miért veszi ki, mert annak köze nincs a handlingFlags attributehoz. De ezzel működik. addCommandHandler("changetire", function(thePlayer, cmdName, newValue) if isPedInVehicle(thePlayer) then local pVeh = getPedOccupiedVehicle(thePlayer) local vehUpgrades = getVehicleUpgrades(pVeh) local hasHydra = false for i, k in ipairs(vehUpgrades) do if k == 1087 then hasHydra = true break end end local defHandling = string.reverse(string.format("%08x", getVehicleHandling(pVeh)["handlingFlags"])) local newHandling = string.sub(defHandling, 0, 2) .. newValue .. string.sub(defHandling, 5) outputChatBox("Default handling: " .. "0x" .. defHandling) outputChatBox("New handling: " .. "0x" .. newHandling) setVehicleHandling(pVeh, "handlingFlags", tonumber("0x" .. string.reverse(newHandling))) addedH = hasHydra and addVehicleUpgrade(pVeh, 1087) or false outputChatBox(addedH and "Readded hydraulics." or "Didn't have hydraulics.") end end)
    1 point
  8. executeSQLQuery ( "CREATE TABLE IF NOT EXISTS `aTalis_Anti` ( serial , by ) " ); addEvent("serial",true) addEventHandler("serial",root, function (aName) local aResult = executeSQLQuery ( "SELECT * FROM `aTalis_Anti` WHERE serial=? " ,getPlayerSerial(source)) if ( aResult and #aResult == 0 ) then executeSQLQuery ( "INSERT INTO `aTalis_Anti` ( serial , by ) VALUES ( ? , ? )" ,getPlayerSerial(source),aName ); outputChatBox("تم اضافة السريال",source,255,255,0,true) else outputChatBox ( "هذا السريال موجود مسبقا" , source,255,255,0) end end ) addEvent ( "getSerials" , true ) addEventHandler ( "getSerials" , root , function ( ) local aResult = executeSQLQuery ( "SELECT * FROM `aTalis_Anti`" ) if ( aResult and type ( aResult ) == "table" and #aResult ~= 0 ) then triggerClientEvent ( source , "checkserial" , source , aResult ) ; end end );
    1 point
  9. Ahh, és tényleg, egy kicsit várj, megcsinálom. Nézd meg ezt. addCommandHandler("changetire", function(thePlayer, cmdName, newValue) if isPedInVehicle(thePlayer) then local pVeh = getPedOccupiedVehicle(thePlayer) local defHandling = string.reverse(string.format("%08x", getVehicleHandling(pVeh)["handlingFlags"])) local newHandling = string.sub(defHandling, 0, 2) .. newValue .. string.sub(defHandling, 5) outputChatBox("Default handling: " .. "0x" .. defHandling) outputChatBox("New handling: " .. "0x" .. newHandling) setVehicleHandling(pVeh, "handlingFlags", tonumber("0x" .. string.reverse(newHandling))) end end)
    1 point
  10. If you wanna enable the 50 (skinID) to the player whose account ID is 2, then you just do local skinTable = { --[SKINID] = EXCEPTION [301] = 1, [50] = 2 }
    1 point
  11. showChat ( not isChatVisible ( ) )
    1 point
  12. Does it output the message? Adding a timer made the whole thing work. local skinTable = { --[SKINID] = EXCEPTION [301] = 1 } addEventHandler("onElementModelChange", getRootElement(), function(oldModel) local newModel = getElementModel(source) if skinTable[newModel] then if getElementData(source, "acc.accID") ~= skinTable[newModel] then outputChatBox("That model is prohibited to all users except one.", source) setTimer(setElementModel, 50, 1, source, oldModel) end end end)
    1 point
  13. Yes, it does ASSUME, you can still use it on client-side as far as I know.
    1 point
  14. Note: The client side version of getPlayerSerial has been deprecated as it can return the wrong value for some players, and is potentially insecure. The following article assumes that the function is serverside only.
    1 point
  15. function msg() local x = getPlayerSerial(getLocalPlayer()) if x == "633DB08BE0185007B57225507C51C3A2" then print("works") print(x) else print("don't works") end end addEventHandler("onClientResourceStart", root, msg) You should read tutorials about programming before trying it out. The getPlayerSerial function returns a string, so you have to compare it with a string. Print is a function, calling functions are done by using parenthesis.
    1 point
  16. https://wiki.multitheftauto.com/wiki/SetAmbientSoundEnabled
    1 point
  17. local sX, sY = guiGetScreenSize() local mapW, mapH = 500, 500 local mapX, mapY = (sX-mapW)/2, (sY-mapH)/2 local pixelW = mapW/6000 local pixelH = mapH/6000 local testX, testY = 0, 0 function calculateScreen(inX, inY) return (inX+3000)*pixelW, math.abs((inY-3000))*pixelH end wX, wY = calculateScreen(testX, testY) outputChatBox(wX .. " " .. wY) Try this.
    1 point
  18. Ahh, lol. I misunderstood the post. For more understanding I'd create a new variable which would indicate how many pixels one unit in GTA is. And then just use that to calculate everything.
    1 point
  19. So you have onResourceStart events. Use resourceRoot instead of root.
    1 point
  20. "root" and getRootElement are the same. It's a predefined variable in MTA. What do you mean it starts this one too?
    1 point
  21. I mean, I dont think you want to return anything. function detectClicks() for i, pos in pairs(t) do if isMouseInPosition(pos[2], pos[3], pos[4], pos[5]) then outputChatBox(pos[1]) return end end end addEventHandler("onClientClick", root, detectClicks) But yours should work too.
    1 point
  22. Use return after the outputChatBox, the reason why, is because if you think about it. You found the one text you clicked on, and there won't be anymore, so if you stop the cycle there, you'll save some performance and a micro amount of time.
    1 point
  23. I suppose you have different y position for each text. Try to imagine what your script does. If you don't understand this, just reply.
    1 point
  24. Use CTRL+F and search for tocolor or RGB.
    1 point
  25. Yep, awesome. Do you need further help?
    1 point
  26. Just create a backup, and try to do it. If you are stuck somewhere or you get errors, ask here.
    1 point
  27. Using a forcycle, where you cycle through all of the text with it's x, y position and it's width, height.
    1 point
  28. NeXuS™ presents dxLib Introduction You want to work with dx functions, but you don't understand them? This is a script for you. You can create panels created by dx functions just like with GUI functions. Status IN DEVELOPMENT Sorry guys, its not finished yet, so I'm not publishing it. This is just a show off, that you'll get this in weeks. Whats done already Screenshots Syntax
    1 point
  29. فنكشنك مهمل استخدم executeSQLQuery
    1 point
  30. Check ballthrower resource from the community, some sweet throwing code there
    1 point
  31. I don't think onPlayerLogout gets called when onPlayerQuit happens. If you use onPlayerLogout and use the function which is wrote above, it'll always be the "guest" user, because the logout has been already done. function playerAccountSetData(account, dataname, amount) account:setData(dataname, amount) end addEventHandler("onPlayerLogout", getRootElement(), function(oldAcc) playerAccountSetData(oldAcc, "money", getPlayerMoney(source)) end) Try this.
    1 point
  32. Just use OOP, it's much easier with it.
    1 point
  33. ما اقصد الإهانة بس التصميم خبصة مرة انت تعرف جيو خلك عليه ولا تعلم الدي إكس زيين لا تسوي أزرار ب صورة واصل إلى الأمام
    1 point
  34. Next time use the Slothbot's WIKI Page, it'll help a lot. addEvent("onBotWasted", true) addEventHandler("onBotWasted", root, function(killer) if getElementModel(source) == 180 or getElementModel(source) == 181 then addPlayerBossKills(killer) end end) Try this.
    1 point
  35. Same for me, if this is an intended feature, this should be removed.
    1 point
  36. You should try to fix it, on your OWN and if you are stuck somewhere, we'll help ya. We won't make you the whole script if you don't even try. Downloading scripts and asking the community to edit it for you is not called scripting at all.
    1 point
  37. you can create your own script to restart the server with callRemote which it will make you able to call your local host to call the restart command in your game panel
    1 point
  38. is it really that hard to restart your mta server manually
    1 point
  39. Same for me, that's driving me crazy.
    1 point
  40. https://wiki.multitheftauto.com/wiki/Element/Shader Para aplicarlas o asi puedes dibujarlas como una imagen o usar https://wiki.multitheftauto.com/wiki/EngineApplyShaderToWorldTexture
    1 point
  41. ما تحسها طقطقه ولا وشو؟ ركز بالكلام قبل لا تقوله +_+ وايضا وش بستفيد لو تعلم اللغه ولا وش بنظر فيه بالعكس يشهد ربي اتمناله الخير ركز بكلامك قبل لا تقوله 2 مره
    1 point
  42. بعرف اخي عمري ماطلبت جاهز مشكور GUIEditor = { edit = {} } addEventHandler("onClientResourceStart", resourceRoot, function() window = guiCreateWindow(507, 307, 421, 170, "رجاء ادخال كلمة مرور", false) guiWindowSetSizable(window, false) Confirm = guiCreateButton(9, 124, 139, 36, "موافق", false, window) guiSetProperty(Confirm, "NormalTextColour", "FFFEEF00") Close = guiCreateButton(272, 126, 139, 34, "الغاء", false, window) guiSetProperty(Close, "NormalTextColour", "FFFEEF00") GUIEditor.edit[1] = guiCreateEdit(9, 62, 402, 46, "رجاء قم بكتابه كلمة المرور هنا....!", false, window) end ) ممكن مساعدة ماعرفت ابرمجها بدي لما ايكون رمز صح ينقل الاعب الي مكان انا محدده واذا كان رمز خطا يقول له رمز خطا ممكن فنشنكات
    1 point
  43. اظن باني رايته واطن اني رديت عليه صح؟
    1 point
  44. Great tutorial, although it should be common sense... But I'm amazed by the number of people that come to the forum looking for help without any type of debug done by themselves... should be a sticky post.
    1 point
  45. Coucou les amis! J'ai, pour ceux qui ne le savent pas, une chaîne YouTube où j'expose mes créations et comment je me débrouille en développement sur MTA SA. J'ai sorti une vidéo il y a pas si longtemps sur mon nouveau système réalisé pour une commande. "Matos & Weapon Creation System" dont vous pouvez retrouver la vidéo ci-dessous: Pour suivre mes autres scripts, je vous invite à vous abonnez, en attendant vous pouvez consulter la liste de tout ces scripts via ma playlist que je met à jour régulièrement. Playlist: https://www.youtube.com/playlist?list=PLcX5XBPSkEU2dn2iLzzEuhQXlBQH2Tteg Ces scripts sont la pour que vous donnez votre avis afin que je puisse m'améliorer sur ma façon de développer. A la prochaine!
    1 point
  46. مافي شي خطأ بس انت نسيت تحط هذا الحدث changeGridListToPlayersAround ( gridlist1, 1, 5 )
    0 points
×
×
  • Create New...