My own npc

05/20/2010 15:29 2010mrsurfer#1
Okay when i finaly finish my server its not going to be up 24/7 since ive left college and ive got no money and theres no jobs around atm, i decided to make a npc where players can get 50k cps ( i may up it) each day (yeh i know my server may be a hit and miss cause it wont be up 24/7 but oh well xD) but ive got it so the npc gives you the cps but how do i make so you can only get it once a day? Here is my code:
#region Free CPs
case 987787:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Hello, you can get 50k cps free each day!"));
GC.AddSend(Packets.NPCLink("Yes please", 2));
GC.AddSend(Packets.NPCLink("No Thanks.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
if (Control == 2)
{
GC.AddSend(Packets.NPCSay("Here you go, remember to say thank you to Jon"));
GC.MyChar.CPs += 50000;
GC.AddSend(Packets.NPCLink("Thank You Jon", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
break;
}
#endregion
05/20/2010 18:41 Arcо#2
in character.cs define this:
public bool CPDay;

Then make your npc like this.
case 987787:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Hello, you can get 50k cps free each day!"));
GC.AddSend(Packets.NPCLink("Yes please", 2));
GC.AddSend(Packets.NPCLink("No Thanks.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
if (Control == 2)
{
if (!GC.MyChar.CPDay)
{
GC.AddSend(Packets.NPCSay("Here you go, remember to say thank you to Jon"));
GC.MyChar.CPs += 50000;
GC.MyChar.CPDay = true;
GC.AddSend(Packets.NPCLink("Thank You Jon", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
else
{
GC.AddSend(Packets.NPCSay("You have already claimed your cps for the day."));
GC.AddSend(Packets.NPCLink("Oh sorry.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
}
break;
}
#endregion
05/20/2010 18:50 2010mrsurfer#3
Quote:
Originally Posted by .Arco View Post
in character.cs define this:
public bool CPDay;

Then make your npc like this.
case 987787:
{
if (Control == 0)
{
GC.AddSend(Packets.NPCSay("Hello, you can get 50k cps free each day!"));
GC.AddSend(Packets.NPCLink("Yes please", 2));
GC.AddSend(Packets.NPCLink("No Thanks.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
if (Control == 2)
{
if (!GC.MyChar.CPDay)
{
GC.AddSend(Packets.NPCSay("Here you go, remember to say thank you to Jon"));
GC.MyChar.CPs += 50000;
GC.MyChar.CPDay = true;
GC.AddSend(Packets.NPCLink("Thank You Jon", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
else
{
GC.AddSend(Packets.NPCSay("You have already claimed your cps for the day."));
GC.AddSend(Packets.NPCLink("Oh sorry.", 255));
GC.AddSend(Packets.NPCSetFace(N.Avatar));
GC.AddSend(Packets.NPCFinish());
}
}
break;
}
#endregion
Thank you :) what do you mean by define: public bool CPDay;
and do you know the number thing for the market? I only know TC is 1002
05/20/2010 19:14 Arcо#4
Go to characater.cs and search for public bool alive and put it under that.
And the ID for market is 1036.
05/20/2010 19:38 .Kob#5
Then, just relog and you can obtain the CPs again >.<. You need save the variable.

It's not recommended to follow the .Arco's recommendations.
05/20/2010 19:48 2010mrsurfer#6
Quote:
Originally Posted by .Arco View Post
Go to characater.cs and search for public bool alive and put it under that.
And the ID for market is 1036.
Thank you shall do it now :)

Quote:
Originally Posted by cakobu View Post
Then, just relog and you can obtain the CPs again >.<. You need save the variable.

It's not recommended to follow the .Arco's recommendations.
xD But Arco recommendations taught me how to program :)
Oh arco i get this problem with this line:
Loc.X = ushort.Parse(Info[5]); <<<< Index was outside the bounds of the array.
Any ideas?