Matt Posted October 24, 2012 Author Share Posted October 24, 2012 Many games use a system in which the players are rewarded for playing every day. I managed to apply this to Eclipse.Lets start off client side.Go to the bottom of PlayerRec and put there```DailyValue As Long```Look for```Function GetPlayerExp(ByVal Index As Long) As Long```and underneath that function, put there```Sub SetPlayerDailyValue(ByVal Index As Long, ByVal DailyValue As Long)' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandlerIf Index > MAX_PLAYERS Then Exit SubPlayer(Index).DailyValue = DailyValue' Error handlerExit Suberrorhandler:HandleError "SetPlayerDailyValue", "modDatabase", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Now go to to HandlePlayerData and put there```Call SetPlayerDailyValue(i, Buffer.ReadLong)```underneath```Call SetPlayerPK(i, Buffer.ReadLong)```Save and compile.Onward to the server!Click on the Control tab and check to see if you have enough room to put there about 4 medium sized labels and a command button.If not, then use this to make a new tab.Click on the SSTab1 and find in it's properties "Tabs" and "Tabs per Row"Change Tabs per Row to 4, and **then** change Tabs to 4.Now right click over SSTab1 and hit properties. You'll see Current Tab and TabCaption. Go to 3 on the Current Tab, and then you can change the name of the tab.Now that you have some room to work, lets put in those 4 labels and command button. I made mine look like this.![](http://www.freemmorpgmaker.com/files/imagehost/pics/d682cfe6762cc603d8ccc6c23326cb24.png)Please note that the text Current Value: and Last Daily Set: are separate from the 0 and Unknown. **Remember; there are four labels altogether.**Name the 0 label lblDailyValueName the Unkown label lblLastDateDouble click on the button and put there```Call SetDailyValues```Look for Private Sub Form_Load()Put there```Call DailyValues```Now go to the bottom of the Server code and put there this```Private Function DailyValues()Dim CurrentDate1 As DateDim CurrentDate2 As StringDim i As StringIf Dir(App.Path & "\data\DailyValueDate.txt") <> "" ThenIf Dir(App.Path & "\data\DailyValue.txt") <> "" Then Open App.Path & "\data\DailyValueDate.txt" For Input As #1 Input #1, i Close #1 lblLastDate.Caption = i Open App.Path & "\data\DailyValue.txt" For Input As #1 Input #1, i Close #1 lblDailyValue.Caption = i CurrentDate1 = DateValue(Now) CurrentDate2 = CurrentDate1 If CurrentDate2 <> lblLastDate.Caption Then Call SetDailyValues End IfEnd IfElseOpen App.Path & "\data\DailyValueDate.txt" For Output As #1Print #1, "0"Close #1Open App.Path & "\data\DailyValue.txt" For Output As #1Print #1, "0"Close #1Call SetDailyValuesEnd IfEnd FunctionPrivate Function SetDailyValues()Dim CurrentDate1 As DateDim CurrentDate2 As StringDim NewValue As StringDim i As LongCurrentDate1 = DateValue(Now)CurrentDate2 = CurrentDate1lblLastDate.Caption = CurrentDate2Open App.Path & "\data\DailyValueDate.txt" For Output As #1Print #1, lblLastDate.CaptionClose #1lblDailyValue.Caption = lblDailyValue.Caption + 1Open App.Path & "\data\DailyValue.txt" For Output As #1Print #1, lblDailyValue.CaptionClose #1For i = 1 To MAX_PLAYERSIf Player(i).DailyValue <> frmServer.lblDailyValue.Caption Then If FindOpenInvSlot(i, 1) = 0 Then PlayerMsg i, "You can get your daily reward, but you need to login with room in your inventory first.", BrightRed End If If FindOpenInvSlot(i, 1) <> 0 Then GiveInvItem i, 1, 0 PlayerMsg i, "You have acquired a daily reward!", White Player(i).DailyValue = frmServer.lblDailyValue.Caption End IfEnd IfNextEnd Function```Now look for```Private Sub HandleLogin(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)```Right after this chunk of code```' Show the player up on the socket statusCall AddLog(GetPlayerLogin(index) & " has logged in from " & GetPlayerIP(index) & ".", PLAYER_LOG)Call TextAdd(GetPlayerLogin(index) & " has logged in from " & GetPlayerIP(index) & ".")```Put there``` If Player(index).DailyValue <> frmServer.lblDailyValue.Caption Then If FindOpenInvSlot(index, 1) = 0 Then PlayerMsg index, "You can get your daily reward, but you need to login with room in your inventory first.", BrightRed End If If FindOpenInvSlot(index, 1) <> 0 Then GiveInvItem index, 1, 0 PlayerMsg index, "You have acquired a daily reward!", White Player(index).DailyValue = frmServer.lblDailyValue.Caption End If End If```Lastly, to make the DailyValue on the server side. Go to modTypes and go to PlayerRec. At the bottom, put there```DailyValue As Long```Find Function GetPlayerAccess(ByVal index As Long) As Long and right above it, put there this```Function GetPlayerDailyValue(ByVal index As Long) As LongIf index > MAX_PLAYERS Then Exit FunctionGetPlayerDailyValue = Player(index).DailyValueEnd Function```Now go to Function PlayerData(ByVal index As Long) As Byte() and put there this```Buffer.WriteLong GetPlayerDailyValue(index)```And that should be it! Save it, compile it, and enjoy. Link to comment Share on other sites More sharing options...
iSnow Posted October 24, 2012 Share Posted October 24, 2012 Looks good Matthew, rewards people for playing. Link to comment Share on other sites More sharing options...
Matt Posted October 24, 2012 Author Share Posted October 24, 2012 Thank you! That was the idea ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
Guest Posted October 24, 2012 Share Posted October 24, 2012 Why are you using functions when you're returning no values (DailyValues and SetDailyValues)? Link to comment Share on other sites More sharing options...
Alerd Posted October 24, 2012 Share Posted October 24, 2012 shell works ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png) Link to comment Share on other sites More sharing options...
Matt Posted October 24, 2012 Author Share Posted October 24, 2012 > Why are you using functions when you're returning no values (DailyValues and SetDailyValues)?Ah yes you have a good point. I'm not the best programmer. The way I learnt was solely "hands on". I used functions ever since I started using VB6 not entirely understanding what they were supposed to do. Its just out of bad habit that I use them, and me not thinking properly.> do not work terribly many mistakes crashes; X> > as there is with the player socker or expI'll look into it. I haven't gotten that error. When does it happen? Link to comment Share on other sites More sharing options...
Alerd Posted October 24, 2012 Share Posted October 24, 2012 shell works ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)Only occasionally is any error with socket Link to comment Share on other sites More sharing options...
abhi2011 Posted October 25, 2012 Share Posted October 25, 2012 @SekaruSo what should be used to return nothing? Subs? Link to comment Share on other sites More sharing options...
Matt Posted November 5, 2012 Author Share Posted November 5, 2012 > @Sekaru> > So what should be used to return nothing? Subs?Yes. Subs return nothing. Link to comment Share on other sites More sharing options...
abhi2011 Posted November 6, 2012 Share Posted November 6, 2012 Just like voids. Link to comment Share on other sites More sharing options...
Scorge Posted May 3, 2013 Share Posted May 3, 2013 I'm lost with this, can you post pictures of a walkthrough? Link to comment Share on other sites More sharing options...
Matt Posted May 3, 2013 Author Share Posted May 3, 2013 Which bit is troubling you? Link to comment Share on other sites More sharing options...
Scorge Posted May 3, 2013 Share Posted May 3, 2013 Pretty much the beginning to end. Link to comment Share on other sites More sharing options...
Matt Posted May 4, 2013 Author Share Posted May 4, 2013 I've just gone over the entire thing, and it's rather simple. I don't see a purpose of screenshotting the entire thing. I can either help you out in person, or upload a vanilla engine with this system in it for you to compare it to. Link to comment Share on other sites More sharing options...
Daneta Posted May 4, 2013 Share Posted May 4, 2013 > I've just gone over the entire thing, and it's rather simple. I don't see a purpose of screenshotting the entire thing. I can either help you out in person, or upload a vanilla engine with this system in it for you to compare it to.do that plss Link to comment Share on other sites More sharing options...
imamPeewee Posted May 5, 2013 Share Posted May 5, 2013 Available in EA..? Link to comment Share on other sites More sharing options...
abhi2011 Posted May 5, 2013 Share Posted May 5, 2013 Yes it will. Link to comment Share on other sites More sharing options...
Domino_ Posted June 28, 2013 Share Posted June 28, 2013 You should add that everyone gets random item between selected like rdm(3,5,20) and one player gets item 20 other item 5\. :)Also there should need to add automatic reset, so it would be easyer. :) Link to comment Share on other sites More sharing options...
Matt Posted June 28, 2013 Author Share Posted June 28, 2013 > You should add that everyone gets random item between selected like rdm(3,5,20) and one player gets item 20 other item 5\. :)> > Also there should need to add automatic reset, so it would be easyer. :)This is meant to be a base. Feel free to tweak it ^_^ What do you mean by "Automatic reset"? Link to comment Share on other sites More sharing options...
Domino_ Posted June 28, 2013 Share Posted June 28, 2013 That you dont need to press the reset button by yourself, but he automatically does that every day @ 22:00 or every seven days @ some time. Link to comment Share on other sites More sharing options...
Domino_ Posted January 22, 2014 Share Posted January 22, 2014 ~~You need to change~~```For i = 1 To MAX_PLAYERS```~~to~~```For i = 0 To MAX_PLAYERS If i = 0 Then Exit Function```~~Or you will getsome socket errors.~~Damn im getting error what i did wrong? :D[attachment=1084:errrrrrr.png] 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