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

Need a Serverside Timer


Kirby4tw
 Share

Recommended Posts

Hey,

I need a Timer for 10 seconds ( 10000 ) after a if statement is true.
How i can set a timer in the serverside source? I found this one:

```
If GetTickCount >= GiveHPTimer + HP_TIMER Then
                    For I = 1 To MAX_PLAYERS
                        If IsPlaying(I) Then
                            If GetPlayerHP(I) < GetPlayerMaxHP(I) Then
                                Call SetPlayerHP(I, GetPlayerHP(I) + GetPlayerHPRegen(I))
                                Call SendHP(I)
                            End If
                        End If
                    Next I
                        GiveHPTimer = GetTickCount
                    End If

```

But how to use this for my own values?
Thanks =)

<(Kirby4tw)>
Link to comment
Share on other sites

first of all, I would recommend just adding a new spell type.

When the buff is done, send a packet to the client with the info that your buffed (add a icon in the corner f.e.).

now you have 2 options
- add a timer and use that as the 20 sec reference
    * enable the timer at receiving packets
    * set the value to 20000
    * when it goes off, send packet to server to debuff
    * disable timer

- using tickcount
    * basically the same, but then in a if statement.

Thats the basic thinking of a buff/debuff, good luck
Link to comment
Share on other sites

Dont use timers… better way its TickCount.

To make it make declaration od new variable on the top. Write bottom this:
```
Public GiveHPTimer As Long
Public GiveMPTimer As Long
Public GiveSPTimer As Long
Public GiveNPCHPTimer As Long

Public Timer10s As Long
```

after that go to this place what you qouted:

```
                If MapNPC(y, x).num > 0 Then
                    If TickCount > GiveNPCHPTimer + 10000 Then
                        If MapNPC(y, x).HP > 0 Then
                            MapNPC(y, x).HP = MapNPC(y, x).HP + GetNpcHPRegen(NpcNum)

                            ' Check if they have more then they should and if so just set it to max
                            If MapNPC(y, x).HP > GetNPCMaxHP(NpcNum) Then
                                MapNPC(y, x).HP = GetNPCMaxHP(NpcNum)
                            End If
                        End If
                    End If

'write this: 

                    If GetTickCount > Timer10s + 10000 Then
'here will be your 10second loop:
                    End If
                End If

```
and last thing what you must do find that:

> ' Make sure we reset the timer for npc hp regeneration
>     If GetTickCount > GiveNPCHPTimer + 10000 Then
>         GiveNPCHPTimer = GetTickCount
>     End If

and add bottom this like that:

> ' reset 10s timer:
>     If GetTickCount > Timer10s + 10000 Then
>         Timer10s = GetTickCount
>     End If

And thats all.
Now you can place everything you want in this field what i marked "here will be your 10second loop".
Hope you will make it.
Link to comment
Share on other sites

Uhh, when you create a timer in the server like this, won't it wait for every piece of code untill the tickcount is over?

And when you create a timer on the form, you would have to make one from 1 to MAX_PLAYERS, which would be unstarted work…
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...