Kirby4tw Posted October 10, 2009 Author Share Posted October 10, 2009 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 More sharing options...
Tyr Posted October 10, 2009 Share Posted October 10, 2009 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 More sharing options...
Kirby4tw Posted October 11, 2009 Author Share Posted October 11, 2009 Hey Thank you.One Question.How i can Use a Timer in the Serverside-sourcecode?Whats the Call?Call SetTimer(…) Is not workingWhats the solution?Thank you :)<(Kirby4tw)> Link to comment Share on other sites More sharing options...
Patrick Posted October 11, 2009 Share Posted October 11, 2009 I think calling the timer only works after it's been created. Link to comment Share on other sites More sharing options...
Kirby4tw Posted October 12, 2009 Author Share Posted October 12, 2009 Please tell my, how to use Tickcounts for a Timer.Need timer for 10 seconds :OThx<(Kirby4tw)> Link to comment Share on other sites More sharing options...
Ruins of Hell Posted October 12, 2009 Share Posted October 12, 2009 Call SetTimer ("Timer", 10000) Link to comment Share on other sites More sharing options...
Kirby4tw Posted October 12, 2009 Author Share Posted October 12, 2009 And where is the TImerSub for the event after 10000ms ?^^ Link to comment Share on other sites More sharing options...
Ruins of Hell Posted October 12, 2009 Share Posted October 12, 2009 Gotta make one yourself. Link to comment Share on other sites More sharing options...
Kirby4tw Posted October 12, 2009 Author Share Posted October 12, 2009 Call SetTimer ("Timer", 10000)Sub Timer()…statement...End Sub? Link to comment Share on other sites More sharing options...
Ruins of Hell Posted October 12, 2009 Share Posted October 12, 2009 Yes. Link to comment Share on other sites More sharing options...
Kirby4tw Posted October 12, 2009 Author Share Posted October 12, 2009 Theres no SetTimer Command what i can use in ModGamelogic on Serverside Engine… Link to comment Share on other sites More sharing options...
Kimimaru Posted October 12, 2009 Share Posted October 12, 2009 Put this Sub anywhere in **modServerTCP**:```Sub SetTimer(ByVal Name As String, ByVal Interval As Long) Call AddNewTimer(Name, Interval)End Sub```Now you should be able to set your own timers in the source using the **Call SetTimer** command. Link to comment Share on other sites More sharing options...
Kirby4tw Posted October 12, 2009 Author Share Posted October 12, 2009 I already try this, but dont work. Link to comment Share on other sites More sharing options...
Tyr Posted October 13, 2009 Share Posted October 13, 2009 i'll help you out when I have time Kirby, pm me again. Link to comment Share on other sites More sharing options...
Fred Posted October 15, 2009 Share Posted October 15, 2009 Dont use timers… better way its TickCount.To make it make declaration od new variable on the top. Write bottom this:```Public GiveHPTimer As LongPublic GiveMPTimer As LongPublic GiveSPTimer As LongPublic GiveNPCHPTimer As LongPublic 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 Ifand add bottom this like that:> ' reset 10s timer:> If GetTickCount > Timer10s + 10000 Then> Timer10s = GetTickCount> End IfAnd 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 More sharing options...
Tyr Posted October 15, 2009 Share Posted October 15, 2009 I helped him out already Fred… we used exact the same code though :D Link to comment Share on other sites More sharing options...
Fred Posted October 15, 2009 Share Posted October 15, 2009 Ok, thats great:) Link to comment Share on other sites More sharing options...
anasky Posted October 15, 2009 Share Posted October 15, 2009 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 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