Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Nostale
You last visited: Today at 04:01

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



How I can add daily rewards on my server? :)

Discussion on How I can add daily rewards on my server? :) within the Nostale forum part of the MMORPGs category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Aug 2017
Posts: 26
Received Thanks: 1
Question How I can add daily rewards on my server? :)

Im searching a way to add daily rewards.
yeyeyeeee is offline  
Old 10/19/2018, 11:29   #2

 
Blowa's Avatar
 
elite*gold: 48
Join Date: Jan 2010
Posts: 647
Received Thanks: 1,789
Learn programming.

What you want to do :
OnPlayerConnection : Check if the player has already got the daily gift
If DailyGiftNotGivenYet
GiftTonOfMoney

Blowa is offline  
Old 10/27/2018, 12:58   #3
 
elite*gold: 0
Join Date: Jun 2018
Posts: 27
Received Thanks: 2
RewardHelper.cs
[NH]Pyro is offline  
Old 10/27/2018, 20:45   #4


 
Singleplayer™'s Avatar
 
elite*gold: 3
Join Date: Feb 2016
Posts: 1,287
Received Thanks: 321
how val already wrote , write a new function for the daily reward , which works like this :
-check last given reward (use a new table on db for this)
-if LastRewardDate != DateOfToday then -> give out the reward to player and set the dateoftoday as LastRewardDate (in db)
and put this function to the OnPlayerConnect event ...
this is maybe not the best solution but it works
Singleplayer™ is offline  
Old 10/27/2018, 21:06   #5
 
elite*gold: 110
Join Date: Jun 2016
Posts: 573
Received Thanks: 191
Quote:
Originally Posted by Singleplayer™ View Post
how val already wrote , write a new function for the daily reward , which works like this :
-check last given reward (use a new table on db for this)
-if LastRewardDate != DateOfToday then -> give out the reward to player and set the dateoftoday as LastRewardDate (in db)
and put this function to the OnPlayerConnect event ...
this is maybe not the best solution but it works
Or you can use GeneralLog to check if we've already had the Daily reward
Fizo55 is offline  
Thanks
1 User
Old 10/27/2018, 21:53   #6
 
MANUEL PERES's Avatar
 
elite*gold: 0
Join Date: May 2012
Posts: 297
Received Thanks: 74

Code:
if (Session.Character.LastLogin.Date != DateTime.Now.Date)
            {
                Session.Character.SpAdditionPoint += Session.Character.SpPoint;
                Session.Character.SpPoint = 10000;

                short[] rewardItems = { 1011, 1011, 1011, 1011, 1011 };
                byte[] rewardCount = { 1, 2, 3, 4, 5 };

                int rnd = new Random().Next(rewardItems.Length - 1);

                Session.Character.GiftAdd(rewardItems[rnd], rewardCount[rnd]);
                Session.Character.GenerateSay($"You received your daily reward: {ServerManager.GetItem(rewardItems[rnd]).Name} x {rewardCount[rnd]}", 14);

            }
            Session.Character.LastLogin = DateTime.Now;
MANUEL PERES is offline  
Thanks
2 Users
Old 10/27/2018, 22:05   #7


 
Singleplayer™'s Avatar
 
elite*gold: 3
Join Date: Feb 2016
Posts: 1,287
Received Thanks: 321
this works too .... lul
Singleplayer™ is offline  
Old 10/27/2018, 22:20   #8
 
elite*gold: 110
Join Date: Jun 2016
Posts: 573
Received Thanks: 191
Code:
var LastDaily = Session.Character.GeneralLogs.LastOrDefault(s => s.LogData == "World" && s.LogType == "Daily" && s.CharacterId == Session.Character.CharacterId && s.Timestamp.Day == DateTime.Now.Day);
if(LastDaily == null)
{
	//Give your item
	var GeneralLogAdd = new GeneralLogDTO
	{
		LogData = "World",
		LogType = "Daily",
		CharacterId = Session.Character.CharacterId,
		AccountId = Session.Account.AccountId,
		Timestamp = DateTime.Now
	};
	DAOFactory.GeneralLogDAO.InsertOrUpdate(GeneralLogAdd);
}
Fizo55 is offline  
Thanks
2 Users
Old 10/27/2018, 23:25   #9


 
Singleplayer™'s Avatar
 
