Jump to content

pa3ck

Members
  • Posts

    1,141
  • Joined

  • Last visited

  • Days Won

    7

Everything posted by pa3ck

  1. pa3ck

    onColShapeHit

    function giveBombToRandomPlayer() local teamElement = getTeamFromName ("Terrorists") local teamMembers = {} if isElement(teamElement) then for k, p in ipairs(getPlayersInTeam(teamElement)) do if getElementDimension(p) == 0 then table.insert(teamMembers, p ) end end else outputChatBox("Team is not available") return end if(teamMembers and #teamMembers > 0 then) local randomIndex = math.random(1, #teamMembers) -- get a random index: between 1 and the length of the table local randomPlayer = teamMembers[randomIndex] -- we already have a random index, now get it from the table setTimer(function() if not isElement(randomPlayer) then -- there's a 6 seconds timer here, there's a chance the terrorist we picked got disconnected, if so, find a new one outputChatBox("Player is no longer available, finding new player...") giveBombToRandomPlayer() return end outputChatBox("You have the bomb!", randomPlayer, 255, 0, 0) outputChatBox("Remember when you enter site.. switch to the C4 to plant!", randomPlayer, 255, 0, 0) giveWeapon ( randomPlayer, 14,1,true) end,6000,1) else outputChatBox("Couldn't find any Terrorists") end end That should work
  2. Well on the wiki it says value: The value you wish to store. Set to false to remove the data. NOTE: you cannot store tables as values, but you can use toJSON strings. Try to set it to false to remove the data instead of setting it to nil and see. Setting it to nil and expecting it to be removed is indeed logical, as far as I know setting setElementData to nil does actually remove it.
  3. pa3ck

    guiCreateEdit

    Looks like you cannot hide the caret. You would need to do a workaround, like using dx functions to create your own edit boxes if you really need to hide the caret, but there's no easy way.
  4. pa3ck

    onColShapeHit

    You're welcome.
  5. Is it only me, or the code indentation never works the way I want it to and code-copy doesn't function as intended? function fnc() if() code() if() code() end end end -> The code in "preview" mode looks like this: function fnc() if() code() if() code() end end end I see there's like a bag icon (looks like a bag to me, might be something else), which in theory should only copy the code without line numbers right? Well for me, it copies the code like this: 1.function giveBombToRandomPlayer1() 2. local players = getPlayersInTeam ( T ) 3. for playerKey, playerValue in ipairs ( players ) do 4. local randomPlayer = getRandomPlayer () 5. setTimer(function() 6. outputChatBox("You have the bomb!", randomPlayer, 255, 0, 0) 7. outputChatBox("Remember when you enter site.. switch to the C4 to plant!", randomPlayer, 255, 0, 0) 8. giveWeapon ( randomPlayer, 14,1,true) 9. end,6000,1) 10. end 11.end
  6. pa3ck

    onColShapeHit

    No, look at this code: function giveBombToRandomPlayer() local teamElement = getTeamFromName ("Terrorists") local teamMembers if isElement(teamElement) then teamMembers = getPlayersInTeam(teamElement) else outputChatBox("Team is not available") return end if(teamMembers and #teamMembers > 0 then) local randomIndex = math.random(1, #teamMembers) -- get a random index: between 1 and the length of the table local randomPlayer = teamMembers[randomIndex] -- we already have a random index, now get it from the table setTimer(function() if not isElement(randomPlayer) then -- there's a 6 seconds timer here, there's a chance the terrorist we picked got disconnected, if so, find a new one outputChatBox("Player is no longer available, finding new player...") giveBombToRandomPlayer() return end outputChatBox("You have the bomb!", randomPlayer, 255, 0, 0) outputChatBox("Remember when you enter site.. switch to the C4 to plant!", randomPlayer, 255, 0, 0) giveWeapon ( randomPlayer, 14,1,true) end,6000,1) else outputChatBox("Couldn't find any Terrorists") end end PS. this code editor is so annoying, I miss the old one, this one always fks up the indentation... not to mention the copy code function, it copies the line numbers and empty lines after each statement... It is not tested, if you get any errors and you can't solve it yourself, feel free to come back with the errors you're getting.
  7. function myFunction() outputChatBox("Function") end bindKey("w", "up", myFunction) OR bindKey("w", "up", function() outputChatBox("Function") end) WRONG bindKey("w", "up", function myFunction() outputChatBox("Function") end) When binding a key (or using anything else that takes functions), you either give it an already declared function name or an anonymous function without any names. An anonymous function cannot be called again, that is the whole purpose of it. So, if you want to bind a key to a function that could be called different ways as well, eg. on events, command, you will need to declare a function outside the bindKey.
  8. Is there a specific event you call the triggerServerEvent from or just when the resource starts? Because the server loads in before the client, so at the time when it runs, the event is not added yet
  9. pa3ck

    Help

    That's because you named your function get() so when you call get() at line 3, you will call your function at line 1 and when you get to line 3 again, you call line 1... Rename your function to getSettings() or something at line 1.
  10. I definitely agree, this is an open-source project, having a reasonably detailed guide / documentation would help attract new contributors. Although, I think it shouldn't necessary be the "Godfathers" job to make such guides, I'm not sure how many contributors are there right now, but if people who already code bits and pieces could also write down how they started, explanation of the structure of the code etc. and then these guides could be accepted by more experienced devs, the "Godfathers". That'd be pretty cool.
  11. pa3ck

    custom weapons

    To attach them to the players' hand, use bone_attach resource from the community.
  12. pa3ck

    custom weapons

    The way most people do is, they replace the weapon with an invisible object, so you will not see anything. You will then attach your gun model to the players' hand, that way you can have multiple guns for the same "invisible" model.
  13. onClientRender - an event that runs at every frame. For example if you have 60 fps, it will run 60 times per second. That is a lot... Anything you have in the onClientRender will be called over and over again including the creation of the marker. If you run your script for 1 minutes with 60 fps, you will have 3600 marker on top of each other, that is causing the lag. You should also consider whether it has to be create on each frame or not, in this case, the marker will need to be created only once. Most of the times you only do GUI / DX parts in the onClientRender anyway. So, to fix the lag, move your local kamuszef... and setElementAlpha outside the onClientRender, possibly before the function
  14. Having onClientRender inside another onClientRender is the easiest way to kill your fps/game. Do not, ever, ever put onClientRender inside onClientRender, because you're adding the event again and again at every single frame. This should be enough: function drawSzef_alap_renderer() if isElementWithinMarker (localPlayer, kamuszefmarker) then local x, y = guiGetScreenSize() dxDrawImage ("fajlok/kepanyag/szef[0].png", x/2, y/2, 500, 300) end end addEventHandler ("onClientRender", getRootElement(), drawSzef_alap_renderer) But that will not work anyway, as the server-side variables (kamuszefmarker) are not shared between the server and client. You should either trigger to client with the marker element and hook the event to that element or add an element data to it i.e. "safeMarker_1" and check in the onClientRender if the player is inside a marker with the element data "safeMarker_1".
  15. pa3ck

    onColShapeHit

    No, you will need a loop to get a new random player until it finds one that's in that team. It would be easier to get the list of players in that team using getPlayersInTeam and use math.random to get a random player from the returned table.
  16. pa3ck

    Fixed.

    That's because of your spelling, replace engineimportTXD with engineImportTXD ( see the capital 'i'? )
  17. Yea, I see it makes different calls.. I don't think I will be able to help you unless I check out all those functions myself, maybe someone experienced in this gamemode will be able to help you.
  18. pa3ck

    onColShapeHit

    Are you sure you call the function "giveBombToRandomPlayer1" somehow? Event, command?
  19. I'm not familiar with this gamemode, so I don't know how updateTopText() works, so if you could post the "updateTopText()" function that would help.
  20. Is the if statements evaluates to true? About the GUI part, probably it gets the toptimes when the map starts and holds it in a LUA table, you would need to update that table after deleting the toptime.
  21. That means you'll need to debug both of the if statements, after line 33 do another outputChatBox to see if it gets triggered, if it triggers, check both of the values in the next if statement: local state1 = getAccountData(getAccount(topsSql[1].topName), "currentPlayerName"):gsub('#%x%x%x%x%x%x', '') local state2 = otherPlayer:gsub('#%x%x%x%x%x%x', '') outputChatBox("Values - " .. state1 .. ":" .. state2 ) -- this is your if statement if getAccountData(getAccount(topsSql[1].topName), "currentPlayerName"):gsub('#%x%x%x%x%x%x', '')) == otherPlayer:gsub('#%x%x%x%x%x%x', '') then SQLite tables that you created with the executeSQLQuery should be saved in the registry.db. You can easily view the tables and the data with any SQL browsers you want to, eg: SQLite Browser
  22. pa3ck

    question

    Nothing, there's nothing wrong with that one, I just think it's better to let MTA's code do the looping with the table being passed to the function rather than the LUA loop.
  23. pa3ck

    Fixed

    I'm not sure if I understand your problem, what is the last loop for? In the first 1 and 2nd loop you have if statements but not in the 3rd? So you basically loop through all the objects again?
  24. No, for this purpose, onResourceStart wouldn't work.
×
×
  • Create New...