PDA

View Full Version : Mailing System


Rapidwolve
04-06-2007, 09:08 PM
NPC: Mail

function onCreated()
createVariables();

function createVariables(){
setVars();
calcMostSent();
this.mailIDs = {"Example Box", "Mailbox 1", "the Bank",
"etc"}; // Add as many as you wish
}


function setVars(){
for (i: allplayers){
temp.player = findPlayer(i);
if (temp.player != null){
this.sentmail.(@temp.player) = temp.player.clientr.sentmailamt;
}
}
}

public function calcMostSent(){
setVars();
temp.keys = getstringkeys("this.sentmail.");
setarray(temp.mostsent, 2);
for (temp.i = 0; temp.i < temp.keys.size(); temp.i ++) {
temp.current = makevar("this.sentmail." @ temp.keys[temp.i]);
if (temp.current > temp.mostsent[1]) {
temp.mostsent[1] = temp.current;
temp.mostsent[0] = temp.keys[temp.i];
}
}
serverr.mail.mostsent = {temp.mostsent[0],temp.mostsent[1]};
return temp.mostsent[0];
}

Class: postoffice-getmail

function onCreated(){
setshape(1,32,32);
}

function onActionGrabbed(){
if (clientr.sentmail == false)
{
if (clientr.sendmailto == null)
{
findNPC("Mail").calcMostSent();
temp.num = findNPC("Mail").mailIDs.size();
temp.mailID = findNPC("Mail").mailIDs[random(0,temp.num)];
clientr.sendmailto = temp.mailID;
temp.msg = "Hmm... this letter is for someone at " @ clientr.sendmailto;
player.chat = temp.msg;
return;
}
else
{
temp.msg = clientr.sendmailto @ " is expecting a letter from you!";
player.chat = temp.msg
return;
}
}

if (clientr.sentmail == true)
{
findNPC("Mail").calcMostSent();
temp.paydol = int(random(4,6));
player.rupees += temp.paydol;
clientr.sendmailto = null;
clientr.sentmail = false;
player.chat = format("Recieved %i rupees", temp.paydol);
return;
}
}

//#CLIENTSIDE
function onCreated() {
setshape(1,32,32);
}


Class: postoffice-stats

/*
Post Office System
by RW*
*/
//#CLIENTSIDE

function onCreated()
onTimeout();

function onTimeout(){
showText(2, x, y, "Tahoma", "b", format("%s has the most sent letters with %s", serverr.mail.mostsent[0],serverr.mail.mostsent[1]));
changeimgzoom(2, .60);
showText(3, x, y+1, "Tahome", "b", format("You have sent %s letter(s)", clientr.sentmailamt));
changeimgzoom(3, .60);
setTimer(.1);
}


Class: mailbox


function onCreated(){
setimg("oakdale_mailbox-1.gif"); // replace with your mailbox image
}

function onActionGrabbed(acc){
if (player.dir == 0){
if (clientr.sendmailto == null) say2(this.mailboxID);
if (clientr.sendmailto != null {
if (clientr.sendmailto == this.mailboxID){
findNPC("Mail").calcMostSent();
clientr.sentmailamt++;
clientr.sentmail = true;
clientr.sendmailto = null;
player.chat = "Sent The Letter!";
}
else
{
player.chat = "Wrong Mailbox!";
}
}
}
}


Post Office:
Create a level for the post office.

Add this code, put it againts a wall or something because it is invisible. You must grab it to get a new letter

join("postoffice-getmail");


Add this code to show statistics.

join("postoffice-stats");


Mailboxes:
Add this code into a level


join("mailbox");
this.mailboxID = "Example Box"; // The mailbox ID must exist in the Mail NPC 'this.mailIDs' array

Chompy
04-06-2007, 09:26 PM
Style postoffice-stats, and maybe turn the timeout down, to like 0.5 or even 1 sec ;)

Looks really nice RW!

