Jump to content

Bilal135

Members
  • Posts

    843
  • Joined

  • Last visited

2 Followers

About Bilal135

  • Birthday 30/06/2002

Details

  • Gang
    Nightwalkers
  • Location
    Pakistan
  • Occupation
    Chick sexer
  • Interests
    Scripting

Recent Profile Visitors

2,443 profile views

Bilal135's Achievements

Road Dawg

Road Dawg (33/54)

15

Reputation

  1. Try this, addEventHandler ( "onClientMarkerHit", root, function ( hitElement ) if source == marker then if ( hitElement == localPlayer and getElementType ( hitElement ) == "player" ) then outputChatBox("working") destroyElement(marker) end end end )
  2. This should do the job. (Not tested) local vehicle = {}; function isVehicleOccupied(vehicleID) if vehicle[vehicleID] = true then return true end return false end function createVehicleForPlayer(player, cmd, model) if not tonumber(model) then return false end if isVehicleOccupied(model) then return false end local x, y, z = getElementPosition(player) local veh = createVehicle(model, x + 5, y, z) if not veh then return false end vehicle[model] = true; end addCommandHandler("vh", createVehicleForPlayer) function destroyVehicleOnQuit(player) if not isPedInVehicle(player) then return false end local veh = getPedOccupiedVehicle(player) if not veh then return false end local model = getElementModel(veh) if not isVehicleOccupied(model) then return false end if not isElement(veh) then return false end destroyElement(veh) vehicle[model] = false; end addEventHandler("onPlayerQuit", root, destroyVehicleOnQuit)
  3. I don't know about others but I use GUI editor from the community.
  4. local crewData = {}; function createCrew(crew, tag, r, g, b) if not tostring(crew) or not tostring(tag) or not tonumber(r) or not tonumber(g) or not tonumber(b) then return outputDebugString("* createCrew: Wrong args.", 1) end if doesCrewExist(crew) then return outputDebugString("* createCrew: Crew already exists.", 1) end crewData[crew] = { Members = {}, crewTag = tag, Color = {r, g, b}, Leader = {}, Experience = 0, }; outputDebugString(crew.." successfully created.") return crew end -- getPlayerCrew function getPlayerCrew(player) if not player then return outputDebugString("* getPlayerCrew: Wrong args.", 1) end local account = getPlayerAccount(player) if isGuestAccount(account) then return false end local accountName = getAccountName(account) for k, v in pairs(crewData) do for k1, v1 in pairs(crewData[v].Members) do -- Error: attempt to index field '?' (a nil value) if v1 == accountName then return v end end end return false end -- addPlayer function addPlayer(player, crew) if not player or not tostring(crew) then return outputDebugString("* addPlayer: Wrong args.", 1) end local account = getPlayerAccount(player) local accountName = getAccountName(account) if isGuestAccount(account) then return end if getPlayerCrew(player) then return end -- getPlayerCrew is called here. table.insert(crewData[crew].Members, accountName) return true end I've been scratching my head over this error for a while now. crewData[v]. Members should not be nil. I've tested that by adding a few test strings in Members table (in addPlayer function), and then by this command. It does output the strings, but still gives error when getPlayerCrew is called. function listMembers(player, cmd, crew) for k, v in pairs(crewData[crew].Members) do outputChatBox(v, root) end end addCommandHandler("fmem", listMembers) Thanks.
  5. I'm trying to add an image in scoreboard but i'm getting this error: https://imgur.com/a/XCIx2F9 this is the line in dxscoreboard_client.lua: dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) and this is what im doing, setElementData(source, "Rank", {type = "image", src="admin.png"}) Thanks.
  6. Is it possible to change the colour of a smoke that is created by createObject? E.g object ID 2780 is smoke but its white, any way to change its colour?
  7. I have heard that inserting players in a new table with 'for i = 1, #playerTable' method reduces the time it takes for the loop to complete, as compared to the more common 'for k, v in ipairs / pairs' loop. I know that the first method is more efficient from Lua guides, but I fail to understand the logic behind it. In the case of the common loop, it would directly iterate over the table returned by getElementsByType. As for the for i = 1 method, we would first have to add the contents of the table (returned by getElementsByType) in a new indexed table, in this instance, playerTable, and then we would loop over it once again to get the players in it. I wrote the following code to compare the time it takes to finish each type of iteration. However, both results were 0. Perhaps, it is because the difference is so minute that the machine is not able to identify it? If that's so, whats the point of preferring the first type over the second, when the difference is barely noticeable? local players = getElementsByType("player"); local playerTable = {}; local sT = getTickCount(); -- Supposed to be a faster way? for i = 1, #players do playerTable[i] = players; -- Insert players in a new indexed table. outputChatBox(getPlayerName(playerTable[i][1]), root); local eT = getTickCount(); outputChatBox(eT - sT, root); -- Output: 0 end -- Compared to the more common loop for k, v in ipairs(players) do outputChatBox(getPlayerName(v, root)); -- Directly access the contents of the table. local endTime = getTickCount(); outputChatBox(endTime - sT, root); -- Output: 0 end EDIT: I realised there is no need to insert the players in a new indexed table. (Still the same output) for i = 1, #players do outputChatBox(getPlayerName(players[i]), root); local eT = getTickCount(); outputChatBox(eT - sT, root); -- Output: 1 end -- Compared to the more common loop for k, v in ipairs(players) do outputChatBox(getPlayerName(v, root)); -- Directly access the contents of the table. local endTime = getTickCount(); outputChatBox(endTime - sT, root); -- Output: 1 end Why is the first sort of iteration faster? Would the difference be even larger, if the number of players were extraordinarily large? If that's the case, I'd understand why we would want to use the first loop over the second.
  8. Show where this table is implemented in the code
  9. Debug your code. xml = xmlLoadFile("cars/saved.xml") if xml then print("File is loaded") else print("File is NOT loaded") end
  10. Probably create an export function that returns the desired xml file. @stPatrick oh I didn’t know that was even possible
×
×
  • Create New...