Jump to content

IIYAMA

Moderators
  • Posts

    6,062
  • Joined

  • Last visited

  • Days Won

    208

Everything posted by IIYAMA

  1. Then you have to synchronise this status with the server, for each player. Try to build that first.
  2. use: root It holds all players. (localPlayer + remoteplayers)
  3. Creating a new table is a slower method, but nothing to worry about. You wouldn't notice the difference with the computers these days. You didn't need the pack function to do this: local pos = {getElementPosition(source)} But if it helps you with readability, then why not a pack function?
  4. Locked for triple posting and wrong section language.
  5. Locked for triple posting, wrong section(this post was in tutorials) and wrong section language.
  6. The data type time in your database is not something you should animate. https://wiki.multitheftauto.com/wiki/GetRealTime Create your end time: (seconds) > End time (start time + duration) That is all you have to save. Remaining time = (End time - current time)
  7. local x, y, z = getElementPosition(source) local xr, yr, zr = getElementRotation(source) local playerData = {x=x, y=y, z=z, xr=xr, yr=yr, zr=zr} Those 2 functions do not return a table, but multiple variables.
  8. https://wiki.multitheftauto.com/wiki/OnClientPlayerVehicleEnter onClientPlayerVehicleEnter can also trigger for the remotePlayers(players other than yourself). So that issue doesn't require any serverside code. ------------------------------------------------- If you want to learn how to sync data, you could start with something not so complicated. And later learn how to use triggerEvents.
  9. Locked for topic bumping. If nobody wants to help you, then there must be something wrong with the information you provide. Or maybe your request is unacceptable. Think about it.
  10. Dit you check out how adminpanel does it? (Vehicle select)
  11. It is not a MTA function. Get it from here: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D
  12. @WorthlessCynomys isElement -- instead of getElementType
  13. The 2D way. First translate the 3D start and end point to 2D. With this function: https://wiki.multitheftauto.com/wiki/GetScreenFromWorldPosition You have now a 2D line instead of a 3D. Next Get the distance between the 2D line and point(your cursor) with: https://wiki.multitheftauto.com/wiki/GetDistanceBetweenPointAndSegment2D
  14. I have heard about this issue before, but not sure if people actually fixed it. The object orientation is updated every frame. But for some unknown reason there is a little delay. With other words: I don't know. Maybe add an extra eventHandler in file bone_attach_c.Lua: addEventHandler("onClientPreRender",root,putAttachedElementsOnBones) --[[ line 85 ]] addEventHandler("onClientRender",root,putAttachedElementsOnBones) --[[ NEW on line 86 ]] If you look at the event order: https://wiki.multitheftauto.com/wiki/Game_Processing_Order You can see that onClientPreRender event first fires and onClientRender fires as last. Maybe if updates are applied on both moments it could be a little bit smoother. Could could could > so not sure.
  15. It is most of the time not a matter of what they show, but which ones aren't shown. Between the ones that are shown and the ones that are NOT shows is your problem. Even if you think such useful information is useless, there will be a time you will think different about your previous reply.
  16. Yes, but BEFORE, not AFTER. Also add some debuglines, I need those to help you.
  17. Hmmm The code is a bit odd. But to fix it. Do not destroy the weapon in the loop. Do it before the loop. Just this: if isElement(armaobject) then destroyElement(armaobject) -- destroyed object end Because the weapon is directly destroyed after creating it. Or atleast I think that could happen.
  18. @thund3rbird23 I am just bewondering, did you test this with other players? Or is that irrelevant? Because this code as it is now doesn't looks like multiplayer compatible. Atleast if the armas effect is visible for remotePlayers(other players than yourself).
  19. Relative as in 80% of 1920px? Nothing actually at the end. The only difference is the usability for the developer. You can develop your UI with absolute values (px), on your own screen resolution, while it is automatic compatible for other resolutions (%).
  20. @grazia local players = getElementsByType("player") -- test code if #players > 0 then setElementData(players[math.random(#players)], "something", "something") end -- local found = false for i=1, #players do local player = players[i] local something = getElementData(player, "something") if something == "something" then iprint(getPlayerName(player), " has something...") found = true break -- stop searching end end
  21. IIYAMA

    Help!

    With: https://wiki.multitheftauto.com/wiki/OnPlayerQuit Players that left the server, are still inside of the playerIDs table. playerIDs[source] = nil
  22. IIYAMA

    Loading mods

    I would recommend moving each loading request atleast to the next frame. That way the process will be synchronised with your framerate > GPU. Which reduces the large freezing effect, because each other operation will be able to finished and continue it's "what ever it's doing?". (Not the small freeze effects though) NOTE: it does not keep an eye on the processor. So for large mods a bigger delay might be recommended.
  23. IIYAMA

    Help!

    The player list is dynamic. The location of the players in the table is changing when players are leaving. Player list (table) local players = getElementsByType("player") New players are added on the back of the table. players = { [1] = player1, [2] = player2, [3] = player3 } players[4] = player4 players = { [1] = player1, [2] = player2, [3] = player3, [4] = player4 } Leaving players are collapsing the list. players = { [1] = player1, [2] = player2, [3] = player3, [4] = player4 } table.remove(players, 1) -- player1 is leaving players = { [1] = player2, [2] = player3, [3] = player4 } If you want to generate IDs, you have to make sure they are always unique. do -- < Closed environment for the variable: id. Nothing can edit it, except for the newId function. local id = 0 function newId() id = id + 1 return id end end local playerIDs = {} function getIDFromPlayer(player) local id = playerIDs[player] if not id then id = newId() playerIDs[player] = id end return id end Note, this table doesn't clean it self, yet.
  24. Big dreams, maybe pay Google a little bit with your privacy, by using the search bar and button. It is a lot cheaper you know? No-cure-no-pay, seriously? ? Zombie bots. <<< Topic doesn't fit within this section, LOCKED
  25. The variable victim contains extra information. It is optional. function cameraFireing(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) iprint("event is fired") if getElementData(localPlayer, "char.inMarkerZone") then iprint("source is in zone") local victim = isElement(hitElement) and getElementType(hitElement) == "player" and hitElement or false local zoneName = getElementData(localPlayer,"char.MarkerZoneName") triggerServerEvent("sendGroupMessage", resourceRoot, victim, victim and getPlayerName(victim), zoneName) end end addEventHandler("onClientPlayerWeaponFire", localPlayer, cameraFireing) addEvent("sendGroupMessage", true) addEventHandler("sendGroupMessage", resourceRoot, function (victim, victimName, zoneName) local message = "#ffffffThe camera: #ca5454(".. zoneName ..") #ffffffdetected shots. " if victimName then message = message .. " You hit this player: " .. victimName end outputChatBox(message, client) if isElement(victim) then outputChatBox(getPlayerName(client) .. " hits you and he doesn't feel sorry for it.", victim) end local players = getElementsByType("player") for i=1, #players do local player = players[i] if player ~= client and player ~= victim then outputChatBox(getPlayerName(client) .. " loves sheeps.", player) end end end, false)
×
×
  • Create New...