-
Posts
6,097 -
Joined
-
Last visited
-
Days Won
218
Everything posted by IIYAMA
-
It is a limit. Timer are an async method. It requires a lot more work to keep temporary variables alive. So timers will make copies of the values rather managing the original values. - You can't pass functions in to a timer as argument. (They can't be copied) - You can pass tables in to a timer as argument, but they will become a (deep) copy.
-
Hmmm, maybe: currentEXP = totalEXP - requiredEXP
-
Debug line 50 and check if the value goes below 0.
-
I think the problem lies somewhere else. Try to debug your code with debug functions. Also check this: Clientside: addEvent("s_callback", true) addEventHandler("s_callback", root, function() triggerServerEvent("serverCallback", localPlayer, s_tarek) -- ???? end)
-
You are using the variable in onClientRender, before it even has a value assigned to it.
-
You made a typo. bodypart ( line 8 ) > bodyPart ( line 10 )
-
There are many. But if there is no issue, why changing the approach? If you want a different approach, it doesn't start with code, but with a concept and questions. How should the data be saved? And how should the data be accessed? Must it be dynamic? Must it be player specific? What are the conditions? What are the possible outcomes?
-
Locked, reason: scripting request. You can make requests here: (read the section rules before posting) https://forum.multitheftauto.com/forum/149-looking-for-staff/
-
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/
-
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.
-
Clientside created elements are not available on serverside. Those markers are already invisible for other clients/players as well as the server.
-
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.
-
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.
-
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
-
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.
-
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)
-
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
-
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 ]])
-
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
-
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 ]])
-
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
-
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
-
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).
-
Locked for misusing this section to produce scripts. This topic is also very old. @komal
