How to make it one time only?

04/12/2011 01:13 BlackCitadel#1
Hello,

I made a new NPC that gives the player 1000 CPs, but it keeps giving him CPs everytime he speaks to him, I want it to give him 1000 CPs one time only for the new player, how can I do that?
Here is the code:

#region GiftGiver
case 9030:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Welcome to Conquer Online, please take this gift."));
GC.AddSend(Packets.NPCLink("Thank you so much!", 1));
GC.AddSend(Packets.NPCLink("No, I don't need it.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
if (Control == 1)
{
GC.MyChar.CPs+ 1000;
}
break;
}
#endregion
04/12/2011 01:44 pro4never#2
Character variable saved/loaded controlling if it's been used already and then just check that variable inside your script.

There are tons of examples all over the forum if you'd search.

So a new variable say... ClaimedTimes = 0;. On load character read it from the character database. On change/logout save to character database.

Simple stuff.
04/12/2011 05:02 BlackCitadel#3
Just tell me how, I can't do it, here is the code:

#region QuestGiver
case 9040:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Hello, if you can give me a RedRose I will give you a nice reward, what reward it is you say? It's a surprise!"));
GC.AddSend(Packets.NPCLink("I collected them.", 1));
GC.AddSend(Packets.NPCLink("Ok I will go.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
else if (Control == 1)
{
if (GC.MyChar.InventoryContains(723454, 1))
{
GC.MyChar.RemoveItem(GC.MyChar.NextItem(723454));

GC.MyChar.CPs += 50000;
GC.MyChar.MyClient.LocalMessage(2000, "You have got 50k CPS For The Quest Please Say Thx For Xabi!");
}
}
break;
}
#endregion

I keep doing the quest many times, I want it only one time a day, or during the quest period.
04/12/2011 05:08 royboy01#4
Quote:
Originally Posted by BlackCitadel View Post
Just tell me how, I can't do it, here is the code:

#region QuestGiver
case 9040:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Hello, if you can give me a RedRose I will give you a nice reward, what reward it is you say? It's a surprise!"));
GC.AddSend(Packets.NPCLink("I collected them.", 1));
GC.AddSend(Packets.NPCLink("Ok I will go.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
else if (Control == 1)
{
if (GC.MyChar.InventoryContains(723454, 1))
{
GC.MyChar.RemoveItem(GC.MyChar.NextItem(723454));

GC.MyChar.CPs += 50000;
GC.MyChar.MyClient.LocalMessage(2000, "You have got 50k CPS For The Quest Please Say Thx For Xabi!");
}
}
break;
}
#endregion

I keep doing the quest many times, I want it only one time a day, or during the quest period.
not to be mean but people arent always going to do your stuff. So its best if you try it ^^
04/12/2011 13:46 BlackCitadel#5
This forums is useless as you are , I am out of this forum, Thanks for being soooooo helpful, seems you don't want to share your info to others, that's it!!! this is your life guys!!
You didn't even tell me HOW TO DO IT? Not a 1 2 3 4 5 (10 years old child) guide. Heh.
04/12/2011 16:21 pro4never#6
The reason we aren't just 'doing it for you' is because you should be learning this stuff. The answer has been posted in a number of guides across the forum. If you did some simple searching (say for 10 exp balls per day... lotto plays per day... etc) you'd find all sorts of answers.

Leading you to those (including how to find basic information yourself without being spoon fed) is the best thing we can do to help you LEARN.

Epvp is not (or at least should not) be about just getting other people to solve your problems for you. They should be pointing you in the right direction and when needed posting some of their knowledge to help you along the way.


Best of luck,
P4N
04/12/2011 16:46 BlackCitadel#7
You guys always have the same problem suffering from it, You always say this word (10 exp balls per day) you didn't even say, for example 10 exp balls the characyer use per day, or 10 exp balls getting it from doing a quest........
04/12/2011 17:03 pro4never#8
What you should be asking yourself when you face this sort of a problem is... "what common things need to be limited use per day"... well the obvious answer would be exp ball usage, lotto usage or gw rewards... those are some of the main ones.

You then try searching those sorts of things and dig through the results till you find an example, someone else asking the question or a release.

Again... these are basic skills you should be learning as you develop your coding skills.
04/12/2011 20:32 { Angelius }#9
@BlackCitadel

if (whatever)// = if !

so if you know at least the basics you'll figure whats wrong here is some info about it

so we know (if) is checking weather the answer is yes or no
so....
if (YourName == "BlackCitadel")
{
than the answer is YES and you are the thread creator Tadam!
}
else {}// what does it means !

else Means else !

however this way you are checking weather the answer was yes or no

so to check if the answer was YES you need something to check something to fill this if (EMPTY SPACE)

and that could be (bool, int , uint . etc )

in your case the closest answer wold be a bool !

public bool FreeToClaim = true;// gose to the Character.cs/Character Class

so now we should have something like

Quote:
if (GC.MyChar.FreeToClaim)
{
GC.MyChar.FreeToClaim = false;// changes the FreeToClaim that we added earlier to false ;
Give him the cps
}
else{Message("GO TO HELL you already claimed the free cps !");}
so far we did a check on that bullshit but dont you think that we need to save that FreeToClaim bool to make sure that the client want be able to claim the cps again on the next server restart !
yep we do but i think thats enough so far ,

and your code should look like

Quote:
if (Control == 1 && GC.MyChar.FreeToClaim)
{
GC.MyChar.FreeToClaim = false;
GC.MyChar.CPs+ 1000;
}
and so far you did make sure that the client well be able to claim it only 1 time each server restart

other ways you need to save it to the database where you are storing the characters info

and yep pro has already told you how to do it QE.(ladyLuck) take some time and try to figure how is it saving the lottouesd today and you'll find the answer .

Good Luck :)
04/12/2011 21:49 pro4never#10
Actually what you showed is part of the character class so it will reset every time they re-log... but yes, decent start.


I'd strongly recommend looking at some coding tutorials such as mine that I did for coemu/cofuture sources ages back. They are far from perfect but basically what I tried to do was take basic coding concepts (Such as... dictionaries...) and then apply them to conquer servers so like "when do I use these, what are they for, how do I use them" etc.

There's a link in my 5095 coemu linklist in my siggy.
04/12/2011 22:24 BlackCitadel#11
OK, Thanks pro4never, I checked your link now, I am going to learn them carefully!!
But is this tutorial only for CoEmu 5095??? Doesn't work for 5165??
04/13/2011 01:21 { Angelius }#12
Quote:
Originally Posted by pro4never View Post
Actually what you showed is part of the character class so it will reset every time they re-log... but yes, decent start.
How Did i miss that one :confused: