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

[EO 2.0] Timer


Keny14
 Share

Recommended Posts

Hello,
So, I'm in coding a speed system: when player click in an icon, his speed is x2.
I've did all and work fine, just one problem, I wanna every 1s player lost -5% MP, and I don't how to do this.

Thank you for your help.
Link to comment
Share on other sites

No else seems to be willing to help so I'll try and help you :cheesy: First off is an example on how to work with timers written by Soul:

>! I decided to write up an example timer to show you how to do it:
>! First, under:
```
Dim tmr25 As Long, tmr500 As Long, tmr1000 As Long
```
add:
```
Dim KickTimer As Long ' declare the new timer
```
Then find:
```
If Not CPSUnlock Then Sleep 1
```
and above it add:
```
If Tick > KickTimer Then ' is it time to check for kicking people?
  For i = 1 To Player_HighIndex ' go through all the active players
      If TempPlayer(i).LastActive < Tick Then ' have they been active recently?
        Call AlertMsg(i, "You have been kicked for inactivity!") ' kick them
      End If
  Next
  KickTimer = Tick + 30000 ' CHECK if we should kick them again in 30 seconds
End If
>! ```
Please note that the player is not always index (it could be Attacker, for attacking a player). Different "activity" resets might need different variable names.
Code: [Select]
>! TempPlayer(Index).LastActive = GetTickCount + 600000
>! Note that 600000 is equal to 10 minutes.

So what you need to do first is have something that can tell our timer code that the player is on x2 speed, for this we use a Boolean value.

Find the 'PlayerRec' in 'modTypes' and below this:
```
Dir As Byte
```
Add:
```
dSpeed As Boolean
```
Now simple have the Boolean value set to 'True' when the player doubles his speed. Next we need to add in the timer. Timer should be added in the sub 'ServerLoop' in 'modServerLoop'. I won't do all the work but following Soul's example should give you an idea on how to setup the timer. Once you have the timer setup all you need to do is loop through all the players and check if '.dSpeed = True', if so you reduce their MP using:

```
Call SetPlayerVital(index, Vitals.MP, GetPlayerVital(index, MP) - 5)
```
Hoped that helped :cheesy:
Link to comment
Share on other sites

@Ryoku:

> Zesh, I'm assuming you mean to do all that in the modServerLoop on the Server, because you failed to tell the mod and sub where you would start this. It just makes it easier to do.

@Zesh:

> Timer should be added in the sub 'ServerLoop' in 'modServerLoop'.

I did mention it :cheesy:
Link to comment
Share on other sites

I can't find them too >_< I've found this:
```
Dim tmr25 As Long
Dim tmr100 As Long
Dim tmr10000 As Long
```But in sub Gameloop

@Zesh:

> Now simple have the Boolean value set to 'True' when the player doubles his speed. Next we need to add in the timer. Timer should be added in the sub 'ServerLoop' in 'modServerLoop'. I won't do all the work but following Soul's example should give you an idea on how to setup the timer. Once you have the timer setup all you need to do is loop through all the players and check if '.dSpeed = True',

^^' I don't understand :/ I know it's boring, but If you can help me to install it, that will be very useful >_< thank you.
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...