Jump to content

IIYAMA

Moderators
  • Posts

    6,097
  • Joined

  • Last visited

  • Days Won

    218

Everything posted by IIYAMA

  1. IIYAMA

    Lag issues

    There is. You can add a debug hook. https://wiki.multitheftauto.com/wiki/AddDebugHook This can be used to monitor the activity of MTA functions and events. Attach the hook to (in the voice resource): https://wiki.multitheftauto.com/wiki/SetPlayerVoiceBroadcastTo https://wiki.multitheftauto.com/wiki/SetPlayerVoiceIgnoreFrom Monitor the activity of all functions every 1min. Then log the result and restart counting. Do this for 30 mins. If the activity is for example around than 100 (per 1 min). Then you need to monitor a bit more. If the activity is higher than 1000 (per 1 min), you know something is wrong. Your developer must be able to do this.
  2. IIYAMA

    Lag issues

    ah sorry, I forgot to reply to your previous topic. It is not very complex to test that assumption, just disable voice and check if the problem still occurs. (fastest way would be out-comment all export functions in the meta.xml of the voice resource, you will see a lot of errors, but it will do it's job) <!-- --> --- If your assumption is correct, then still that doesn't mean that the resource is fully responsible. Since voice is just an API, that receive instructions from another resource. That will be a second objective in that case.
  3. IIYAMA

    help in code

    Please ask for support in your language section, for a higher chance of success. (because of language barrier) https://forum.multitheftauto.com/forum/94-other-languages/ Topic locked
  4. no, each resource has it's own unique environment. But you can use export functions to retrieve variable values from other resources. https://wiki.multitheftauto.com/wiki/Call Keep in mind that: Tables are deep-copied. (loaded) Functions can't be past over. There is also elementdata, that can be act as an in-between storage place, but that has the same restrictions as exports.
  5. Every line of code can be validated, if it does what it is suppose to do. By only looking at the end result will only give you one type of answer, which is: success or failure. Note, this ain't a lecture. But telling me that something isn't working, without actually trying to figure out what went wrong through various debug techniques doesn't sit right with me. I know that it can be a pain to debug everything (that ain't death staring at a debug console), but now it feels more like unwillingness. Please learn it, for your own sake.
  6. In that case, swap these 2 lines: setTimer(function() local thePlayer = source local thePlayer = source setTimer(function() And then start working on the other functions. Like this one: function JAIL(thePlayer,commandName,sendToName,ido,...) And add a debug command: addCommandHandler("idozito", function () iprint("idozito:",idozito) end) So that you can monitor your table: idozito
  7. Removing code is not the same as fixing code. You need to fix your first iteration.
  8. This is still old. Source is not available in async functions (created by setTimer). Therefore you need to redefine it before using the async functions. local thePlayer = source There is no timer saved here.
  9. You can also use the account (pointer) or accountName instead. You may have tried it, but it seems like you didn't do it correctly. Try to use the accountName (since it seems you are using that) and if it doesn't work, post the code again with the changes.
  10. Save(and load) it based on serial. idozito[toPlayer] = setTimer(function() idozito[getPlayerSerial(toPlayer)] = setTimer(function()
  11. There is no global Lua environment afaik, atleast not that I am aware of. Each resource has it's own environment. But that doesn't mean a resource can't get information through http. If you want MTA to native support custom Lua env. variables, you probably need to create a module or modify MTA itself.
  12. Just use the config file. https://wiki.multitheftauto.com/wiki/GetResourceConfig While the syntax might be different, it's goal is exactly the same.
  13. That is because the `return` keyword stops the whole function. You are currently executing the following code, while I left most of the details out of it. How many times do you think this loop will run? (no matter what outcome of math.random is) for i=1, 1000 do if math.random(2) == 1 then return true else return false end end A : 1000 times B : 0 times C : 1 time Try to move the NOT state (as in no team has been found), after the loop. --[[ ... ]] local thePlayer = source for _, v in pairs(teams) do if teamName == v[1] then setTimer(function() spawnPlayer(thePlayer ,v[2],v[3],v[4],v[5],v[6],0,0,playerTeam) giveWeapon(thePlayer , v[7],ammo,false) giveWeapon(thePlayer , v[8],ammo,false) giveWeapon(thePlayer , v[9],ammo,false) end,2000,1) return -- this stops the whole function... end end setTimer(function() spawnPlayer(thePlayer,guestSpawns[num][1],guestSpawns[num][2],guestSpawns[num][3],guestSpawns[num][4],guestSpawns[num][5],0,0,playerTeam) end,2000,1) --[[ ... ]] By the way, this is just 1 out of many solutions.
  14. Use a table, so that you can separate player data. And if you do not know how to work with a table, then go watch table tutorials on Youtube. local allPlayerData = {} addEventHandler("onPlayerJoin", root, function () allPlayerData[source] = {} -- initial state end) addEventHandler("onPlayerQuit", root, function () allPlayerData[source] = nil end, true, "low") local box = createObject(1271, x, y, z) allPlayerData[player]["box"] = box -- save local box = allPlayerData[player]["box"] -- load
  15. IIYAMA

    Scroll label

    Not sure what you want to achieve. But you could add a DX effect, that shows the whole label when hovering.
  16. Too all clients: -- server local theElement = createElement("<element-type>", "<element-id>") setElementData(theElement, "<key>", "<data>") setTimer(function () setElementData(theElement, "<key>", getTickCount()) end, 4000, 0) -- client addEventHandler("onClientResourceStart", resourceRoot, function () local theElement = getElementByID("<element-id>") iprint("start value:", getElementData(theElement, "<key>")) addEventHandler("onClientElementDataChange", theElement, function (theKey, oldValue, newValue) iprint(theKey, oldValue, newValue) end, false) end, false)
  17. The big difference is that the object created on clientside, is not added to the element tree of serverside. (so unavailable/invisible) <!-- serverside / clientside --> <resource id="resource-id"> <map id="dynamic"> <!-- START clientside ONLY for redditing --> <object/><!-- invisible/unavailable for serverside and other players --> <!-- END clientside --> <!-- START clientside ONLY for IIYAMA --> <object/><!-- invisible/unavailable for serverside and other players --> <!-- END clientside --> <!-- START clientside ONLY for Tekken --> <object/><!-- invisible/unavailable for serverside and other players --> <!-- END clientside --> </map> </resource>
  18. Use timestamp: local currentTime = getRealTime().timestamp Since the index seconds is only from 0 > 59.
  19. Get real time uses seconds. ------------ -- server -- local timestamp = getRealTime().timestamp -- seconds local jailDuration = (60 * 4) -- seconds local jailEndTime = timestamp + jailDuration -- local remainingJailTime = jailEndTime - timestamp triggerClientEvent(player, "sync-jail-time", player, remainingJailTime ) -- the client only has to know this once ------------ -- client -- local jailEndTime addEvent("sync-jail-time", true) addEventHandler("sync-jail-time", localPlayer, function (remainingJailTime) jailEndTime = (remainingJailTime * 1000) + getTickCount() -- convert to miliseconds, to make it more accurate (as the machine times are not aligned by seconds) end, false) function getRemainingJailTime () if jailEndTime then local timeNow = getTickCount() return math.ceil(math.max(jailEndTime - timeNow, 0) / 1000) -- seconds end return 0 end
  20. Please use normal text format, it makes it hard to dxDraw functions are like paint, the last colour you put on the canvas will be visible. Which means that it is all about timing, this can be adjusted by changing the addEventHandler priority. https://wiki.multitheftauto.com/wiki/AddEventHandler removedEventHandler > addEventHandler addEventHandler( "onClientRender", root, function () end, false, "high" ) -- first layer of paint = back addEventHandler( "onClientRender", root, function () end, false, "normal" ) -- normal = middle addEventHandler( "onClientRender", root, function () end, false, "low" ) -- last layer of paint = top addEventHandler( "onClientRender", root, function () end, false, "low-1" ) -- last layer of paint = top top addEventHandler( "onClientRender", root, function () end, false, "low-2" ) -- last layer of paint = top top top An alternative is looping through a table and changing the item order.
  21. You are not stupid, it might be too complex to begin with. This is called the element tree: https://wiki.multitheftauto.com/wiki/Element_tree And as you know, tree's do start with the root element. (With this tree, there is a single root, yea I know that is strange...) Under this (inverted) tree you can see it is branching in to different other elements. This is how MTA organize it's elements. resourceRoot is the start of a single resource. Under the resourceRoot, you can see 1 resourceDynamicElementRoot. (This is where all your elements created by script are childs of) There are also resourceMapRootElement(s). Each element represents a map element, created by a .map file. Knowing all this and look at this representation of your resource (based on the code above): Serverside <resource id="your-resource"> <!-- resourceRoot --> <map id="dynamic"> <!-- resourceDynamicElementRoot --> </map> </resource> Clientside <resource id="your-resource"> <!-- (serverside) resourceRoot --> <map id="dynamic"> <!-- (serverside) resourceDynamicElementRoot --> <!-- START clientside --> <vehicleBlipRoot> <blip/> <blip/> <blip/> </vehicleBlipRoot> <!-- END clientside --> </map> <!-- (serverside) --> </resource> <!-- (serverside) --> As I said before, clientside has access to all serverside elements. But serverside has no access/isn't ware of clientside elements. You want to destroy client elements with serverside, but serverside is not ware that they exist. With the following element structure you can solve that: <resource id="your-resource"> <map id="dynamic"> <vehicleBlipRoot> <blipServerSide> <!-- START clientside --> <blip/> <!-- END clientside --> </blipServerSide> <blipServerSide> <!-- START clientside --> <blip/> <!-- END clientside --> </blipServerSide> <blipServerSide> <!-- START clientside --> <blip/> <!-- END clientside --> </blipServerSide> </vehicleBlipRoot> </map> </resource> If you delete blipServerSide, with the function destroyElement, then the blip clientside will also be deleted. This is happening because when you call the destroyElement function on serverside, the same function will be called on clientside on the same element (behind the scenes). And thx to propagation (already enabled) the function will also be called for all the children of the element that is about to be destroyed, which is in this case the client element blip. I can't explain it better than this.
  22. Exactly, that is why I gave you an example of how to do that, don't waste it. Since you still do not understand it, this is my last attempt to show you how you can delete clientside elements by also using a serverside element. If you still don't understand it, then that is unfortunately. Serverside local playerBlipElementContainerElement = createElement("playerBlipElementContainer", "playerBlipElementContainer:24436dg45632Ddfg") addEventHandler("onPlayerJoin", root, function () local serverSideElement = createElement("playerBlipElement_serverSide") setElementData(serverSideElement, "owner", source) setElementParent(serverSideElement, playerBlipElementContainerElement) end) --[[ -- Players already ingame addEventHandler("onClientResourceStart"... getElementsByType("player") ... ]] Clientside local playerBlipElementContainerElement = getElementByID("playerBlipElementContainer:24436dg45632Ddfg") ------------------- -- MODIFY THIS, for players already ingame (add a little delay) and for new players (onClientPlayerJoin + add a little delay) local serverSideElements = getElementChildren(playerBlipElementContainerElement) for i=1, #serverSideElements do local serverSideElement = serverSideElements[i] local owner = getElementData(serverSideElement, "owner") local blip = createBlipAttachedTo(owner, 0, 1, 150, 150, 150, 255, 1) setElementParent(blip, serverSideElement) end
  23. Server created elements are available clientside. Client created elements are NOT available on serverside. But there is 1 trick you can use to delete clientside elements by serverside. Start the following example when you are not downloading other resources, clientside must have been started before 10 seconds. Server local serverSideElement = createElement("exampleElement", "id:3563454hasduy3685dsfs") setTimer(function () -- destroy the element over 10 seconds destroyElement(serverSideElement) end, 10000, 1) Client local clientSideElement = createElement("exampleExample") -- get the serverside element local serverSideElement = getElementByID("id:3563454hasduy3685dsfs") if isElement(serverSideElement) then setElementParent(clientSideElement, serverSideElement) -- set the clientside element as child of the serverside element end addEventHandler("onClientElementDestroy", clientSideElement, function () iprint("onClientElementDestroy") end, false) *** Fixed the wrong ID value.
  24. Server local pedParentElement = createElement("pedParent", "pedParent-323536") ---------------- local ped1 = createPed ( 120, 5540.6654, 1020.55122, 1240.545 ) local ped2 = createPed ( 120, 5550.6654, 1020.55122, 1240.545 ) local ped3 = createPed ( 120, 5560.6654, 1020.55122, 1240.545 ) setElementParent(ped1, pedParentElement) setElementParent(ped2, pedParentElement) setElementParent(ped3, pedParentElement) Client addEventHandler("onClientPedDamage", getElementByID("pedParent-323536"), function() cancelEvent() end )
  25. As far I know there are not very advanced AI implementations, at least not how AI decides it's tasks. But there is an ped controller (makes a ped do stuff) with a task sequencer (makes a ped do stuff according to sequence/list of tasks): https://web.archive.org/web/20160727231206/http://crystalmv.net84.net/pages/scripts/npc_hlc.php https://web.archive.org/web/20170123100149/http://crystalmv.net84.net/pages/scripts/npc_tseq.php But how the AI interacts, that is something you have to create on your own.
×
×
  • Create New...