Jump to content

Saml1er

Retired Staff
  • Posts

    1,058
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by Saml1er

  1. Remember do not start the resources with those files or mta downloader will start downloading them but still this is not enough you also need to load the scripts using loadString. You'll also need sand boxes. Here's an example: local files = {txd = {}, model = {} } -- you need to insert all functions into rows like event handlers, timers and more if you also want to unload the scripts. local env = { } -- for storing functions and variables _engineImportTXD = engineImportTXD local engineImportTXD = function(txd,model) local model = _engineImportTXD(txd,model) or false if not model then return end table.insert(files.model, model) return model end _engineLoadTXD = engineLoadTXD local engineLoadTXD = function(txd) local file = _engineLoadTXD(res.."/"..txd) or false if not file then return end table.insert(files.txd,file) return file end -- loading scripts in client side local function LoadScript (commandstring) local notReturned local commandFunction,errorMsg = loadstring("return "..commandstring) if errorMsg then notReturned = true commandFunction, errorMsg = loadstring(commandstring) end if errorMsg then return end --- set the new environment to env table so variables including functions are not stored in global scope "_G" setmetatable(env, {__index = _G}) ----- Now copy all variables and functions to env table setfenv(commandFunction, env) results = { pcall(commandFunction) } if not results[1] then return end if not notReturned then local resultsString = "" local first = true for i = 2, #results do if first then first = false else resultsString = resultsString..", " end local resultType = type(results[i]) if isElement(results[i]) then resultType = "element:"..getElementType(results[i]) end resultsString = resultsString..tostring(results[i]).." ["..resultType.."]" end end end local function unLoadData ( ) for i,v in ipairs(files.model) do engineRestoreModel(v) end for i,v in ipairs(files.txd) do destroyElement(v) end env = {} end Usage: LoadScript ( script ) -- should be string and you can use fileRead to read the file from server and side and load them at client side. unLoadData ( ) -- unloading script
  2. ok and how can i create a costum downloader ? never did that before You can make it using fileRead fileGetSize fileCreate fileWrite triggerLatentClientEvent -- after reading file from server side then trigger a event with those data using this function and write those files on client pc ---- addEventHandler("onClientRender",root, function ( ) dxDrawRectangle dxDrawText -- rendering your custom downloader bar end )
  3. Nah, don't worry. Just like IYAMA said simply you need to take care of variables and amount of functions. If you check race resource you'll find it kinda alien language but still you'll see that they used meta methods and I think that's really useful in those cases I mean for example, if you have 2 tables and one has all your data stored in table1 but you want to have another table with same data then you can simply use __index and leave the table empty and when you are trying to access a variable from table2 and if it is not found in table2 then __index will be triggered and it will be accessed in table1 or if it not found then it will return nil which you already know. Many people don't really care about meta methods but if you check them how they help in accessing then you'll start loving it. They also help in rendering stuff. I usually use a table for storing data instead of multiple variables. You're code is fine though and more importantly nice work ^^
  4. is fight ko kahi aur jaga per continue kero. Discussion ki jaga hain ladne ki nahi. e.e
  5. Yes, it is. Shrink your images and try not to use too much mods but if you want to use mods then you can also make a custom downloader and players can download mods of their own choice.
  6. local sx,sy=guiGetScreenSize() local ax,ay = 1024,760 -- your screen resolution x and y, mine is 1024, 760 dxDrawImage(sx*(1795/ax),sy*( 522/ay),sx*( 106/ax),sy*( 111/ay), "images/player.png", 0, 0, 0, tocolor(255, 255, 255, 255), true) dxDrawText("The time is:", sx*(1760/ax),sy*( 21/ay),sx*( 1931/ax),sy*( 52/ay), tocolor(0, 0, 0, 255), sx*(0.80/ax), "bankgothic", "center", "top", false, false, true, true, false) A tip from me: Go to google.com and look for "How to google?"
  7. Saml1er

    Modules

    Learn C++. Case closed.
  8. local function blipJoin() addTeamBlip(source) for i,v in pairs (pBlips) do if i ~= source then setElementVisibleTo (v,source,true) end end end addEventHandler("onPlayerLogin",getRootElement(),blipJoin)
  9. addCommandHandler("turflist", function(p) local turfs = {} for k,v in pairs(turfPos) do local turfGang = executeSQLQuery("SELECT GangOwner FROM BoDTurfSystem WHERE Turfs=?", "Turf["..tostring(k).."]" ) for i=1, #turfs do if turfs[i][1] == turfs[k][1] then turfs[k] = {turfGang[1].GangOwner, turfs[k][2]+1} break else turfs[k] = {turfGang[1].GangOwner, 1} break end end end for i, v in pairs(turfs) do outputChatBox("Group:"..tostring(turfs[i][1]).." Value:"..tostring(turfs[i][2])) end triggerClientEvent(p, "openList", p, turfs) end )
  10. Saml1er

    SQL

    SQLite is very easy to use. I also had this kind of problem. So I just changed table name and everything was fixed. : )
  11. for l, i in pairs(turfs) do You are looping while table is empty which probably won't insert anything in it.
  12. Saml1er

    SQL

    Its SQL, you might've screwed up the table so simply drop this table and create a new one.
  13. local val = turfs["myGang"] or local val = turfs.myGang Both will work. EDIT: You're using ipairs. Which will get only integer keys and it will not count string keys. Use pairs.
  14. That will not work. setTimer ( function() for index, player in ipairs(getElementsByType("player")) do addTeamBlip(player) end end,10000,0 )
  15. Saml1er

    need help!

    Just put the map folder in server>mods>deathmatch>resources>YourMapFoldersHere
  16. Saml1er

    need help!

    Search for "[shooter]" in community.multitheftauto.com and you'll find tons of shooter maps with scripts.
  17. local elem = createPed (...) addEventHandler("onClientPreRender",root, function() dxDrawLine3D (...) dxDrawImage3D (...) -- custom function, search in wiki and you can this for rendering button images. It has an arguement where you can attach this image to an element, so simply attach it to ped and set ped alpha to 0 or whatever suits you end) addEventHandler("onClientClick",root, function() end) EDIT: Ah, I just found out that this is not what you were asking for.
  18. I don't know about variables if they can hack it but if a hacker can get access to ftp then yes they can and about element data . It's better to check. https://wiki.multitheftauto.com/wiki/On ... DataChange
  19. triggerClientEvent ( source, "housing:showInfo", source, "error", "You need an additional $".. convertNumber ( price - tonumber(getElementData(source,"Money") ) .."." ))
  20. guiGetText? hmmm..what will i use it for ? also ...how to change the color of the button, setalpha gonna make it more ...darker...but not with a exculative color, isn't it? guiCreateEdit? should i make a edit box and hide it? behind the image of .... ... ... login edit box? edit1 = guiCreateEdit (...) guiSetAlpha ( edit1, 0) This will make the edit box transparent.
  21. He meant this: local x,y = guiGetScreenSize() local ox,oy = 1920,1080 local Scale = (1920 / x ) * (1080 / y) local fontSize = 2.30/Scale
  22. Saml1er

    [Q&A]

    getPlayerAccount getAccounts setAccountData getAccountData table.sort
  23. Saml1er

    [Q&A]

    I made this one as simple as possible. local sx,sy = guiGetScreenSize () local messages = {"Test1","Test2","Test3" } local maximumRectangles = 9 local MoveMessagesInSeconds = 2 addEventHandler ("onClientPreRender",root, function () if #messages > 0 and #messages <= maximumRectangles then for i,v in ipairs (messages) do local i2,i3 = i* ( sx*0.035) ,i * ( sx*0.0175) -- i2 for dxDrawText and i3 for rectangles dxDrawRectangle(sx*(750/1024), (sy*0.5)+i3, sx*(240/1024) ,sy*( 20/1024), tocolor(0, 0, 0, 100), false) dxDrawText ( v, sx*0.74,sy*(15/768), sx,sy+i2, tocolor ( 255,255,255, 255 ),sx*( 1/1024), "default-bold","left","center",false,false,true,true ) end end end ) addEventHandler("onClientPlayerJoin",root, function () table.insert(messages, getPlayerName(source).." has joined") end ) setTimer ( function ( ) table.remove(messages,#messages) end, MoveMessagesInSeconds*1000,0)
×
×
  • Create New...