Jump to content

Gtagasje

Members
  • Posts

    141
  • Joined

  • Last visited

Everything posted by Gtagasje

  1. My guess would be that the progress bar only accepts round numbers. If you want to add 0.5% you could make it so that the progress bar updates only every 2 frames but the text updates every frame, or you could make your own progress bar using DX functions.
  2. I had this problem too when I tried updating stuff when a player logged out or quit the server. The way I fixed is was by just deleting the row and inserting it again instead of updating it, this seemed to work. You might want to consider trying this if you can't find a different solution.
  3. I'm guessing you want to spawn a vehicle once the player hits a marker? createVehicle() warpPedIntoVehicle() "onMarkerHit" -- Event
  4. Most of the free webhosts (for sure 000webhost) don't allow external connection.
  5. Gtagasje

    Skin change

    Ah, so you're running the freeroam resource, in that case you'd have to add these things to the function in the freeroam resource.
  6. Then, as Castillo said, you'd have to tell us where parts is defined. Because the error means that 'parts' is not a number(which math.random needs), it is a nil value meaning it's nothing.
  7. Gtagasje

    Skin change

    If the VIP group is a team, you'd have to use if getTeamName(getPlayerTeam([player element here)) == "VIP" then but if the VIP group is an ACL group then you'd have to use if isObjectInACLGroup("user."..getPlayerAccount([player element here]), aclGetGroup("VIP")) then If the player passes the check you can set his skin to whatever you want, otherwise you set his skin to 0 using setElementModel()
  8. Gtagasje

    car spawn

    You seem like a just beginning scripter, and then I'd not recommend making such a system because if you want to do it good it'll take some scripting skills, but if you really want to try you can make a GUI using guiCreateWindow() Then you can add a gridlist with a vehicle, and make it trigger the buying when you click a button using guiCreateGridList() guiGridListGetSelectedItem() guiGridListGetItemText() guiCreateButton() onClientGUIClick -- On click event Then you can trigger a serverside event to create a vehicle using triggerServerEvent() And then you can spawn the vehicle, set it's owner and take the player's money using getPlayerMoney() takePlayerMoney() createVehicle() getAccountName() getPlayerAccount() setElementData() But, this is only part of the script, for example for the lock and engine you'd have to use setVehicleLocked() setVehicleEngineState() And to set a new owner you'd have to use setElementData() again. But as I said, this is only part of the script, if you want a good vehicle system it'd be a few hundred lines, and pretty advanced. (Speaking of experience, I just made one 2 weeks ago.) If you have a feeling you won't be able to do this, it's the best to just look for one on https://community.multitheftauto.com
  9. https://community.multitheftauto.com/index.php?p= ... ls&id=3940 You can use this. I don't know if it works though, I use one I made myself thus I have not tested this.
  10. Just use this; https://community.multitheftauto.com/index.php?p= ... includes=1 You can change the distance in the client.lua (default is 75) If you want different sounds you can just change the audio files in the sounds folder. If you want to remove sounds you just remove parts of the script; for example: elseif weapon == 22 then --pistol if(ammoInClip == 0 and reloadSoundEnabled)then pistolReload("sounds/weapon/pistole.wav", x,y,z) else local sound = playSound3D("sounds/weapon/pistole.wav", x,y,z) setSoundMaxDistance(sound, distance) end If you would remove that part the pistol wouldn't have a custom sound anymore.
  11. Gtagasje

    AFK script

    Server side: function afkCommand(thePlayer, cmd) if isPedInVehicle(thePlayer) then outputChatBox("You must be on foot to use this command.", thePlayer, 255, 255, 255) else if isPedOnGround(thePlayer) then if getElementDimension(thePlayer) < 10 then outputChatBox("You will be AFK in 5 seconds", thePlayer, 255, 255, 255) setTimer( function() setElementDimension(thePlayer, math.random(10, 1000)) setElementFrozen(thePlayer, true) end, 5000, 1 ) elseif getElementDimension(thePlayer) >= 10 and getElementDimension(thePlayer) <= 1000 then outputChatBox("You will be returned to the main dimension in 5 seconds", thePlayer, 255, 255, 255) setTimer( function() setElementDimension(thePlayer, 0) setElementFrozen(thePlayer, false) end, 5000, 1 ) end else outputChatBox("You must be on the ground to use this command.", thePlayer, 255, 255, 255) end end end addCommandHandler("afk", afkCommand) Note: To make this script to work, don't make it client side. If you make it client side it will not work due to the arguments given in certain functions.
  12. Yup, the data was being inserted, but when I wanted to go and take a screenshot I saw what was wrong. Appearently the database rounded the x y and z to 0 decimals, so the check I did afterwards obviously didn't exist, because that had like 10 decimals. So thank you for making me check that.
  13. Gtagasje

    Radio Player

    You could try this: addEventHandler("onClientResourceStart", getRootElement(getThisResource()), local screenWidth, screenHeight = guiGetScreenSize() local windowWidth, windowHeight = 552, 476 local left = screenWidth/2 - windowWidth/2 local top = screenHeight/2 - windowHeight/2 Agui = guiCreateWindow(left, top, windowWidth, windowHeight, ":O Around Panel v1.0", false) guiWindowSetSizable(Agui, false) guiSetVisible(Agui, false) playb = guiCreateButton(420, 315, 101, 51, "Play/Stop", false, Agui) stopb = guiCreateButton(420, 375, 101, 51, "Stop", false, Agui) TBDEV = guiCreateEdit(10, 335, 113, 21, "URL", false, Agui) guiEditSetMaxLength(TBDEV, 32767) ) addEventHandler("onClientGUIClick", getRootElement(), function() if guiGetText(TBDEV) then if source == playb then if sound ~= nil then stopSound(sound) end sound = playSound(guiGetText(TBDEV)) elseif source == stopb then if sound ~= nil then stopSound(sound) end end else outputChatBox("You must fill in a URL first!", 255, 0, 0) end end )
  14. Okay, so, now I've changed the things you pointed out, and I have this: function createHouse(x, y, z, interior, intx, inty, intz, price) local handler = dbExec(connection, "INSERT INTO Houses(X, Y, Z, Interior, IntX, IntY, IntZ, Locked, Passworded, Password, Price, Sale, Owner) VALUES(?,?,?,?,?,?,?,'No','No','',?,'No','')", x, y, z, interior, intx, inty, intz, price) if handler then local resid = dbPoll(dbQuery(connection, "SELECT * FROM Houses WHERE X=? AND Y=? AND Z=? AND Interior=? AND IntX=? AND IntY=? AND IntZ=? AND Price=?", x, y, z, interior, intx, inty, intz, price), -1) outputChatBox("House "..(resid[1].ID).." has been created successfully!", source, 0, 255, 0) buildHouse(id, x, y, z, interior, intx, inty, intz, price) else outputChatBox("An error occured while creating the house!", source, 255, 0, 0) dbFree(resid) end end addEvent("createHouse", true) addEventHandler("createHouse", getRootElement(), createHouse) Yet, now I get this error(on the outputChatBox() line again.): ERROR: Attempt to index field '?'(a nil value) Any ideas on what's the problem?
  15. Gtagasje

    Radio Player

    Is this the full function you use for playing and stopping sounds?
  16. Uhm, not sure if it was an accident when copying, but you have an error in your meta. This: "Darkwarrior" type="misc" name="My Server" description="damage proof car" version="0.1"/> Should be this: "Darkwarrior" type="misc" name="My Server" description="damage proof car" version="0.1"/>
  17. I'm not entirely sure if it would work, but you could try this: local dbid, ent, ext= nil intEnt, intExt = {}, {} function loadHouses(interiorElement) if not (interiorElement) then interiorElement = getElementsByType('house') end if(interiorElement) then for _, interior in ipairs(interiorElement)do loadOnePickup(interior) end else outputDebugString('[ERROR] : interiorElement not found', 3) end end setTimer(loadHouses, 500, 1) function loadOnePickup(int) if not(int) then outputDebugString('[ERROR] : element(int) not found', 3) end dbid = getElementData(int, 'home:id') if (dbid) then ent = getElementData(int, 'home:entrance') ext = getElementData(int, 'home:exit') createHousePickup(int) end end addEvent('createHousePickups', true) addEventHandler('createHousePickups', getRootElement(), loadOnePickup) function createHousePickup(interior) intEnt[dbid] = createPickup(ent[INT_X], ent[INT_Y], ent[INT_Z], 3, 1273) setElementParent(intEnt[dbid], interior) setElementDimension(intEnt[dbid], ent[INT_DIM]) setElementInterior(intEnt[dbid], ent[INT_INT]) intExt[dbid] = createPickup(ext[INT_X], ext[INT_Y], ext[INT_Z], 3, 1318) setElementParent(intExt[dbid], interior) setElementDimension(intExt[dbid], ext[INT_DIM]) setElementInterior(intExt[dbid], ext[INT_INT]) entrance = intEnt[dbid] addEventHandler('onPickupHit', entrance, boop) outputChatBox(tostring(getElementType(entrance))) exit = intExt[dbid] end function boop() outputChatBox('DAMMIT MOON MOON') end Basicly I've moved the event handler so that it adds one for each pickup you create. Again, I'm not sure if it would work, but give it a try.
  18. Hmm, not sure why I did it. I guess I'll change that too then (too bad I'm still on my phone.) Also, on a side note, why is it better to use dbExec for insert queries? Because when I looked at the database, it inserted it perfectly fine, and I'm kinda curious now.
  19. I'm not sure if it's the same, but I tried using resid[1]["ID"]. I think I got the same error, but again, I'm not sure if it's the same, and I'm not sure if I got exactly the same error. I'll test it tomorrow, posting this via phone.
  20. Gtagasje

    MySQL Error

    Hello there, Once again, something is bugging me. And once again, it's mysql. I have made a function which adds something to the table, and then right after that checks for a value in that table, since 1 of the columns is auto increment. I guess my function would explain it better: function createHouse(x, y, z, interior, intx, inty, intz, price) local handler = dbQuery(connection, "INSERT INTO Houses(X, Y, Z, Interior, IntX, IntY, IntZ, Locked, Passworded, Password, Price, Sale, Owner) VALUES(?,?,?,?,?,?,?,'No','No','',?,'No','')", x, y, z, interior, intx, inty, intz, price) local res = dbPoll(handler, -1) if res then local resid = dbPoll(dbQuery(connection, "SELECT * FROM Houses WHERE X=? AND Y=? AND Z=? AND Interior=? AND IntX=? AND IntY=? AND IntZ=? AND Price=?", x, y, z, interior, intx, inty, intz, price), -1) outputChatBox("House "..(resid.ID).." has been created successfully!", source, 0, 255, 0) -- Error line buildHouse(id, x, y, z, interior, intx, inty, intz, price) else outputChatBox("An error occured while creating the house!", source, 255, 0, 0) end end addEvent("createHouse", true) addEventHandler("createHouse", getRootElement(), createHouse) Now the error I'm getting is as following: attempt to concatenate field 'ID' (a nil value) This is getting caused at the line of the outputChatBox(). I have tried delaying the selecting with 1 second, but that gave the same error. So I do not think the database being slow is the problem. So, I really have no clue what is causing this error, and as you can maybe tell I am yet to be an expert at mysql. Thanks in advance, Gtagasje.
  21. Gtagasje

    Table

    Thanks a lot man, you helped me again! And yeah, if I encounter into more problems related to this I'll first try that before asking here.
  22. Gtagasje

    Table

    I tried it, but it the labels still get the text "nil" when I click a row, and if I remove the tostring() at the guiSetText I get errors that a string was expected but a nil was given.
  23. Gtagasje

    Table

    It returns the ID of the weapon I clicked. The gridlist has the columns "Weapon", "Price" and "ID", so if I click "Colt 45" it returns "22", and if I click "Silenced" it returns "23".
  24. Gtagasje

    Table

    Hi there, Im having a little problem with tables. I have a table storing certain informating about weapons, and I want to try match those values with values in a gridlist row when it's clicked. But, I just can't get it working. It first gave me the error 'attempt to index ?(a nil value' but that is gone after I changed something, and now it just returns nil (I found out by using tostring on the returned value) This is my code: wepTable = { {["ID"] = 22, ["Name"] = "Colt 45", ["Price"] = 3, ["Dual"] = "Yes", ["Clip"] = "17(34)", ["Type"] = "Handgun"}, {["ID"] = 23, ["Name"] = "Silenced", ["Price"] = 1, ["Dual"] = "No", ["Clip"] = "17", ["Type"] = "Handgun"}, {["ID"] = 24, ["Name"] = "Deagle", ["Price"] = 7, ["Dual"] = "No", ["Clip"] = "7", ["Type"] = "Handgun"} } -- These are just 3 lines from the table, because it's quite big, but there are more. --This is the malfunctioning function function gridUpdate(row, col) local tempWepName = guiGridListGetItemText(wepGrid, row, wepGrid_ID) for i, v in ipairs(wepTable) do if wepTable[i]["ID"] == tempWepName then local wepID = wepTable[i]["ID"] local wepName = wepTable[i]["Name"] local wepPrice = wepTable[i]["Price"] local wepDual = wepTable[i]["Dual"] local wepClip = wepTable[i]["Clip"] local wepType = wepTable[i]["Type"] break end end guiSetText(nameVar, tostring(wepName)) guiSetText(dualVar, tostring(wepDual)) guiSetText(clipVar, tostring(wepClip)) guiSetText(typeVar, tostring(wepType)) guiGridListClear(wepGrid) for i=1,#wepTable do local row = guiGridListAddRow(wepGrid) guiGridListSetItemText(wepGrid, row, wepGrid_name, wepTable[i]["Name"], false, false) guiGridListSetItemText(wepGrid, row, wepGrid_price, wepTable[i]["Price"], false, false) guiGridListSetItemText(wepGrid, row, wepGrid_ID, wepTable[i]["ID"], false, false) end guiGridListSetSelectedItem(wepGrid, row, col) end I hope I gave enough information, basicly the labels (nameVar, typeVar etc.) all get set to 'nil', because I did something wrong with the table but can't find out what. Thanks in advance.
×
×
  • Create New...