Rapidwolve
04-06-2007, 09:31 PM
Style postoffice-stats, and maybe turn the timeout down, to like 0.5 or even 1 sec ;)

Looks really nice RW!

Done and thanks.

bscharff
05-27-2007, 11:12 PM
My Server (playerworld141) Won't Let Me Get A Letter.
(I can grab the "join postoffice-getmail" thing all I want but I don't get any message or script flag on my attributes)
Also, the Script Compiler Gives Me Numerous Errors So It Won't Even Let Me Save class: mailbox

Chompy
05-28-2007, 12:02 AM
My Server (playerworld141) Won't Let Me Get A Letter.
(I can grab the "join postoffice-getmail" thing all I want but I don't get any message or script flag on my attributes)
Also, the Script Compiler Gives Me Numerous Errors So It Won't Even Let Me Save class: mailbox

Post the errors?

Oh, and I think RW forgot the code for onActionGrabbed()

Rapidwolve
05-28-2007, 12:14 AM
My Server (playerworld141) Won't Let Me Get A Letter.
(I can grab the "join postoffice-getmail" thing all I want but I don't get any message or script flag on my attributes)
Also, the Script Compiler Gives Me Numerous Errors So It Won't Even Let Me Save class: mailbox

I tested it and it worked fine for me before I released it, can you tell us what the errors were?

Post the errors?

Oh, and I think RW forgot the code for onActionGrabbed()

Yes if you dont have a triggerAction for when a player grabs something then add it somewhere.


function onKeyPressed(code, key)
{
switch (temp.key)
{
case "a":
Grab();
break;
}
}

function Grab()
{
frontPosition = {player.x + 1.5 + vecx(player.dir) * 2, player.y + 1.5 + vecy(player.dir) * 2};
canGrab = (testplayer(frontPosition[0], frontPosition[1]) || testnpc(frontPosition[0], frontPosition[1]));
if (canGrab)
{
triggerAction(frontPosition[0], frontPosition[1], "Grabbed", player.account, player.guild);
}
}


onActionGrabbed(account, guild);

bscharff
05-29-2007, 01:53 AM
Script compiler output for Class mailbox:
error: unexpected symbol { at line 8: if (clientr.sendmailto != null {


I'm Using the Exact Class: mailbox code listed above except using mailbox.gif instead of oakdale_mailbox-1.gif


But the Real Problem Is that It Dosen't Assign A Letter. I'm using the EXACT script mentioned above except more mailboxes.

xXziroXx
05-29-2007, 01:59 AM
Change the line:

if (clientr.sendmailto != null {

To:

if (clientr.sendmailto != null) {


Shame on you RW!

bscharff
05-29-2007, 02:10 AM
Thanks ziro!

Since Some Dumbo Decided To Abuse His Staff Powers (*cough* Account: dude2020 *cough* Never Hire Him) To Delete All Vital Server Information (ServerOptions, ServerFlags)
I Can't Even Log In To The Game. I Can Login To RC, But that's It.

Would Someone please Post Their ServerOptions So I Don't Have To Contact Support & Wait A Week For A Response?
Thanks!

Anyways, For Now Just Assume I'm Copy & Pasting EXACTLY What You Posted As The Script (Exception: ziro's Fix to the mailbox class)

cbk1994
05-29-2007, 02:13 AM
Thanks ziro!

Since Some Dumbo Decided To Abuse His Staff Powers (*cough* Account: ----- *cough* Never Hire Him) To Delete All Vital Server Information (ServerOptions, ServerFlags)
I Can't Even Log In To The Game. I Can Login To RC, But that's It.

Would Someone please Post Their ServerOptions So I Don't Have To Contact Support & Wait A Week For A Response?
Thanks!

Anyways, For Now Just Assume I'm Copy & Pasting EXACTLY What You Posted As The Script (Exception: ziro's Fix to the mailbox class)

On the Graal Bible, it has all of the options for server ops.

Don't go around spreading accounts, please edit that out! That is extremly rude, how would you like it if someone accused you of doing something without proving you did it?!

You're being rude, I bet you don't even have proof he did it!

bscharff
05-29-2007, 02:20 AM
Proof (See Attached)

Highlight In A Glimpse:

Time: Mon May 28 05:20:31 2007
dude2020 deleted file levels/auction.nw
Time: Mon May 28 05:20:32 2007
dude2020 deleted file levels/back_room.nw
Time: Mon May 28 05:20:33 2007
dude2020 deleted file levels/cafe.nw
Time: Mon May 28 05:20:34 2007
dude2020 deleted file levels/event_briefing.nw
Time: Mon May 28 05:20:36 2007
dude2020 deleted file levels/event_house.nw
Time: Mon May 28 05:20:37 2007
dude2020 deleted file levels/house_01.nw
Time: Mon May 28 05:20:38 2007
dude2020 deleted file levels/houses01.nw
Time: Mon May 28 05:20:40 2007
dude2020 deleted file levels/island_01.nw
Time: Mon May 28 05:20:41 2007
dude2020 deleted file levels/jail.nw
Time: Mon May 28 05:20:42 2007
dude2020 deleted file levels/jail_office.nw
Time: Mon May 28 05:20:44 2007
dude2020 deleted file levels/lounge.nw
Time: Mon May 28 05:20:45 2007
dude2020 deleted file levels/main_level.nw
Time: Mon May 28 05:20:47 2007
dude2020 deleted file levels/onlinestartlocal.graal
Time: Mon May 28 05:20:49 2007
dude2020 deleted file levels/park.graal
Time: Mon May 28 05:20:50 2007
dude2020 deleted file levels/postoffice.nw
Time: Mon May 28 05:20:52 2007
dude2020 deleted file levels/staffhangout.nw
Time: Mon May 28 05:20:53 2007
dude2020 deleted file levels/staffshangout.nw
Time: Mon May 28 05:20:55 2007
dude2020 deleted file levels/staffstatueroom.nw
Time: Mon May 28 05:20:56 2007
dude2020 deleted file levels/tavern.nw
Time: Mon May 28 05:20:57 2007
dude2020 deleted file levels/zoraafields.nw
Time: Mon May 28 05:21:04 2007
dude2020 deleted file scripts/gambet_movablefurniture.txt
Time: Mon May 28 05:21:06 2007
dude2020 deleted file scripts/gralats.txt
Time: Mon May 28 05:21:07 2007
dude2020 deleted file scripts/mailbox.txt
Time: Mon May 28 05:21:08 2007
dude2020 deleted file scripts/postoffice-getmail.txt
Time: Mon May 28 05:21:10 2007
dude2020 deleted file scripts/postoffice-stats.txt
Time: Mon May 28 05:21:11 2007
dude2020 deleted file scripts/staffsign.txt
Time: Mon May 28 05:22:08 2007
dude2020 has updated the server options
Time: Mon May 28 05:22:15 2007
dude2020 has updated the folder configuration
Time: Mon May 28 05:22:18 2007
dude2020 has updated the server flags
Time: Mon May 28 05:25:09 2007
dude2020 changed the rights of bscharff
removed rights: warptoxy,warptoplayer,warpplayers,updatelevel,disc onnectplayers,viewattributes,setattributes,setowna ttributes,resetattributes,adminmessage,changeright s,banplayers,changecomments,changestaffaccounts,se tserverflags,changeoptions,changefolderconfig,chan gefolderrights,NPC-Control
new ip range(s):
Time: Mon May 28 05:26:12 2007
dude2020 changed the rights of Admin-Playerworld141
removed rights: warptoxy,warptoplayer,warpplayers,updatelevel,disc onnectplayers,viewattributes,setattributes,setowna ttributes,resetattributes,adminmessage,changeright s,banplayers,changecomments,changestaffaccounts,se tserverflags,changeoptions,changefolderconfig,chan gefolderrights,NPC-Control
new ip range(s):
Time: Mon May 28 05:26:29 2007
RC dude2020 disconnected.

bscharff
05-29-2007, 02:21 AM
Oh Yeah, Thanks about the graal bible tip ;]

xXziroXx
05-29-2007, 02:28 AM
Here's my serveroptions from Mythic:



# Start location
startlevel=ml_island.gmap
startx=62.5
starty=52.5

# Unstick me location
unstickmelevel=ml_island.gmap
unstickmex=62.5
unstickmey=52.5

# Protected weapons
protectedweapons=weapon1,weapon2

# Jail levels
#jaillevels=

# Explosion restriction
noexplosions=true

# Static restriction
setbodyallowed=true
setheadallowed=true
setbomyallowed=false
setswordallowed=true
setshieldallowed=true

# Gralat loss options
mindeathgralats=0
maxdeathgralats=0

# Staff gralat restriction
normaladminscanchangegralats=true

# Local 'staff guilds'
staffguilds=Server,Owner

# 'Bush' items
bu****ems=false

# 'Baddy' items
baddyitems=false

# 'Healing' swords
healswords=false

# Non-script timeouts
respawntime=10
horselifetime=0
baddyrespawntime=60

# Server scripting flags
dontaddserverflags=false

# Server maps
#bigmap=maptext,mapimage,defaultx,defaulty
#minimap=maptext,mapimage,defaultx,defaulty

# Warping (all players)
warptoforall=true
warptoforlowadmins=true

# Warping activation
warpto=true
ignorewarpto=false

# Ghost mode
ghostmodeenabled=false
ghostmodefornotstaff=false

# Playerlist icons
#playerlisticons=

# Profile variables
profilevars=Server Relation:=clientr.staffrank

# Trial account limits
limitfreeplayers2=false

# AP system activation
apsystem=true

# Starting AP
startap=100

# Global guilds activation
globalguilds=true
#allowedglobalguilds=Mythic Legend

# AP timeouts
aptime0=30
aptime1=90
aptime2=300
aptime3=600
aptime4=1200

# Hearts/Sword limits
heartlimit=3
swordlimit=1

# 'putnpc' scripting command
putnpcenabled=false

# Translation
enabletranslations=false

# Language selection
#translatedlanguages=

# Server language
serverlanguage=English

# NPC-Server 'sleep'
sleepwhennoplayers=false

# Tilesets
newtilesets=true
newtilesetlevels=ml_,

# Staff
staff=ZOMG,SECRET,OK?

# GMAP list
gmap=ml_island

# Weapon order
weaponorder=weapon1,weapon2

# NPC-Control rights
npcrights=true

# Kill count
dontchangekills=true

# NPC-Server nickname
nickname=Mythic Legends NPC

# Speedhack tolerance
speedhacktolerance=90

# Idle disconnect
disconnectifnotmoved=false

# Save levels
savelevels=true
savelevelsmessage=true

# Staff only
onlystaff=false

# Log script function calls
scriptlogfunctions=write player.nick,write player.guild,call sendtonc,call sendtorc

# Levels auto-save
levelsaveauto=true


Edit: "bu****ems" is censored, should be "bush items" (remove the space).

Rapidwolve
05-29-2007, 02:40 AM
Good thing this thread isn't about server options. :D

bscharff
05-29-2007, 02:52 AM
Got My Server Fixed...

Here's What I Have For NPC: Mail
function onCreated()
createVariables();

function createVariables(){
setVars();
calcMostSent();
this.mailIDs = {"Main House", "Bloos House", "Events House", "Cafe", "Tavern" "Lounge"}; // Add as many as you wish
}


function setVars(){
for (i: allplayers){
temp.player = findPlayer(i);
if (temp.player != null){
this.sentmail.(@temp.player) = temp.player.clientr.sentmailamt;
}
}
}

public function calcMostSent(){
setVars();
temp.keys = getstringkeys("this.sentmail.");
setarray(temp.mostsent, 2);
for (temp.i = 0; temp.i < temp.keys.size(); temp.i ++) {
temp.current = makevar("this.sentmail." @ temp.keys[temp.i]);
if (temp.current > temp.mostsent[1]) {
temp.mostsent[1] = temp.current;
temp.mostsent[0] = temp.keys[temp.i];
}
}
serverr.mail.mostsent = {temp.mostsent[0],temp.mostsent[1]};
return temp.mostsent[0];
}


Error Received:
Script compiler output for Mail (in level main_level.nw at pos (30.5, 30)):
error: unexpected token: "Lounge" at line 7: this.mailIDs = {"Main House", "Bloos House", "Events House", "Cafe", "Tavern" "Lounge"}; // Add as many as you wish
error: missing semicolon at line 7: this.mailIDs = {"Main House", "Bloos House", "Events House", "Cafe", "Tavern" "Lounge"}; // Add as many as you wish
error: unexpected token: } at line 8: }

SEE NEXT PAGE.

bscharff
05-29-2007, 02:57 AM
Class: postoffice-getmail
function onCreated(){
setshape(1,32,32);
}

function onActionGrabbed(){
if (clientr.sentmail == false)
{
if (clientr.sendmailto == null)
{
findNPC("Mail").calcMostSent();
temp.num = findNPC("Mail").mailIDs.size();
temp.mailID = findNPC("Mail").mailIDs[random(0,temp.num)];
clientr.sendmailto = temp.mailID;
temp.msg = "Hmm... this letter is for someone at " @ clientr.sendmailto;
player.chat = temp.msg;
return;
}
else
{
temp.msg = clientr.sendmailto @ " is expecting a letter from you!";
player.chat = temp.msg
return;
}
}

if (clientr.sentmail == true)
{
findNPC("Mail").calcMostSent();
temp.paydol = int(random(4,6));
player.rupees += temp.paydol;
clientr.sendmailto = null;
clientr.sentmail = false;
player.chat = format("Recieved %i rupees", temp.paydol);
return;
}
}

//#CLIENTSIDE
function onCreated() {
setshape(1,32,32);
}

Error Received:
Script compiler output for Class postoffice-getmail:
error: missing semicolon at line 22: return;

DustyPorViva
05-29-2007, 03:01 AM
change
player.chat = temp.msg
to
player.chat = temp.msg;
then.

xXziroXx
05-29-2007, 03:02 AM
You got sloppy RW :x

Rapidwolve
05-29-2007, 03:02 AM
In the first one you also forgot to add a comma after Tavern.

bscharff
05-29-2007, 03:02 AM
Thanks
Also, Fixed the NPC: Mail Error. I Was retarded.

Rapidwolve
05-29-2007, 03:03 AM
You got sloppy RW :x

Bah

bscharff
05-29-2007, 03:19 AM
OK, Now There's No Script Errors.
But I Still Can't Grab A Letter. (It Doesn't Say "Hmm... This Letter Is For Someone At _____")

Also, It Doesn't Write Any Strings (clientr.sentmail) or whatever it is.

bscharff
05-29-2007, 03:20 AM
If You Need To See or Fix It I'll Give You RC Temporarily or somthing as a reward.

Server: Playerworld141
I'm on Now ;]

bscharff
05-29-2007, 03:44 AM
OK, It Assigns Where To Deliver It and All, but It doesn't let me deliver it. As In, No Message like posted the letter is showed.

PS: I added that script that did something about grabbing, It was the thing that let me get a letter. I also added it to the mailbox Class but it didn't fix the cannot deliver thing.

Rapidwolve
05-29-2007, 04:02 AM
Your only supposed to add it to one weapon, and it should work fine unless i forgot another character. x.x

bscharff
05-30-2007, 08:06 PM
OK, removed it from the class "mailbox" and it didn't affect anything.

xAndrewx
05-30-2007, 08:12 PM
hmm, i'll re-write you a new one