|
You last visited: Today at 04:01
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.
10/19/2018, 11:20
|
#1
|
elite*gold: 0
Join Date: Aug 2017
Posts: 26
Received Thanks: 1
|
How I can add daily rewards on my server? :)
Im searching a way to add daily rewards.
|
|
|
10/19/2018, 11:29
|
#2
|
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
|
|
|
10/27/2018, 12:58
|
#3
|
elite*gold: 0
Join Date: Jun 2018
Posts: 27
Received Thanks: 2
|
RewardHelper.cs
|
|
|
10/27/2018, 20:45
|
#4
|
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
|
|
|
10/27/2018, 21:06
|
#5
|
elite*gold: 110
Join Date: Jun 2016
Posts: 573
Received Thanks: 191
|
Quote:
Originally Posted by Singleplayer™
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
|
|
|
10/27/2018, 21:53
|
#6
|
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;
|
|
|
10/27/2018, 22:05
|
#7
|
elite*gold: 3
Join Date: Feb 2016
Posts: 1,287
Received Thanks: 321
|
this works too .... lul
|
|
|
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);
}
|
|
|
10/27/2018, 23:25
|
#9
|
elite*gold: 3
Join Date: Feb 2016
Posts: 1,287
Received Thanks: 321
|
Quote:
Originally Posted by Fizo55
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 ...
|
|
|
10/28/2018, 03:39
|
#10
|
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.
|
|
|
10/28/2018, 07:06
|
#11
|
elite*gold: 0
Join Date: Jan 2011
Posts: 326
Received Thanks: 26
|
Quote:
Originally Posted by MANUEL PERES
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.
|
|
|
10/28/2018, 09:01
|
#12
|
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...
|
|
|
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
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);
|
|
|
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.
|
|