elite*gold: 3
Join Date: Feb 2016
Posts: 1,287
Received Thanks: 321
Quote:
Originally Posted by Fizo55 View Post
Code:
var LastDaily = Session.Character.GeneralLogs.LastOrDefault(s => s.LogData == "World" && s.LogType == "Daily" && s.CharacterId == Session.Character.CharacterId && s.Timestamp.Day == DateTime.Now.Day);
if(LastDaily == null)
{
	//Give your item
	var GeneralLogAdd = new GeneralLogDTO
	{
		LogData = "World",
		LogType = "Daily",
		CharacterId = Session.Character.CharacterId,
		AccountId = Session.Account.AccountId,
		Timestamp = DateTime.Now
	};
	DAOFactory.GeneralLogDAO.InsertOrUpdate(GeneralLogAdd);
}
nice °-° , can u maybe explain the first line a lil bit more there are some strange things i cant understand there ...
Singleplayer™ is offline  
Old 10/28/2018, 03:39   #10
 
0Lucifer0's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,019
Manuel peres solution is a lot better.
For the answer it just get the last reward log of today. If null this mean there is no log so no reward.
0Lucifer0 is offline  
Thanks
1 User
Old 10/28/2018, 07:06   #11
 
elite*gold: 0
Join Date: Jan 2011
Posts: 326
Received Thanks: 26
Quote:
Originally Posted by MANUEL PERES View Post

Code:
if (Session.Character.LastLogin.Date != DateTime.Now.Date)
            {
                Session.Character.SpAdditionPoint += Session.Character.SpPoint;
                Session.Character.SpPoint = 10000;

                short[] rewardItems = { 1011, 1011, 1011, 1011, 1011 };
                byte[] rewardCount = { 1, 2, 3, 4, 5 };

                int rnd = new Random().Next(rewardItems.Length);

                Session.Character.GiftAdd(rewardItems[rnd], rewardCount[rnd]);
                Session.Character.GenerateSay($"You received your daily reward: {ServerManager.GetItem(rewardItems[rnd]).Name} x {rewardCount[rnd]}", 14);

            }
            Session.Character.LastLogin = DateTime.Now;

Where add this.
lorenx911 is offline  
Old 10/28/2018, 09:01   #12
 
0Lucifer0's Avatar
 
elite*gold: 0
Join Date: May 2009
Posts: 1,005
Received Thanks: 1,019
... common at least understand before copy past... obviously you put it on the connection...
0Lucifer0 is offline  
Old 10/28/2018, 09:31   #13

 
elite*gold: 64
Join Date: May 2011
Posts: 1,229
Received Thanks: 854
Quote:
Originally Posted by MANUEL PERES View Post

Code:
if (Session.Character.LastLogin.Date != DateTime.Now.Date)
            {
                Session.Character.SpAdditionPoint += Session.Character.SpPoint;
                Session.Character.SpPoint = 10000;

                short[] rewardItems = { 1011, 1011, 1011, 1011, 1011 };
                byte[] rewardCount = { 1, 2, 3, 4, 5 };

                int rnd = new Random().Next(rewardItems.Length);

                Session.Character.GiftAdd(rewardItems[rnd], rewardCount[rnd]);
                Session.Character.GenerateSay($"You received your daily reward: {ServerManager.GetItem(rewardItems[rnd]).Name} x {rewardCount[rnd]}", 14);

            }
            Session.Character.LastLogin = DateTime.Now;
Btw fix ur crash (IndexOutOfRangeException)
Code:
int rnd = new Random().Next(rewardItems.Length - 1);
BladeTiger12 is offline  
Thanks
2 Users
Reply


Similar Threads Similar Threads
gate waves end rewards+event rewards
09/15/2012 - DarkOrbit - 35 Replies
i give a list of all rewards of gate's end events. olsow the waves of the gate's to safe peaple some work . i'm not chure i post it in the right section. feel free to drag it to the right one. i hope this helped some peaple. greets. *kaat* 1. alpha gate: NPC waves 40 Streuners



All times are GMT +1. The time now is 04:05.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.