Leaderboard
Popular Content
Showing content with the highest reputation on 12/10/21 in Posts
-
Thank you very much. I am trying my hardest to help you and everyone else who is genuinely in the need of it. You're welcome!1 point
-
Thanks for all your help I'd like you to win the day again so I went ahead and gave you a good boost1 point
-
Sure. Here is my example. -- We assume that there is only one warehouse on the map/server. -- We assume that being inside the warehouse means being inside the colshape. local warehouse_timer = false; local warehouse_col = false; -- TODO. local function warehouseEnter(shape, matching_dimm) if (shape == warehouse_col) and (matching_dimm) then -- If we previously had a warehouse_timer, then we should clean it up here regardless. if (warehouse_timer) then killTimer(warehouse_timer); warehouse_timer = false; end warehouse_timer = setTimer( function() -- TODO -- If the timer has finished, then we should clean it up. warehouse_timer = false; end, 1000, 1 -- TODO ); end end addEventHandler("onClientElementColShapeHit", root, warehouseEnter); local function warehouseLeave(shape, matching_dimm) if (shape == warehouse_col) and (matching_dimm) then -- If we have previously entered the warehouse clientside, then we should -- have the warehouse_timer variable set to not false. We assume that -- the warehouseEnter function has been properly implemented. if (warehouse_timer) then killTimer(warehouse_timer); warehouse_timer = false; end end end addEventHandler("onClientElementColShapeLeave", root, warehouseLeave); Good luck with your project. I like that you phrased your idea in a serious way. ?1 point
-
You're not even giving a full description what your script is supposed to do! Besides that, your script has flaws. But the flaws of your kind of scripts do not allow general support. Instead of doing too much, I want to give you hints: function warehoueEnter() if (getElementType(source) == "ped") or (getElementType(source) == "marker") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then setElementData(localPlayer, "timer", 60) :O = setTimer(warehoueTimer, 1000, 61) else killTimer(:O) end end addEventHandler("onClientElementColShapeLeave", localPlayer, warehoueEnter) addEventHandler("onClientElementColShapeHit", localPlayer, warehoueEnter) you fire this event for all colshapes; is this really what you want to do? for what colshapes do you want warehoueEnter to really trigger? if you asked this question in a straightforward way, maybe people could help you much easier. If you want to limit triggering events to certain elements such as WarehouseCol1, use the addEventHandler function with propagate set to false and comparing the first argument of the event handler callback to WarehouseCol1. Look at the wiki page of onClientElementColShapeHit for an example! you triggering this event handler for both leaving and entering the col shapes makes no sense. could you please decide on what is important here: entering the warehoue if you enter the col shape (onClientElementColShapeHit) or when you leave it (onClientElementColShapeLeave)? There seldom exist MTA scripters that seek support on our forums and I like to see you here. If you want to listen to my advice, then please learn from the code structures and examples from the wiki. Format your code exactly like on the wiki pages. Get used to best-practice coding rules.1 point
-
1 point
-
There is a fundamental logic issue in your script. The element type of the root element is "root". Thus the following check will always fail: if (getElementType(getRootElement()) == "ped") then return end --thought maybe this would work Do you know about predefined event handler global variables? They are set based on the situation of each issued event. Look them up here. I suggest you to use the source event handler global variable like this: if (getElementType(source) == "ped") then return end The following is kind of weird, so please split up the event handler code: --Leaving the warehouse function warehouseLeave() if (getElementType(getRootElement()) == "ped") then return end --thought maybe this would work if isElementWithinColShape(localPlayer, WarehouseCol1) == true then timertxt = getElementData(localPlayer, "timer") Wtimer = dxDrawTextOnElement(localPlayer, "Defend Warehouse: "..timertxt, 1, 20, 255, 0, 255, 255, 5, "arial") elseif Wtimer == nil then return else destroyElement(Wtimer) end end addEventHandler("onClientRender", getRootElement(), warehouseLeave) -- OK. because of dxDrawTextOnElement addEventHandler("onClientElementColShapeLeave", getRootElement(), warehouseLeave) -- Why??? Good luck with your scripting! ?1 point
-
Understandable. I am hoping for a modding API a'la plugin-sdk in the new GTA SA version. In some rumors there was talk of a comparison to high fidelity mods in the community. To not confuse the public I have, cautiously in advance, edited the Wiki page on how to buy GTA SA that the new game version on digital markets will not be compatible with MTA. This might of course change but it is unlikely to happen fast. I sure hope so! As vague as our participation in the upcoming game release is, as vague is also the modding capability of it. Due to the recent crossfire between GTA modding community and R* Games/Take-Two especially. But I am hoping for a more stable and capable engine that would not require those ugly assembly hacks anymore to get the game to multiplayer fruition.1 point
-
Judging from the code above, you are once again using one global variable that would be overwritten multiple times in an event handler, called "chicken". I hope you will not do that again and instead store such things in lists instead. You have not yet fixed the pickup issue that I mentioned as point number 3. Other than that, happy to see you scripting around. ?1 point
-
Wow, that is a long time ago! I am happy to see you come back to MTA scripting. It sure is fun ?1 point
-
Hello kewizzle! it looks like there are multiple issues with your script. I don't know why but you are using an inconsistent scripting style. At one point you either are using local variables and at the other you are not. Please refresh yourself on coding best practices! in lines 34, 35 and 36 you are storing data in global variables x, y, z, dropped and dropMarker that is being overwritten each time the createDeathPickup function is called. I suggest you to use local variables for storage instead. change the way the HitPick function is defined. You could use the source event variable instead of the dropped global variable to cancel the event. Making it depend on the global variable dropped is a bad idea because it does change each call to createDeathPickup. Imagine what happens if there are multiple death pickups at once: if the last created one gets destroyed then your event handler stops working! If you are hitting multiple pickups in a short time-interval then only one of the pickups would be stored in the element-data variable "pickup". The player has to leave the pickup marker and re-enter it in order to pickup another thing it is supposedly standing on. This could be annoying to the players. I recommend you to instead use a list of pickups that the player is nearby of. I suppose that the usePickup function is not able to be triggered twice to get health, guns, etc from the same pickup. You should clean-up the marker after the pickup was taken because it would otherwise still collide with pickups that can be taken. The result is an invisible pickup that prevents the other pickups from being taken. Just like the issues above this could prevent your script from working properly. Suggestions to further improve the script: make use of the onMarkerLeave function to clear the list of nearby pickups of the pickup that the player is nearby. Proposed fixes for 1, 2 and 4: outputServerLog ( "***Drop System Loaded ***" ) local state = {} local deathpickups = {}; local function bindState(player) bindKey(player, "l", "down", function(player) local dropped = getElementData(player,"pickup"); if isElement(dropped) then local pickupInfo = deathpickups[dropped]; usePickup(dropped,player) killTimer(pickupInfo.dtimer); destroyElement(pickupInfo.dropped); destroyElement(pickupInfo.dropmarker); removeElementData(player, "pickup") deathpickups[dropped] = nil; end end) end function getElementsWithinMarker(marker) if (not isElement(marker) or getElementType(marker) ~= "marker") then return false end local markerColShape = getElementColShape(marker) local elements = getElementsWithinColShape(markerColShape) return elements end addEventHandler("onResourceStart", resourceRoot, function() for _, player in pairs(getElementsByType ("player")) do bindState(player) end end) addEventHandler("onPlayerJoin", root, function() bindState(source) end) function createDeathPickup ( totalammo, killer, killerweapon, bodypart ) --when a player dies if ( killer ) then if ( getElementType ( killer ) == "player" ) then local x, y, z = getElementPosition ( source ) --get the position of the person who died and define it as x, y and z local dropped = createPickup ( x, y, z, 2, math.random(22, 34), 15000, math.random(1,3)) local dropmarker = createMarker ( x, y, z-0.5, "cylinder", 1, math.random(1, 255), math.random(1, 255), math.random(1, 255), 255) addEventHandler("onPickupHit", dropped, HitPick) addEventHandler("onMarkerHit", dropmarker, function(player) if isElement(player) and getElementType(player) == 'player' then setElementData(player,"pickup",dropped) end end) local dtimer = setTimer(function() if (getElementData(player, "pickup") == dropped) then setElementData(player, "pickup", nil); end destroyElement(dropped); destroyElement(dropmarker); deathpickups[dropped] = nil; end, 15000, 1) local info = {}; info.dtimer = dtimer; info.dropped = dropped; info.dropmarker = dropmarker; deathpickups[dropped] = info; end end end addEventHandler("onPedWasted", getRootElement(), createDeathPickup) function HitPick ( ) -- you don't have to check the source parameter if you just plan to check if it is an element. cancelEvent() end1 point
-
hey guys, me and my friend made a new Server Called: TL but there is one problem, we downloaded a resource to show the money in the scoreboard but when we start the resource it doesnt show me the money in the scoreboard and also not a tab for it. The code of it: exports [ "scoreboard" ]:addScoreboardColumn ( "Money", 3 ) -- Add the "Money" column to the scoreboard. function updatePlayersMoney ( ) -- Create "updatePlayersMoney" function. for index, player in ipairs ( getElementsByType "player" ) do -- Loop through all online players. setElementData ( player, "Money", getPlayerMoney ( player ) ) -- Set "Money" element data to the player money. end -- End our loop. end -- End our function. setTimer ( updatePlayersMoney, 2500, 0 ) -- Set a infinite 2.5 seconds timer to execute "updatePlayersMoney" function. i hope you guys can help me out Kind Regards, Artic1 point
-
Make sure you started scoreboard, and then again restarted the money resource. If that doesn't work, try this : exports [ "scoreboard" ]:addScoreboardColumn ( "Money", 3 ) function updatePlayersMoney ( ) for index, player in ipairs ( getElementsByType "player" ) do local money = getPlayerMoney ( player ) setElementData ( player, "Money", "$"..money ) end end setTimer ( updatePlayersMoney, 2500, 0 ) You forgot to add local money = getPlayerMoney ( player ) before setting the element data. You didn't specify "money"1 point
