Matt Posted April 2, 2013 Author Share Posted April 2, 2013 Don't you hate it when you're player killing and your opponent spam clicks the healing potions to full health? This tutorial will make sure that you can only consume one item every second.This has only been tested on EO 2.0, but it should work on multiple other engines.Go into your server, and look for TempPlayerRec. At the bottom of the rec, put there```FreeAction As Boolean```Now look for```Case ITEM_TYPE_KEY```Right above that, put there this```TempPlayer(index).FreeAction = False```Now look for```Case ITEM_TYPE_CONSUME```And right under that, put there this``` If TempPlayer(index).FreeAction = False Then Exit Sub End If```Now look for```If Tick > tmr1000 Then```Under it, put there``` For i = 1 To Player_HighIndex If TempPlayer(i).FreeAction = False Then TempPlayer(i).FreeAction = True Next```Save, compile, and enjoy! ![^_^](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/happy.png) Link to comment Share on other sites More sharing options...
Alerd Posted April 2, 2013 Share Posted April 2, 2013 Thanx ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
Matt Posted April 2, 2013 Author Share Posted April 2, 2013 No problem! ![^_^](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/happy.png) Enjoy! Link to comment Share on other sites More sharing options...
abhi2011 Posted April 3, 2013 Share Posted April 3, 2013 Yay, another short tutorial. Link to comment Share on other sites More sharing options...
Wortel Angels Posted April 3, 2013 Share Posted April 3, 2013 Would be better if you can choose the Time which it need till you can re-use it again but thats very nice too :-) Link to comment Share on other sites More sharing options...
Matt Posted April 3, 2013 Author Share Posted April 3, 2013 > Would be better if you can choose the Time which it need till you can re-use it again but thats very nice too :-)All you need to know is how serverLoop works.GetTickCount is a number that keeps going up. An interval of 1000 is equivalent to one second. So if you wanted to make it only every two seconds, declare a variable callled tmr2000\. Then put there in the "do while"```If getTickCount > tmr2000 then 'checking if its been two seconds'Code that happens every two seconds goes heretmr2000 = getTickCount + 2000 'setting tmr2000 to the current time + two secondsEnd if``` Link to comment Share on other sites More sharing options...
erkro1 Posted April 3, 2013 Share Posted April 3, 2013 This isn't very efficiënt, since it not always the same amount of time, the server takes the code every 1 second, even if no player is healing and such but that makes it that some players can eat it in 0.1 seconds (if the server receives packet of them eating it 0.1 second before it hits the 1 second loop) and some might have it 0.9 seconds.Just look at how it's done with health regeration (it has also a timer value inside the TempPlayerRec so that everyone heals after x seconds)I hope you understand this. Link to comment Share on other sites More sharing options...
Matt Posted April 3, 2013 Author Share Posted April 3, 2013 > This isn't very efficiënt, since it not always the same amount of time, the server takes the code every 1 second, even if no player is healing and such but that makes it that some players can eat it in 0.1 seconds (if the server receives packet of them eating it 0.1 second before it hits the 1 second loop) and some might have it 0.9 seconds.> > Just look at how it's done with health regeration (it has also a timer value inside the TempPlayerRec so that everyone heals after x seconds)> > I hope you understand this.I didn't think about that. Thank you for pointing it out!Although it isn't as efficient as it should be, it still prevents spam eating. Link to comment Share on other sites More sharing options...
Wortel Angels Posted April 3, 2013 Share Posted April 3, 2013 > All you need to know is how serverLoop works.> > GetTickCount is a number that keeps going up. An interval of 1000 is equivalent to one second. So if you wanted to make it only every two seconds, declare a variable callled tmr2000\. Then put there in the "do while"> > ```> > If getTickCount > tmr2000 then 'checking if its been two seconds> > 'Code that happens every two seconds goes here> > tmr2000 = getTickCount + 2000 'setting tmr2000 to the current time + two seconds> > End if> > ```I know how but the Newbies here not ;-) Link to comment Share on other sites More sharing options...
Alerd Posted September 24, 2013 Share Posted September 24, 2013 I dont understand why dont work ;/ none debug , error ;/ Link to comment Share on other sites More sharing options...
Domino_ Posted January 22, 2014 Share Posted January 22, 2014 This should work```If TempPlayer(i).FreeAction = False Then If Tick > tmr1000 Then For i = 1 To Player_HighIndex If TempPlayer(i).FreeAction = False Then TempPlayer(i).FreeAction = True Next End If End If```Add before```If Tick > tmr1000 Then``` Link to comment Share on other sites More sharing options...
Richy420Rich Posted January 22, 2014 Share Posted January 22, 2014 The correct way would be to just add a scroll bar in your item editor, this will define the usage of the consumables.Item(EditorIndex).ConsumeInterval = (scrlbarInterval.value * 1000)Then you can use a player variable to add on the ConsumeInterval.Before eating the item:If TempPlayer(index).LockConsume = True Then Exit SubAfter eating the item:TempPlayer(index).ConsumeInterval = GetTickCount + Item(ItemNum).ConsumeIntervalTempPlayer(index).LockConsume = TrueAnd you can run a check in the server loop to check it, use an iteration that already loops all players, and you save a re-iteration.If TempPlayer(i).LockConsume = True ThenIf TempPlayer(i).ConsumeInterval <= GetTickCount ThenTempPlayer(i).LockConsume = FalseTempPlayer(i).ConsumeInterval = 0End IfEnd IfThe end result is beautiful, I can drink a potion faster than I can eat a pie. ;) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now