Jump to content

savour

Members
  • Posts

    45
  • Joined

  • Last visited

Everything posted by savour

  1. about variables/arrays, you can check the string with patterns before performing the loadstring() on it, check http://lua-users.org/wiki/PatternsTutorial for more information about it. for functions and events regulating, there is the wrapping way, which you can find in Bonsai's MGM, and the other way which i prefer to use, by adding debug hooks. it's extremely effective and gives you some extra abilities, check https://wiki.multitheftauto.com/wiki/addDebugHook
  2. if you're talking about the math, then i would suggest you to take a look at AMT (Arezu's Mapping Toolbox), it has some good math as a begin. also, you will find this event helpful: OnClientCursorMove
  3. so do we, also the picture isn't here
  4. savour

    xml vs json

    actually if you don't know both of them, i'd say go with XML for now. and here is an example
  5. صحيح كلامك لكن: النقط والفواصل عادي تكون بدون مسافات، لكن كل واحد على حسب الشكل اللي يحبه ، في ناس لو طول السطر معاها بتنزله لسطر تاني لكن المهم المسافة ماتئثر اذا قفلت الشيء اللي قبلها مثال hello = "Hello " .."MTA " .."Community" print(hello) --> Hello MTA Community + عند الارقام، لازم تكون في مسافة، قوس او انتر بعد الرقم عشان لايحسبها فاصلة عددية (نسيتها كمان بس حبيت اوضح) المتغيرات كتبتها كدا عشان تتفهم اسرع + احب اذا استخدمت متغير داخل اللوب احطه داخل اللوب عشان اقلل نسبة التداخل (عادة)، يعني اللوب كل مرة تشتغل بتشتغل على متغيرات نظيفة بالنسبة ل string.gmatch صحيح بترجعلك فنكشن وانا هنا نسيتها تماما، لكن الفنكشن اللي بترجعها بتكون شبيهة بفنكشكن اللوب pairs، والصراحة اول مرة اعرف ان الام تي ايه في فنكشن split فدايما كنت بابحث عن الباترن واستخدم gmatch ، شكرا على الاضافة، دا الكود السليم: function addZero (str) local newStr = "" local t = {} for digit in string.gmatch(str, "([^:]+)") do local tmpStr = "" if string.len(digit) == 1 then tempStr = "0"..digit else tempStr = tostring(digit) end table.insert(t, tempStr) end newStr = table.concat(t, ":") return newStr end وصاحب الموضوع اعتقد قالها عشان التوقيت يعني 5:6:20 مثلا تصبح 05:06:20، الفنكشن عندك اكثر شمولية لكن الصراحة ماشفت توقيت بينكتب بالفاصلة، شكرا ع التنبيه
  6. about the Boolean check, I think it would be good to store it as it is "true/false" but in a string value, then when you acquire it again transform in through this simple check dbResult = dbResult == "true" and true or false --that's a shortcut for dbResult = someRetrievedValue if dbResult == "true" then dbResult = true else dbResult = false end
  7. well, the way I prefer is tables and check in advance, like in your example, if the house is locked, it will be sent whenever the pickup is streamed and the layout stuff will be handled client-side in that exact moment without any delay, but if the house lock stats changed, the server will loop through the players in it's radius to let there client's know through events.
  8. savour

    Got Boolean

    before getting the player account you must get the player element itself, you can't do that directly through a string. you will need to use getPlayerFromName() local gang = getPlayerAccount(getPlayerFromName(name)) apply it to other getPlayerAccount() as well
  9. مفيدة فعلاً بس عندي تعليقين، ليه استخدمت string.rep وانت بتضيف صفر واحد؟ كمان اذا بتستخدمه بس للوقت، اذا استخدمته على صيغة كاملة مثل "5:3" بيحولها ل "05:3" فقط فمن الافضل تكون function addZero (str) local newStr = "" local t = {} for _, digit in ipairs(string.gmatch(str, ":")) do local tmpStr = "" if string.len(digit) == 1 then tempStr = tostring(0..digit) else tempStr = tostring(digit) end table.insert(t, tempStr) end newStr = table.concat(t, ":") return newStr end
  10. ### UPDATE ### Added a GUI to customize the functions, also some dxDraw functions were added, so now the chat wont be flooded anymore. screenshot: Hi there. About the resource: So basically this script gives you the ability to save, load and delete multiple warps, with an extra feature of calculating the actual map's duration, it's made for DM race gamemode (for mappers, map testers and trainers). it's pretty useful and accurate when it comes to loading warps, also time calculation is pretty reliable. --Commands: -- /sw Save Warp -- /lw Load Warp -- /dw Delete Warp -- /resetWarps Delete all warps -- /duration Calculat the map's duration if you ran into any trouble, checkout the github page: https://github.com/Sagr7/PositionSaver/ ..maybe it's already solved there! Download MTA:SA Resources Community: https://community.multitheftauto.com/index.php?p=resources&s=details&id=15931 Github: https://github.com/Sagr7/PositionSaver/ if you found any bug, feel free to leave a comment.
  11. basically, shaders means the drawings on the screen, with it you can do almost everything you can imagine with it, but you have to get some *knowledge*
  12. dbQuery returns a query handle and not the final usable value, instead, it pass it to a callBackFunction, in this case dbPoll can handle it also, it returns a table of the results which is you already put in there, means that if you want to get the colors of this vehicle id from the db you first must've inserted it there. try outputChatBox(vehicle:getData("veh:id")) and see the results, then try local result = dbPoll(dbQuery(mysql, "SELECT matrica FROM vehicle WHERE id=?", vehicle:getData("veh:id")), - 1) if(#result >= 1) then for i, v in ipairs(result) do outputChatBox("Result #"..i..": "..v) end else outputChatBox ( "No data were found that matching the query case" ) end if you got the last message that means you don't have any data stored in your database matching that given arguement
  13. "flag_type_dual"=true means that you can TWO guns at the same time, ak47 has it false already what i think you need is https://wiki.multitheftauto.com/wiki/SetWeaponProperty here: "flag_type_heavy" -- bool - Can't jump "flag_move_and_aim" -- bool - Can move and aim at same time "flag_move_and_shoot" -- bool - Can move and fire at same time "flag_aim_arm" -- bool - Uses other arm for aiming "flag_shot_slows" -- bool - Slows down (area effect)
  14. from what i see it should work, but after putting it in the notepad++ i noticed some weird font in the addDebugScript line, you added some Arabic symbols in that line before the quotes- ' - which is considered as "Unicode" symbols, can't be used in LUA outside the string quotes so you will need to re-write that line, try this: addDebugHook('postFunction', GHook, {'giveWeapon','setWeaponAmmo','takeWeapon'}) even when you paste it here in the "Code" insertion you will notice it as a huge dot or something, however you will need also to remove any writing decorators you recently added and so. also you can check for the Unicode characters with this website https://apps.timwhitlock.info/unicode/inspect
  15. just move the SQL function to the server-side script and pass the resulted table with the same triggerClientEvent
  16. the code says that if you leave the vehicle it will blow up, what you want is when you leave the sultan for example, all the sultan's in the game will be blown up? because i can see that you are talking about the vehicle's ID's are the same idk if you mean the model or what
  17. Here you go, I think this should work local sw, sh = guiGetScreenSize() fontSize = 8 local newsFont = dxCreateFont("lato.ttf", fontSize) -- default = 9 local sizeScale = 1 -- text size in scales local NEWS = { "This is overlord test1", "Ayowapodkjawp awpojkdpawdpow awpojkdpawdpow awpojkdpawdpow wapo jdawpodj apwowoap dowap wap[ojd wapdojawp oa jspodj opapoajs opsdj asd lkjawbd wpiaugd uipwadwapiug dpwaiug dp iudwapi udgpwad udgapiw d ipugea fuea[udh fw[ad iuoha[foiuh a aw[uoihauoi hdw[fdiuo ahw[ aw wa[ uohawf[ fuhiwa[ h oaiudhAyowapodkjawp awpojkdpawdpow wapo jdawpodj apwowoap dowap wap[ojd wapdojawp oa jspodj opapoajs opsdj asd lkjawbd wpiaugd uipwadwapiug dpwaiug dp iudwapi udgpwad udgapiw d ipugea fuea[udh fw[ad iuoha[foiuh a aw[uoihauoi hdw[fdiuo ahw[ aw wa[ uohawf[ fuhiwa[ h oaiudh", "Awesome" } function renderNews() addEventHandler("onClientRender", root, function() local height = 0 for _, v in ipairs(NEWS) do local sizeOfRect = (2*(dxGetFontHeight(sizeScale, newsFont)/1.75)) -- converts logical units to actual pixels height local lines = math.ceil(string.len(v)/(65/(sizeScale*(fontSize/9)))) if lines < 1 then lines = 1 end --Just to make sure, idk if it's necessary if lines > (dxGetFontHeight(sizeScale, newsFont)/1.75) then lines = lines + 1 end --Just to make sure, but i think it's necessary local h = lines * sizeOfRect dxDrawRectangle(sw-385, 95+height, 370, h+(5*sizeScale*(fontSize/9)), tocolor(0,0,0,155)) dxDrawText(v, sw-380, 90+height+(5*sizeScale*(fontSize/9)), sw-15, 100+h+height, tocolor(255,255,255,255), sizeScale, newsFont, "left", "center", true, true) -- align Y set to 'center' to be more flexible height = height + h + 10*sizeScale*(fontSize/9) end end) end addEventHandler("onClientResourceStart", resourceRoot, renderNews)
  18. yea sure, you will need to use the optional arguments of setPedAnimation, you have "time" and "interruptable", also you can use the setTimer function if that did not work. https://wiki.multitheftauto.com/wiki/SetPedAnimation
  19. you need to use the setElementVelocity after changing the position, not before. function Down (source ) local Sx, Sy, Sz = getElementVelocity (source) local Px, Py, Pz = getElementPosition (source) setElementPosition ( source, Px, Py - 80, Pz, false) setTimer(function() setElementVelocity ( source, Sx, Sy, Sz) end, 100, 1) end
  20. it seems like you've missed one "end" every if, for, while and there sub-statements must be closed with end, just like IIYAMA said, Here is the code with the missing end, you just compare it and you will know which one you've missed. function eventDeath(killer) local killed = getPlayerName (source) if ( killer ) then local killerPerson = getPlayerName (killer) if ( getElementData(killer,"Prison") == true ) or ( getElementData(source,"Prison") == true ) then for index,player in ipairs (getElementsByType("player")) do if ( getElementData(player,"Police") == true ) or ( getElementData(player,"AdminRank") >= 5 ) then outputChatBox(""..killerPerson.." Killed "..killed.." while he/she was in jail! ",player,255,255,255,true) end end end end end addEventHandler ( "onPlayerWasted", getRootElement(), eventDeath ) 
×
×
  • Create New...