Jump to content

Miika

Members
  • Posts

    253
  • Joined

  • Last visited

Everything posted by Miika

  1. Hi, I got this type of error in my garage saver script: ERROR: garagesystem\server.lua:6: attempt to call field 'insert' (a nil value) Part of my code: local vehicle = getPedOccupiedVehicle(hitElement) local handlingsTable = {} for i=1, #handlingtable do local dvalue = getVehicleHandling(vehicle)[handlingtable[i]] table.insert(handlingsTable, dvalue) end xmlNodeSetAttribute(datanode, "handling", toJSON(handlingsTable)) Table: handlingtable = { "mass", "turnMass", "dragCoeff", "centerOfMass", "percentSubmerged", "tractionMultiplier", "tractionLoss", "tractionBias", "numberOfGears", "maxVelocity", "engineAcceleration", "engineInertia", "driveType", "engineType", "brakeDeceleration", "brakeBias", "ABS", "steeringLock", "suspensionForceLevel", "suspensionDamping", "suspensionHighSpeedDamping", "suspensionUpperLimit", "suspensionLowerLimit", "suspensionFrontRearBias", "suspensionAntiDiveMultiplier", "seatOffsetDistance", "collisionDamageMultiplier", "monetary", "modelFlags", "handlingFlags", "headLight", "tailLight", "animGroup" }
  2. Hi, I have almost completed my SQLite based house system. But i want to create house blips showing only in radar with short distance to not make "blip spam" in F11 map. So is this possible to make or do i need to give up this thing?
  3. Try this: function vctint(thePlayer) if not (isPedInVehicle(thePlayer)) then setElementInterior(thePlayer, 5) setElementDimension(thePlayer, 1) setElementPosition(thePlayer, 225.0107421875, -8.0927734375, 1002.2109375) setElementRotation(thePlayer, 0, 0, 90, "default", true) setCameraTarget(thePlayer, thePlayer) end end addEventHandler("onMarkerHit", vctIn, vctint) Btw, you cannot use setCameraTarget without giving the taget.
  4. New question How can i get single column name and output it to chatbox in given row? I mean something like this: for i=1, getFreeID() do local result = dbExec(database, "SELECT * FROM houselist WHERE id = ?", i, houseList) outputChatBox(result[i]) end i is the row number and i want to get value from houseList column and then output it to chabox.
  5. Got it work, thank you very much!
  6. Hi, I'm currently making SQLite based house system, it's first time when i work with databases. So how can i get number of database items? I need to get house id and put it to pickup data. My code: function newHouse(int, x, y, z, r, name, price) pic = createPickup(x, y, z, 3, 1273, 0) -- id = ??? <---- i need to count, how many items there are inside the table setElementData(pic, "id", id + 1) setElementData(pic, "name", name) setElementData(pic, "status", "sale") setElementData(pic, "price", price) setElementData(pic, "int", int) dbExec(database, "INSERT INTO houselist (houseName, houseOwner, housePrice, houseForSale, housePosition, houseInterior) VALUES (?, ?, ?, ?, ?, ?)", tostring(name), "", tonumber(price), "No", x .. ", " .. y .. ", " .. z .. ", " .. r, int) triggerClientEvent (client, "closeGUI", client) end addEvent("houses_new:createNewHouse", true) addEventHandler("houses_new:createNewHouse", resourceRoot, newHouse) My table: database = dbConnect("sqlite", "house_database.db") dbExec(database, "CREATE TABLE IF NOT EXISTS 'houselist'(id INTEGER PRIMARY KEY, houseName TEXT, houseOwner TEXT, housePrice bigint(255), houseForSale TEXT, housePosition TEXT, houseInterior INT)" ) I hope you understand something what i mean
  7. Miika

    Help.

    I forgot one thing from script, try this: function addNotification(thePlayer, text, _type) if (thePlayer and text and _type) then triggerClientEvent(thePlayer, 'addNotification', thePlayer, text, _type); end end
  8. Miika

    Help.

    Test it. function addNotification(thePlayer, text, _type) if (thePlayer and text and _type) then triggerClientEvent(player, 'addNotification', thePlayer, text, _type); end end
  9. Thank you, this tutorial helped me alot!
  10. Hi, I just started working with vehicle tuning garage script. I want to make dx navigation so i need to use sub tables to make it easier. How can i use values from sub tables, if my table looks something like this: table = { "Exhaust", {"1018", "1019", "1020", "1021", "1022"}; {"exh_b_ts", "exh_b_t", "exh_b_l", "exh_b_m", "exh_b_s"}; {"Upswept", "Twin", "Large", "Medium", "Small"}; "Rims" {"1025", "1073", "1074", "1075"}; {"wheel_or1", "wheel_sr6", "wheel_sr3", "wheel_sr2"}; {"Offroad", "Shadow", "Mega", "Rimshine"}; }
  11. And your have more features and better way in code when i looked
  12. Oh, i haven't seen this before.. My bad
  13. I just gave faster method how i do all my gridlist things
  14. This is example, havent tested, post errors here I would do it with table, easier than adding else if every time: table { --text, img src --Just add row like this for more {"rick click", "img/rick.png"}; {"daryl click", "img/daryl.png"}; } function clickingClothesShop () if(source == ClothesShopGuiGridlist) then -- Rick local row, col = guiGridListGetSelectedItem(ClothesShopGuiGridlist) guiCreateStaticImage(20, 200, 100, 100, table[row+1][2], false) --Uses file location from table outputChatBox(table[row+1][1]) --Outputs "rick click" end end addEventHandler ( "onClientGUIClick", root, clickingClothesShop ) GUI: ClothesShopGuiGridlist = guiCreateGridList(34, 77, 257, 295, false, ClothesShopGuiWindow) guiGridListAddColumn(ClothesShopGuiGridlist, "Clothes", 0.9) for i=1,#table do guiGridListAddRow(ClothesShopGuiGridlist) guiGridListAddRow(ClothesShopGuiGridlist) guiGridListSetItemText(ClothesShopGuiGridlist, 0, 1, table[i][1], false, false) guiGridListSetItemColor(ClothesShopGuiGridlist, 0, 1, 9, 139, 0, 255) end
  15. So people are asked me to make to make backflip / frontflip sciprt. I haven't seen any else scripts that works with arrow keys, so i made this little script. Press arrow_down to make a backflip and arrow_up to make frontflip! Video tells more than 1000 words Tell me what you think about this script Download link: https://community.multitheftauto.com/in ... s&id=12903 You're free to use and edit, but do not remove the credits
  16. Maybe this: add to start: addEventHandler("onPlayerJoin", root, function() local team = getPlayerTeam(source) local tr, tg, tb = getTeamColor(team) setPlayerNameTagColor(tr, tg, tb) end ) Mute message: local team = getPlayerTeam(source) local tr, tg, tb = getTeamColor(team) outputChatBox("#ffffff"..getPlayerNametagText(source).. "" .. RGBToHex(tr, tg, tb) .. " has been muted for spam", getRootElement(), 255, 255, 0,true) Then add this to somewhere to script: function playerChat(message, messageType) if messageType == 0 then cancelEvent() local r, g, b = getPlayerNametagColor(source) outputChatBox(RGBToHex(r, g, b) .. "" .. getPlayerNameTag(source)..": ".. message, root, r, g, b, true) end end addEventHandler("onPlayerChat", root, playerChat) And you need this function every script you use colored messages: function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end
  17. So do you want team color to message or team color to name or both? Btw that tocolor was mistake, you can remove the line. And remove local front of r, g, b.
  18. I'm author of this script. I have v3 version of this, comment if you need it. It have moving doors that closes for 20 seconds when you rob it + criminals only.
  19. Jaa että ville on uusi scriptaamisessa? + Kenenköhän pohjilta sattuu olemaan scripti ? Muuten vaan samat koordinaatit ja funktiot GG https://community.multitheftauto.com/in ... s&id=10815
  20. If you mean message color, you can use community created function rGBToHex Example: local r, g, b = getPlayerNametagColor(source) color = tocolor(r, g, b) outputChatBox("#ffffff"..getPlayerNametagText(source).. "" .. RGBToHex(r, g, b) .. " has been muted for spam", getRootElement(), 255, 255, 0,true) function RGBToHex(red, green, blue, alpha) if((red < 0 or red > 255 or green < 0 or green > 255 or blue < 0 or blue > 255) or (alpha and (alpha < 0 or alpha > 255))) then return nil end if(alpha) then return string.format("#%.2X%.2X%.2X%.2X", red,green,blue,alpha) else return string.format("#%.2X%.2X%.2X", red,green,blue) end end
  21. Test it. Server: function loginPlayer(username, password) local account = getAccount(username, password) if user ~= nil or user ~= "" or pass ~= nil or pass ~= "" then if (account ~= false) then logIn(client, account, password) triggerClientEvent("closeLoginGUI", client) showCursor(client, false) showChat(client, true) else outputChatBox("Invalid username & password!", client, 255, 0, 0) end else outputChatBox("Please enter username and password.", client) end end addEvent("loginPlayer", true) addEventHandler("loginPlayer", getRootElement(), loginPlayer) function createAccount(username, password) if (password ~= "" and password ~= nil and username ~= "" and username ~= nil) then local addedAccount = addAccount(username, password) if (addedAccount) then outputChatBox("You have been successfully registered and logged in!", client) loginPlayer(username, password) triggerClientEvent("closeRegisterGUI", client) else outputChatBox("An account with your username is already registered.", client) end else outputChatBox("Please enter username and password.", client) end end addEvent("registerPlayer", true) addEventHandler("registerPlayer", getRootElement(), createAccount) function showGUI(joinedPlayer) triggerClientEvent(joinedPlayer, "nobfokopenlogin", joinedPlayer) fadeCamera(source, true, 5) setCameraMatrix(source, 1468.8785400391, -919.25317382813, 100.153465271, 1468.388671875, -918.42474365234, 99.881813049316) end addEventHandler("onPlayerJoin", getRootElement(), showGUI) addEventHandler("onResourceStart", resourceRoot, function() setGameType ("FTA: v1.0.0") resetMapInfo() for _, player in ipairs (getElementsByType("player")) do kickPlayer(player, client) end end ) function createTeams() admin = createTeam("Admin", 0, 255, 0) noteam = createTeam("Unemployed", 255, 255, 0) end addEventHandler("onResourceStart", resourceRoot, createTeams) exports.scoreboard:addScoreboardColumn('Country') function showcountry() local flag = exports.admin:getPlayerCountry ( source ) if flag then setElementData(source,"Country",flag) end end addEventHandler("onPlayerJoin",getRootElement(),showcountry) function showPos(thePlayer) x,y,z = getElementPosition(thePlayer) outputChatBox("X, Y, Z: " .. x .. "," .. y .. "," .. z, client) end addCommandHandler("pos", showPos) function onLogout () cancelEvent() outputChatBox("Logout command has been disabled due to abuse.", client, 255, 0, 0) end addEventHandler ("onPlayerLogout", getRootElement(), onLogout) function chatbox(text, msgtype) if (msgtype == 0) then cancelEvent() local name = getPlayerName(source) local r, g, b = getPlayerNametagColor(source) local country = exports.admin:getPlayerCountry(source) outputChatBox("["..country.."] " .. name .. ": "..text, client, r, g, b) end end addEventHandler("onPlayerChat", root, chatbox)
  22. Thank you! That fixed my problem, now it works perfectly.
  23. Hi, I have a problem with getCursorPosition. I'm trying to make dx button and when i move my mouse to rectangle, it makes another white rectangle top of it. Nothing happens when i move my mouse to rectangle? Part of code: addEventHandler("onClientRender", root, function() if enabled == true then local height = 15 local lenght2 = dxGetTextWidth("Buy weapon", 1, "bankgothic") button = dxDrawOutlinedRectangle(1, tocolor(255, 165, 0, 170), x/2-200, y/2+150, 400, 30, tocolor(255, 255, 255, 130), false) dxDrawOutlinedText(tocolor(255, 165, 0, 255), "Buy weapon", x/2-lenght2/2, y/2+150, 200, 20, tocolor(0, 0, 0, 255), 1, "bankgothic", nil, nil, nil, nil, true) sx, sy = getCursorPosition() if (sx >=x/2-200 and sx <=x/2+200) and (sy >=y/2+150 and sy <=y/2+180) then dxDrawRectangle(x/2-200, y/2+150, 400, 30, tocolor(255, 255, 255, 80), true) end end end ) No any errors in debugscript.
×
×
  • Create New...