Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[EO] Consume Item Delay


Matt
 Share

Recommended Posts

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

> 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 here

tmr2000 = getTickCount + 2000 'setting tmr2000 to the current time + two seconds

End if

```
Link to comment
Share on other sites

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

> 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

> 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

  • 5 months later...
  • 3 months later...
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

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 Sub

After eating the item:

TempPlayer(index).ConsumeInterval = GetTickCount + Item(ItemNum).ConsumeInterval

TempPlayer(index).LockConsume = True

And 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 Then

If TempPlayer(i).ConsumeInterval <= GetTickCount Then

TempPlayer(i).LockConsume = False

TempPlayer(i).ConsumeInterval = 0

End If

End If

The end result is beautiful, I can drink a potion faster than I can eat a pie. ;)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...