Keny14 Posted March 28, 2012 Author Share Posted March 28, 2012 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 More sharing options...
abhi2011 Posted March 28, 2012 Share Posted March 28, 2012 U mean spells add it as a spell type Link to comment Share on other sites More sharing options...
Keny14 Posted March 28, 2012 Author Share Posted March 28, 2012 No, I don't mean spells. ^^' Link to comment Share on other sites More sharing options...
abhi2011 Posted March 28, 2012 Share Posted March 28, 2012 if button press thenmp loss 5% or something Link to comment Share on other sites More sharing options...
Keny14 Posted March 28, 2012 Author Share Posted March 28, 2012 @abhi2011:> if button press then> mp loss 5% or somethingI don't know how to do this something xD.I think it's need a timer or something else. x_x Link to comment Share on other sites More sharing options...
abhi2011 Posted March 29, 2012 Share Posted March 29, 2012 nope. Timer just gets the tick/second count. it has nothing do with it. Just make ur sprite go faster. Link to comment Share on other sites More sharing options...
Keny14 Posted March 29, 2012 Author Share Posted March 29, 2012 I don't need the code to make player's speed x2, I've did it. I need the code to remove -5%mp every 1s. Link to comment Share on other sites More sharing options...
PD Posted March 29, 2012 Share Posted March 29, 2012 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 secondsEnd 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 More sharing options...
RyokuHasu Posted March 29, 2012 Share Posted March 29, 2012 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. Link to comment Share on other sites More sharing options...
PD Posted March 29, 2012 Share Posted March 29, 2012 @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 More sharing options...
RyokuHasu Posted March 29, 2012 Share Posted March 29, 2012 XD i didnt see it and still cant find it… >.< but that just makes me feel like an idiot XD Link to comment Share on other sites More sharing options...
Keny14 Posted March 29, 2012 Author Share Posted March 29, 2012 I can't find them too >_< I've found this:```Dim tmr25 As LongDim tmr100 As LongDim 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 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