Jump to content

The_GTA

Helpers
  • Posts

    822
  • Joined

  • Last visited

  • Days Won

    86

Everything posted by The_GTA

  1. You're welcome! I believe this algorithm is important to a lot of inventory systems that are slot based.
  2. local skinData = dbQuery(connection,"SELECT * FROM accounts WHERE id=? AND skin=? LIMIT 1",(id),(skin)) What are the definitions of the global variables "id" and "skin"?
  3. local slot = #self.items while (count > 0) and (slot > 0) do if self.items[slot][1] == itemID then local canTake = math.min(count,self.items[slot][2]) self.items[slot][2] = self.items[slot][2] - canTake if self.items[slot][2] == 0 then table.remove(self.items,slot) end count = count - canTake end slot = slot - 1 end if (count > 0) then outputDebugString("not taken entire count"); end slot parameter to Inventory:takeItem has been neglected.
  4. According to your stack definition you can only have 128 on each stack. I recommend you to change your algorithm to take items from multiple stacks until the requested take-count is exhausted. Are you familiar with this idea?
  5. (...) if not slot then for i = #self.items ,1 ,-1 do if self.items[i][1] == itemID then slot = i break end end if not slot then return false end end local canTake = math.min(count,self.items[slot][2]) self.items[slot][2] = self.items[slot][2] - canTake if self.items[slot][2] == 0 then table.remove(self.items,slot) end (...)
  6. You should either turn the "stack" key in the tables inside of the "item" table to Lua numbers or use tonumber inside of the getItemInfos function, for example... items = { [1] = {name = "Appel",stack = 10,isDurability = false,isAmmo=false}; (...) } This is important because you are using numeric operations in your Inventory:takeItem method.
  7. Hello iwalidza, let me ask you some questions about your code first: if not count then count = self.infos[2] end Is this supposed to set "count" to the maximum value of currently held items? This would not make sense in your model because you have multiple slots with varying count of items between each slot. self.infos = { getItemInfos (itemID)} What does the getItemInfos function do? Could you post the definition aswell? Now let's get to the ideas. Let's assume you have slots 1, 2, 3, where slot 1 is itemID 124, slot 2 is itemID 124 and slot 3 is itemID 140. I don't understand which item you want to pick from? Slot 1, 2 or 3? Let's assume you pick from slot 1 with count = 140. inv:takeItem(inv:getItemIDFromSlot(1), 140, 1) inv:takeItem(inv:getItemIDFromSlot(2), 40, 2) inv:takeItem(inv:getItemIDFromSlot(3), 100, 3)
  8. No Problem. The solution to your inquiry is that simple. And I know from your background that you are of German heritage. Thus if you want to have German-only support requests answered by me, please post threads in the German sub-forums and mention my name. I am fully competent to answer in German only if it helps you understand the topics much better.
  9. You have to use the same function in the marker-hit and marker-leave event handlers. German: du sollst die gleiche Funktion in den Marker-Treffer und Marker-Verlassen Ereignis-Behandlern nutzen.
  10. Yes, you do. Check on the player element in the marker events. What is your problem?
  11. inside = createMarker( -1883.283203125, 865.4765625, 35.171875, "arrow", 4.0, 0, 255, 255 ) Removed the 56.0 because that argument to createMarker made no sense.
  12. Hello eoL|Shady, I recommend you to use the hasObjectPermissionTo function on the player to check for privilege about entering the special interior or even receiving/showing the interior information. To achieve that you should conditionally-enclose related code for teleportation, marker-hit and marker-leave. But considering that you have not shown us the entire code, there is more to disable for non-admins than we can know.
  13. Hello iwalidza, you did create a thread in the past about this topic where I did help you. I already have given you a direction about stacking items and server-side code. Could you explain how exactly your questions are not yet answered? The "stacking" of items that you mention is the count of the same item in the inventory, yes? Then the script that I gave you does already have an item ID system. Thus giving items to players that already have said items does stack them. What is missing is a client-side portion of the code. But I have already given you an idea on how to implement it.
  14. You're welcome! I felt a tad generous today because I had a good day. The next step is making use of the "onClientVehicleDoorOpenChange" event, with the source variable being the vehicle whose doors have been manipulated, to create a 3D sound at the location of the door.
  15. Hello J-N, in case you need a script to detect the door-open-and-close event clientside I have scripted a little something for you. meta.xml <meta> <script src="doorevents_client.lua" type="client" /> <script src="doors_test.lua" type="client" /> </meta> doorevents_client.lua local veh_doorInfos = {}; local valid_veh_doors = { 0, 1, 2, 3, 4, 5 }; local function getVehicleDoorInfo(veh) local info = veh_doorInfos[veh]; if (info) then return info; end; info = {}; for m,n in ipairs(valid_veh_doors) do info[n] = not ( getVehicleDoorOpenRatio(veh, n) == 0 ); end veh_doorInfos[veh] = info; return info; end addEventHandler("onClientElementDestroy", root, function() if not (getElementType(source) == "vehicle") then return; end; veh_doorInfos[source] = nil; end ); addEvent("onClientVehicleDoorOpenChange"); addEventHandler("onClientRender", root, function() for m,veh in ipairs(getElementsByType("vehicle")) do local vdi = getVehicleDoorInfo(veh); for m,n in ipairs(valid_veh_doors) do local isNotClosed = not ( getVehicleDoorOpenRatio(veh, n) == 0 ); if not (vdi[n] == isNotClosed) then vdi[n] = isNotClosed; triggerEvent("onClientVehicleDoorOpenChange", veh, n, isNotClosed); end end end end ); doors_test.lua addEventHandler("onClientVehicleDoorOpenChange", root, function(doorIndex, isNotClosed) outputChatBox("door nr. " .. doorIndex .. " is open: " .. tostring(isNotClosed)); end ); Hopefully this can come in handy for you!
  16. I was not aware that MTA had an official PHP SDK, but go figure. multitheftauto/mtasa-php-sdk: The official PHP SDK for the Multi Theft Auto Web Interface. (github.com) Sorry for not being able to support you in the way you wanted to, but you cannot expect volunteers like us to do this professionally especially with secrecy involved. I am glad that you figured it out yourself.
  17. I see that your MySQL database query building is subject to SQL-injection attacks. You should use the dbPrepareString function to mitigate this issue, like so... local conn = getMySQLC() local sqlquery = dbPrepareString(conn,"UPDATE `UserAccount` SET `?` = '?' WHERE `User` = '?'", Data, Value, tonumber(Tables[ID]["User"])) dbExec(conn, sqlquery)
  18. Hello MrLoki, 1) what kind of help do you expect in this regard? 2) do you have any idea how your "account system" should work, look like, etc? 3) are there any examples of account systems you are thinking of?
  19. I would still appreciate if you at least gave us the author's name or the link to where you got the code from. This would be helpful if other users also encounter similar issues. There is a syntax error in this line. I hope you understand that it is difficult for the outside user to understand your system. You are sharing a small fraction of an apparently fully integrated system. What we are expecting from you is a precise description of what already works. Share the messages you are already receiving, the debug output you see, an example scenario that does work, an example scenario that does not work.
  20. Hello roDaN, could you please explain your scripts a little bit more? You seem to be using a combination of MTA Lua scripting and web service technology (PHP, HTTP). This looks really complicated and I would like to know what software you are using, where you got the guidance from on how to create your script, whether the PHP portion does use any renowned libraries and whether you have gotten any response on the PHP side at all by now.
  21. Hello Lovin.mta, I think that the error may be in the following line, the specification of the callback to fetchRemote. local called = callRemote("https://community.multitheftauto.com/mta/resources.php", function(_, version) Please compare your understanding with the wiki documentation and try again.
  22. I wonder whether you are looking for the ped bone matrix. You can query it using the getElementBoneMatrix function. The bone matrix describes the orientation of the bone in 3D space (rotation + position).
  23. Hello FlorinSzasz, as brackets do you mean "{" (curly-brackets) or "[" (square brackets]?
  24. You don't need to know the algorithm if you can make use of the getRealTime function. By giving it the seconds of current day you can fetch the datetime description of the next day by adding the amount of seconds that eoL|Shady has described. Then you can reconstruct the datestring from that time description. But I guess that eoL|Shady's answer might be enough to get you in the right direction.
  25. To answer the original question, you should store the current time in a variable so that it is synchronized for the entire timer callback. setTimer(function() local now = getTickCount() for _,vehicle in pairs(getElementsByType('vehicle')) do (...) Then you should use the "now" variable in the following operations instead of the direct call to "getTickCount", for example... end if tonumber(data.blinkFreq) and VEHICLE_BLINK_TICK[vehicle] and VEHICLE_BLINK_TICK[vehicle][light] and now - VEHICLE_BLINK_TICK[vehicle][light].tick > data.blinkFreq then --if data.blink then The reason for that is that the getTickCount function does fetch the current time point and you seem to be oblivious to the fact that execution of scripts does take time aswell. Please be mindful of this fact.
×
×
  • Create New...