Jump to content

IIYAMA

Moderators
  • Posts

    6,089
  • Joined

  • Last visited

  • Days Won

    216

Everything posted by IIYAMA

  1. For a scripter, yes. If you are looking for somebody that can create it, this is not the right section for that. See this section instead: https://forum.multitheftauto.com/forum/149-looking-for-staff/
  2. You can't. It might be fake-able with propagation, but I don't think that is what you want. That is not going to work, the serverside function will not be able to apply the effect on an clientside element. What you need to do: Destroy the marker <--> recreate it.
  3. Clientside created elements are not available on serverside. Those markers are already invisible for other clients/players as well as the server.
  4. It is mainly used to break a big task in separated sub-tasks. Your computer can't finish the big task in one run without blocking everything else (other resources and applications like your browser). For example: You have to do 10 exams and for that you have write a script that would determine which exams you have to learn for. For learning each exam you need 4 hours. You are a human, so you need every day atleast 13 hours resting/sleep, breakfast, dinners etc. ----- No worries, you do not need to program this. But there is one thing that matters, which is that you can only finish 2.75 exams per day. In Lua there is also limit, just run this to find out: while true do end ------ Coroutines are used to pause the code when the duration takes to long. The timer is used to resume the code at a new moment. Now an impossible task can become smaller possible tasks.
  5. I am just wondering, Mrtasty explained what the coroutine does. But do you also understand why they are used for something like bans? Temporarily stopping code isn't something you do without a good reason.
  6. Limit is used to collect a maximal amount of results. This also allows your database to stop searching when you got the result you need. If you do not apply a limit. The database will keep searching (for example an account) even after finding it. Depending of the location of the data, you can reduce search time from 0% to 99%. LIMIT 1 If search based on row numbers: > 99% = target data is on the first row (the rest can be skipped) > 0% = target data is on the last row -------------- But in the example of MrTasty it is used to make sure that the returned table length can either be 0 or 1. Just to keep things simple. if #result == 1 then
  7. IIYAMA

    NPC

    With for example this: https://web.archive.org/web/20130728213352/http://crystalmv.net84.net/pages/scripts/npc_hlc.php
  8. IIYAMA

    please help :(

    Because there is something called "ping" (internet/network speed delay), therefore the code doesn't wait for the message to be returned. Which means that this condition will not work as it was intended for: if triggerServerEvent(--[[...]]) then Also, you forgot to include the player. Which is used in the sys function. Your main problem. triggerServerEvent("amkocworkplz", getRootElement(), localPlayer) I do not see if the fastestman function is called, so I can't validate that part.
  9. can't you be a little bit specific? ... Well, this is what I changed: local screenSize = Vector2(guiGetScreenSize()) -- Do not create textures every frame, but DO before rendering them local textures = {} for i=1, 6 do textures[i] = dxCreateTexture("assets/screen" .. i .. ".png") or "assets/screen" .. i .. ".png" -- apply a fallback in case of failing end local backgroundTexture = textures[1] function random () -- No need for tickCount if you use a timer. (unless tickCount is used for processing data) backgroundTexture = textures[math.random(6)] end setTimer( random, 30000, 0 ) local angle = 0 -- angle is missing?????????????? local function draw( ) dxDrawImage ( 0, 0, screenSize.x, screenSize.y, backgroundTexture, angle, 0, -120 ) end addEventHandler("onClientRender", root, draw)
  10. It starts with the addEventHandler, which is called in JavaScript the addEventListener. (might have been a better name) This attached handler is something that listens to events, as if it is a microphone which listens to everything you say. But there is a catch, the listener/handler does have a filter ability. It does only it's thing (calling the function attached to it, when all conditions are met. This makes sure that not every addEventHandler triggers for every event. The first filter moment is the eventName. "onPlayerJoinRoom" Only eventHandlers do trigger with the exact same event. The second filter moment is the baseElement. local baseElement = root triggerClientEvent(source, "onPlayerJoinRoom", baseElement, arg) local handlerElement = root addEvent("onPlayerJoinRoom", true) addEventHandler("onPlayerJoinRoom", handlerElement, function () end) Trigger "onPlayerJoinRoom" Rules - If the baseElement is the same as the handlerElement. OR - If the baseElement is an (indirect) child of the handlerElement. AND propagation enabled <root> <console/> <player dontRespawn="false"/> <player dontRespawn="false" lastSpawnarea=""/> <resource id="resourcebrowser"/> <resource id="assault"> <map id="dynamic"> <team/> <team/> <blip/> <marker/> <colshape/> <blip/> <blip/> </map> </resource> </root> Root parent > console child Root parent > player child Root parent > resource child Resource parent > map child Map parent > team child Map parent > marker child See element tree: https://wiki.multitheftauto.com/wiki/Element_tree Feedback Call the handler function
  11. triggerEvent("onDestroyCurrentMap",arenaSrv.players,arg) TriggerEvent is not used to be send to players or to the server. It stays on the same side as it is triggered from. so yes, the same adjustment to the code: triggerEvent("onDestroyCurrentMap",resourceRoot,arg) In case of cross resource triggering: (two different resources) addEvent("onDestroyCurrentMap", true) addEventHandler("onDestroyCurrentMap", root, function () end, true --[[ << Enable propagation ]])
  12. hmmm, Create peds and place them in the vehicle? ? Recreate the vehicle Attach and detach the player on to the vehicle setPedWearingJetpack Respawn the vehicle at the same place where it blew up and move the vehicle to the right position Redirect the player, oh oh this is getting bad... https://wiki.multitheftauto.com/wiki/RedirectPlayer
  13. triggerClientEvent(arenaSrv.players,"onDestroyCurrentMap",arenaSrv.players) You filled in a table as base element. Base elements do not decide which players receive the event. They are only used for the addEventHandlers. triggerClientEvent(arenaSrv.players,"onDestroyCurrentMap",resourceRoot) addEvent("onDestroyCurrentMap", true) addEventHandler("onDestroyCurrentMap", resourceRoot, function () end, false --[[ << Disable propagation ]])
  14. You can also remove the ped from the vehicle even if he is not in a vehicle. The function will simply return false in that case. Not sure if that solves the whole issue. You could also re- set the player position with setElementPosition. But remember to disable the warp argument, else they become zombies ?. https://wiki.multitheftauto.com/wiki/SetElementPosition
  15. You do not need to use a loop, you can also provide a table with players as the first argument. When streaming data, root is perfect. But for bring data from one side to the otherside, with the purpose to help with initial loading (prepare the client before using the resource), making use of the root might be a bad idea. You have no guarantee that the client has loaded his resource, which means you do not know if he can receive it. In that case you only want to send a message to the players that have downloaded and loaded the resource. client > onClientResourceStart > triggerServerEvent > server > add the player to the the table 'loadedPlayers = {}' + send all the server-to-client initial data > triggerClientEvent > client
  16. GJ! Some suggestions: You could move not supported elements to custom elements, so that spawn points ect, are maintained. https://wiki.multitheftauto.com/wiki/CreateElement ------ <sync_map_element_data> In some cases you want elementdata to be applied to the elements. (Especially the custom ones).
  17. Locked for misusing this section to produce scripts. This topic is also very old. @komal
  18. No problem, enjoy Once you have mastered the table completely, serverside scripting will become less of a challenge. One last tip: be more consistent with locals. (Line 4) Those keep things clean and tidy.
  19. So there is just one state ON and OFF? Or are the more states in visibility? Like: On map showing Tag showing In order to make it easier. Set a default state: visibility = false Do your checks, if YES do: visibility = true add the ped to the table If visibility == false, remove the ped from the table. function Seconds() local f1, f2, f3= getCameraMatrix() for l,t in ipairs(getElementsByType("ped"))do local f4,f5,f6=getElementPosition(t) local visible = false -- by default the ped is not visible -- Do your checks. if(getDistanceBetweenPoints3D(f1,f2,f3,f4,f5,f6)<=25.0)then if(isLineOfSightClear(f4,f5,f6,f1,f2,f3+2))then local f7,f8=getScreenFromWorldPosition(f4,f5,f6+1) if(f7)and(f8)then -- Ped is visible visible = true -- set the state -- Add the ped to the table if not added yet. if not PlayerVisible[t] then outputChatBox("TM: #FFFFFFPoint D!",255,150,50,true)-- This point IS reached... PlayerVisible[t] = true-- Still working this... !!! end --PlayerVisible[t][id]="NPC" -- Once point Z is reached, then I'll worry about this stuff --PlayerVisible[t][name]="Bill" -- Once point Z is reached, then I'll worry about this stuff end elseif(PlayerVisible[t])then-- Ped no longer in L.O.S. outputChatBox("TM: #FFFFFFPoint 1!",255,0,0,true) end elseif(PlayerVisible[t])then-- Ped no longer in Range outputChatBox("TM: #FFFFFFPoint 2!",255,0,0,true) end -- Clear the ped from the table if not visible and in the table if not visible and PlayerVisible[t] then PlayerVisible[t] = nil end end -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! --collectgarbage() -- < REMOVE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! end And remove destroyed elements from the table. Lua does not know if an element exist or is destroyed. function ClientRender()-- This event is constantly called, it's not wise to add anything here unless you have NO other choice... You were warned! for l,t in pairs(PlayerVisible)do if isElement(t) then outputChatBox("TM: #FFFFFFPoint Z!",255,150,50,true)-- Not reaching this point... ((( With the noted changes, I now reach Point Z ))) else PlayerVisible[t] = nil -- if the element is destroyed, clear the data end end end
  20. Also don't forget to convert strings to numbers, when typing the command. (+ fallback) R, G, B = tonumber(r) or 255, tonumber(g) or 255, tonumber(b) or 255
  21. Locked for using a leaked resource without permission.
  22. Currently you are looping through the selecting of players that only have the statement. Are the once that are removed also players that didn't even have the statement in the first place? Depending on that answer I can give you the right solutions.
  23. Also the moment for adding and removing the event can be better. + check if the event is triggered. local displayDevTimer addEventHandler("onClientMapStarting",root,function () iprint("onClientMapStarting is triggered") if isTimer(displayDevTimer) then resetTimer(displayDevTimer) iprint("resetTimer") else addEventHandler("onClientRender",root,render) iprint("addEvent") displayDevTimer = setTimer(function () removeEventHandler("onClientRender",root,render) displayDevTimer = nil iprint("removeEvent") end,5000,1) end end)
  24. Probably out of the screen. dxDrawText doesn't require width and height. It needs a start-point(x1,y1) and end-point(x2,y2). Between those points is the box where your text is placed. local startX, startY = 0, sY - (sY*0.5) local endX, endY = sX, sY dxDrawText("Alpha 1.0.2 still work on Developer",startX, startY, endX, endY, tocolor(255,255,255,230),tables.fontSize,tables.font,"center","center",false) (I can't figure out the text position based on your code)
  25. This for l,t in ipairs(PlayerVisible)do will only loop through items, BUT only items that are stored as an array. {[1] = player, [2] = player, [3] = player} -- array structure -- OR {player, player, player} To solve that issue we can use pairs, instead of ipairs. This function doesn't care if items are stored as an array. {[player] = true, [player] = true, [player] = true} -- your structure So do this instead: for l,t in pairs(PlayerVisible)do
×
×
  • Create New...