Jump to content

WiBox

Members
  • Posts

    234
  • Joined

  • Last visited

Everything posted by WiBox

  1. WiBox

    Table..

    Hello guys, I need a help with something... I need a way when I press Create zone: zoneCreator.button[2] = guiCreateButton(137, 532, 141, 29, "Create Zone", false, zoneCreator.window[1]) those 4: function showZoneOutput() guiSetText(zoneCreator.edit[1], string.format('%.3f', x)) guiSetText(zoneCreator.edit[2], string.format('%.3f', y)) guiSetText(zoneCreator.edit[3], string.format('%.3f', w)) guiSetText(zoneCreator.edit[4], string.format('%.3f', d)) end get added inside that table: zones = { --{id,name,owner,ctrl,price,objects,radio,x,y,sx,sy} --{id = 1, name = "Test zone", owner = "TsT", ctrl = "", price = 50000, objects = 0, radio = "", x = -1188.001, y = -438.446, sx = 19.328, sy = 22.896} } Can someone help me with making that thing? I tried I know I should make a function..: function test( ) -- get info from loadInfo and add them inside the table zones = { addEventHandler ( "onClientGUIClick", zoneCreator.button[2], showZoneOutput, false ) end addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource( ) ), test ) Now of course I made it wrong with messing part... If someone can help.. Thanks.
  2. WiBox

    addEventHandler!

    Wow at least there's someone here which know how to explain something clearly, thanks!
  3. WiBox

    addEventHandler!

    Mmm what about use onPlayerCommand? As: function Test(command,plr) if ( command =="..." or command =="..." ) then if ( did player change dimension ) then addCommandHandler... command and event handlers end end end addEventHandler("onPlayerCommand", root, Test) The thing is.. I got a CommandHandler which back the player to his last location before he use that command.. And once he write that command he instantly go back to his last location before he use that command.. I'm afraid that he goes back faster than the command will determinate if the player was at dimension 336 and for the 2 other command they can work. Is there a EventHandler which check if the player changed dimension? Or I can create one? as triggerEvent or triggerClientEvent (using the code on server side.) which check if the player changed dimension. Now I don't know if that work or if I can add it in that Test function. Because I didn't understand quite good what it do.. as I see the function it set a element dimension... But I didn't understand what role it do and with what it will help me.. But the thing is I got interested on that triggerEvent onElementDimensionChange, if I can use that so the command handler which I already told what my problem with it can work with that event.. But I need help so I know how to make and add it in the Test function.. Thanks for your help . And sorry for my useless English dictation..
  4. WiBox

    addEventHandler!

    Then what about if I can make a function which example: function isEventHandled() if ( addEventHandler("meds.useMedKitOnOther", root, usemedkitanother ) ) then return true elseif ( removeEventHandler("meds.useMedKitOnOther", root, usemedkitanother) ) then return false end end Timer10 = setTimer( function() for _,plrs in ipairs (getElementsByType("player")) do if ( getElementDimension(plrs) == 0 ) then if ( isEventHandled == true ) then killTimer(Timer10) elseif ( isEventHandled == false ) then resetTimer(Timer10) end addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) end end end, 1000, 0) Does something like that work? I mean use a function for check if addEventHandler added or removed, It didn't work for me.. Because ofc I did something wrong in function isEventHandled, I'm still new at coding and I'm using /debugscript 3 but there's only two thing always get spammed eventhandler... already handled line 20 and 21.. My only problem is to check if the Event is already handled so is there a way like I said so it work? I don't want to remove using med kits from dimension 336 I just want to stop and add it using a command and I made it, when he go back to another dimension I need that the med kits get automatically added and I made it I just want to do something so I check if addEventHandler already handled then killTimer(Timer10) ..
  5. WiBox

    addEventHandler!

    Dude.. Look the med kit should work on any other dimensions, I just want to pause those 4: removeCommandHandler("usemedkit", usethemedkit) removeCommandHandler("acceptmedkit", healOthers) removeEventHandler("meds.giveMedKit", root, giveMedKit) removeEventHandler("meds.useMedKitOnOther", root, usemedkitanother) And I already made that, but the thing is they can leave the dimension by using /leaved So if they left or go back to the main dimension I want those 4 get auto added.. So I tried to loop them and make if one of them already handled of line 3 and 4 so the timer will be destroyed.. I want with a command so in dimension 336 the med kit get enable and disable, I maybe use med kits in dimension 336.. Can you just give me a way as I said? And yeah I'm making it for all player join the dimension 336.. But the thing is I just need a way if he left dimension 336 the med kits command and event handlers will be added automatically.. So I tried using setTimer so it will check every second but the spam in the 2 lines: addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) but the thing is I want to check if 1 of those 2 lines are already handled so I killTimer(Timer10) ...
  6. WiBox

    Images

    hmm? Like I want to put a image on a object on the world... For I feel that I made myself clear.. I want to add a image on a object, but I didn't found a function on MTA wiki page.. Can someone answer without trolling?
  7. WiBox

    Images

    Hello, I was searching on the wiki MTA page but I didn't find what I need, I want to add a image in a specific place not on the player screen as guiCreateStaticImage, I want it in a specific place. I appreciate who can help me Thanks.
  8. WiBox

    addEventHandler!

    So? Is there a way I can make that? Or it's a impossible thing?
  9. WiBox

    addEventHandler!

    The thing is, I want if the player left a specific dimension, He just can go back to dimension 0, I want when he go back to the main dimension those 4 get added.. Because I'll remove them with a command and I want if the player left the dimension so those 4 get added.. function removePlayerMedkits(player) for _,plrs in ipairs(getElementsByType("player")) do if ( getElementDimension (plrs) == 336 ) then removeCommandHandler("usemedkit") removeCommandHandler("acceptmedkit") removeEventHandler("meds.giveMedKit", root, giveMedKit) removeEventHandler("meds.useMedKitOnOther", root, usemedkitanother) end if ( not addCommandHandler("usemedkit", usethemedkit) ) then addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) end end end addCommandHandler("empm", removePlayerMedkits) Now look, I use this command to disable medkits, I want if the players left from dimension 336 the 4 of: addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother get added automatically. Any idea's?
  10. WiBox

    addEventHandler!

    I'll make it simple for you to understand, in this code: Timer10 = setTimer( function () for _,plrs in ipairs(getElementsByType("player")) do if ( getElementDimension(plrs) == 0 ) then addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) end end end, 1000, 0) I want to add after line 8, if ( addEventHandler line 7 and addEventHandler line are already handled ) then killTimer(Timer10) elseif ( addEventHandler line 7 and 8 are not handled ) then resetTimer(Timer10) end Can you make it for me? Or at least give me a example I would be grateful and thanks for your help!
  11. WiBox

    addEventHandler!

    If the Event Handler is already handled*, and if there isn't a way hope someone say that it's not possible..
  12. Timer10 = setTimer( function () for _,plrs in ipairs(getElementsByType("player")) do if ( getElementDimension(plrs) == 0 ) then addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) end end end, 1000, 0) For I feel that I made myself clear, In this code I want to add if; addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) If it's already handled! Is there a way that I check if a Event Handler already handled? Because It seems that which spamming is those addEventHandler if there is a way I can check if they are already handled it will help so much, and thanks for all who helped me here
  13. WiBox

    HELP!

    Thanks, I appreciate what you did for me, Thanks so much
  14. How to check if the function a () -- code.. end addEventHandler("onPlayerCommand", root, a) already handled?
  15. Dude in my last topic, I can make with Timer if this command is removed then it get added and if it wasn't removed then I kill the Timer but the thing is you gave me as a variable and I don't know how to use a variable to check if it's removed or not.. Kind of hard to me as I'm new at coding.. example local isActive = faslse if ( isActive == true ) then removeCommandHandler("usemedkit") isActive = false elseif ( isActive == false ) then addCommandHandler("usemedkit", usemedkits) isActive = true end it means like do: if ( isActive == true ) then killTimer(Timer10) elseif ( isActive == false ) then addCommandHandler("usemedkit", usemedkits) killTimer(Timer10) end something like that?
  16. WiBox

    HELP!

    {Ah. Well, you can use triggerServerEvent with the data and use table.insert to add that data into zones table} I need to do that, but the thing is how to make the format? I mean in the zones table there is: {id = 1, name = "", owner = "", ctrl = "", price = 5000, objects = 0, radio = "", x = , y = , sx = , sy = } I just need to put example this line into the table with table.insert but on the wiki they didn't give a example with triggerServerEvent.. And I'm still a newbie at coding.. That's why I appreciate if you gave me a small example Thanks~
  17. example I want to check if addCommandHandler("usemedkit", usemedkits) already exist example: if ( addCommandHandler("usemedkit", usemedkits) ) then removeCommandHandler("usemedkit") elseif ( removeCommandHandler("usemedkit" ) then addCommandHandler("usemedkit, usemedkits) end I know that this 5 lines don't work but if someone can give me a hint how to check if a specific command is already exist I would appreciate that
  18. WiBox

    Fix a script..

    Thanks for your help @DeadthStrock but it didn't work. I found the broken part of my code, but for I fix it I need the answer on that topic: Thanks for you two helping me
  19. WiBox

    Fix a script..

    You used command handler to back them.. If the player used a command for leave the dimension 336 before I use the command for back his medkits.. how should I back his medkit? Won't work like you told me.. Timer10 = setTimer( function () time0 = 1 for _,plrs in ipairs(getElementsByType("player")) do if ( getElementDimension (plrs) == 0 ) then if ( not addCommandHandler("usemedkit", usethemedkit) ) then addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) end if ( addCommandHandler("usemedkit", usethemedkit) ) then killTimer(Timer10) end if ( getElementDimension (plrs) == 336 ) then if ( addCommandHandler("usemedkit", usethemedkit) ) then killTimer(Timer10) end if ( not addCommandHandler("usemedkit", usethemedkit) ) then resetTimer(Timer10) end if ( addCommandHandler("usemedkit", usethemedkit) ) then killTimer(Timer10) end timer0 = timer0 - 1 if ( timer0 < 0 ) then killTimer(Timer10) end end end end end, 1000, 0) I made the code and it worked! But I just need to stop the spam which come from the lines 9 and 10. I need a way to kill the timer once the commandhandler and event handler get added.. https://imgur.com/a/nHDP3Nv This spam I mean..
  20. WiBox

    Fix a script..

    Dude I'll explain from the beginning, I made a code which if the player go back to the main dimension it re add: addCommandHandler("usemedkit", usethemedkit) addCommandHandler("acceptmedkit", healOthers) addEventHandler("meds.giveMedKit", root, giveMedKit) addEventHandler("meds.useMedKitOnOther", root, usemedkitanother) Those 4 I remove them with a command and I can back them with a command, but if he goes back to the main dimension I want for those 4 get added automatically. That's all
  21. WiBox

    Fix a script..

    Man I made a Timer so It work automaticly, I want to do that without use a command or should I use a EventHandler?
  22. onPlayerCommand specify all command available I want to specify one command only one.
  23. WiBox

    Fix a script..

    That's why I'm trying to kill the Timer, I just want it too add one time the command handler if it wasn't created.. I need a way that, if the command handler already created then the timer get destroyed, any hints please?
  24. WiBox

    Fix a script..

    I made a script which disable medkits in dimension 336. the thing is, it work but it spam that addEventHandler ['meds.useMedKit with this function is already handled] I want a way for I stop that spam, those spam come from the 2 lines 9, 10.
×
×
  • Create New...