Bilal135

Members
  • Content Count

    836
  • Joined

  • Last visited

Community Reputation

13 Decent

2 Followers

About Bilal135

  • Rank
    Road Dawg
  • Birthday 30/06/2002

Details

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

Recent Profile Visitors

2,020 profile views
  1. 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?
  2. That sums it up. Thank you.
  3. 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.
  4. Show where this table is implemented in the code
  5. Debug your code. xml = xmlLoadFile("cars/saved.xml") if xml then print("File is loaded") else print("File is NOT loaded") end
  6. If you have added that in meta.xml, what does the debugscript output?
  7. Probably create an export function that returns the desired xml file. @stPatrick oh I didn’t know that was even possible
  8. Lol I thought you were trying to load a file from a different folder within the same script.
  9. <file src="folder/filename.xml"/> xml = xmlLoadFile("folder/filename.xml")
  10. Perhaps, what you're looking for is dxDrawImageOnElement.
  11. I loved how you introduced the features in a humorous way. Great to see original content in MTA Roleplay after such a long period of rip offs. Good luck, @Blast3r.
  12. @IIYAMA, ah yes, i misunderstood. He might have wanted to trigger the event somewhere else.
  13. From what I have come to understand is, when you type 'test', you want to create an object, and if it already exists, then delete it. Imo you don't even need an event to do that, but if you want to do it your way, it would be better to pass the object as an argument to the trigger event. local obj addEventHandler("test", function(plr, cmd) if not isElement(obj) then obj = createObject(1234, getElementPosition(plr)) -- spawn object with '1234' id at our current position. else triggerEvent("deleteObject", obj) end end) addEvent("deleteObject", true) addEventHandler("deleteObject", function(object) if not isElement(object) then return outputChatBox("Object does not exist.", source, 255, 0) end destroyElement(object) end end) An alternative and much simpler way to do this would be like this (but of course it depends on how you intend your script to work). local obj addEventHandler("test", function(plr, cmd) if not isElement(obj) then obj = createObject(1234, getElementPosition(plr)) -- spawn object with '1234' id at our current position. else outputChatBox("Destroying object.", plr) destroyElement(obj) end end) ----------- @stPatrick, with all due respect, where did you trigger the 'trigger' event? Custom events have to be manually triggered.