Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Mailing System (https://forums.graalonline.com/forums/showthread.php?t=73324)

Rapidwolve 04-06-2007 08:08 PM

Mailing System
 
NPC: Mail
PHP Code:

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 (
iallplayers){
    
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.mostsent2);
    for (
temp.0temp.temp.keys.size(); temp.++) {
      
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
PHP Code:

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
PHP Code:

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

function onCreated()
  
onTimeout();

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


Class: mailbox
PHP Code:


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

function 
onActionGrabbed(acc){
  if (
player.dir == 0){
    if (
clientr.sendmailto == nullsay2(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
PHP Code:

join("postoffice-getmail"); 

Add this code to show statistics.
PHP Code:

join("postoffice-stats"); 

Mailboxes:
Add this code into a level

PHP Code:

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


Chompy 04-06-2007 08: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 08:31 PM

Quote:

Originally Posted by Chompy (Post 1297469)
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 10: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-27-2007 11:02 PM

Quote:

Originally Posted by bscharff (Post 1312514)
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-27-2007 11:14 PM

Quote:

Originally Posted by bscharff (Post 1312514)
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?

Quote:

Originally Posted by Chompy (Post 1312516)
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.

PHP Code:

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

function 
Grab()
{
  
frontPosition = {player.1.5 vecx(player.dir) * 2player.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.accountplayer.guild);
  }


onActionGrabbed(account, guild);

bscharff 05-29-2007 12: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 12:59 AM

Change the line:

PHP Code:

if (clientr.sendmailto != null 

To:

PHP Code:

if (clientr.sendmailto != null) { 


Shame on you RW!

bscharff 05-29-2007 01: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 01:13 AM

Quote:

Originally Posted by bscharff (Post 1312780)
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 01:20 AM

1 Attachment(s)
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 01:21 AM

Oh Yeah, Thanks about the graal bible tip ;]

xXziroXx 05-29-2007 01:28 AM

Here's my serveroptions from Mythic:


PHP Code:

# 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 01:40 AM

Good thing this thread isn't about server options. :D

bscharff 05-29-2007 01:52 AM

Got My Server Fixed...

Here's What I Have For NPC: Mail
PHP Code:

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 (
iallplayers){
    
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.mostsent2);
    for (
temp.0temp.temp.keys.size(); temp.++) {
      
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 01:57 AM

Class: postoffice-getmail
PHP Code:

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 02:01 AM

change
player.chat = temp.msg
to
player.chat = temp.msg;
then.

xXziroXx 05-29-2007 02:02 AM

You got sloppy RW :x

Rapidwolve 05-29-2007 02:02 AM

In the first one you also forgot to add a comma after Tavern.

bscharff 05-29-2007 02:02 AM

Thanks
Also, Fixed the NPC: Mail Error. I Was retarded.

Rapidwolve 05-29-2007 02:03 AM

Quote:

Originally Posted by xXziroXx (Post 1312810)
You got sloppy RW :x

Bah

bscharff 05-29-2007 02: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 02: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 02: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 03: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 07:06 PM

OK, removed it from the class "mailbox" and it didn't affect anything.

xAndrewx 05-30-2007 07:12 PM

hmm, i'll re-write you a new one


All times are GMT +2. The time now is 01:31 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.