Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-03-2011, 09:01 AM
mrnothersan mrnothersan is offline
Owner of MrNothersan
Join Date: Mar 2011
Location: On the Computer
Posts: 97
mrnothersan is an unknown quantity at this point
Send a message via AIM to mrnothersan Send a message via MSN to mrnothersan
In-Game Email System

Hi

Are there any tutorials which tell you how to make an in game email system so that people can email all the admins (like a ticket system)?

Regards
__________________

Regards
MrNothersan - Playerworld owner


Staff Hirings Thread for MrNothersan: http://forums.graalonline.com/forums....php?p=1639180

Reply With Quote
  #2  
Old 04-03-2011, 09:10 AM
oo_jazz_oo oo_jazz_oo is offline
Jazz teh Awesome
oo_jazz_oo's Avatar
Join Date: Jul 2006
Location: California
Posts: 596
oo_jazz_oo is a jewel in the roughoo_jazz_oo is a jewel in the rough
Send a message via MSN to oo_jazz_oo
This should get you started.

http://forums.graalonline.com/forums...ad.php?t=74011

Also, search code gallery for examples of SQLite usage in Graal.
__________________

Reply With Quote
  #3  
Old 04-03-2011, 06:26 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
You will want to choose a way to store the data. The four main ones are:
  • Database NPC flags
  • Files
  • SQLite
  • Player flags

The first one should be thrown out in this case as all information you store will be kept in memory. When Era used flags like this, we were using almost 250 MB of memory just for the database, which caused a lot of problems for the rest of the server.

I would also throw out the last one since the data would still be kept in memory as long as the player was online, and RC will truncate any player flags to ~255 characters in length. In addition, if the player were to be reset, they would lose all of their mail.

Both files and SQLite are acceptable in this case. I would recommend SQLite for this instance, but it has a far larger learning curve, and if you use it without understanding it you can cause major problems. If you're interested in taking the SQL route, there are some tutorials available on the internet. I started on a guide here—it's lacking a lot of stuff right now, though.

Graal data files are very simple. They are simply a set of variables and values, one per line, that looks like this:
PHP Code:
foo=bar
baz
="a","b"
test=92 
If we pretend that this file is located at data/test.txt, then we can use the following code to access it:

PHP Code:
temp.vars.loadVars("data/test.txt");

echo(
temp.vars.foo); // echoes "bar"
echo(temp.vars.baz[0]); // echoes "a"
echo(temp.vars.test 9); // echoes "101" 
Saving variables is equally simple:

PHP Code:
// defining the variable like this may or may not be necessary;
// I do it to clarify my purpose
temp.vars null;

temp.vars.stringExample "one";
temp.vars.arrayExample = {"a""b"76};
temp.vars.numberExample 47;

// first parameter is location to save to
// second parameter is whether or not to append
//    false = erase the existing file, replace it with this
//    true  = add these values to the existing file
temp.vars.saveVars("data/test.txt"false); 
Note that in order to allow scripts to access files, you need to give the NPC-server rights to those files, just like if it were a staff member. Open the rights of (npcserver) and add to their folder rights:
Quote:
rw data/*
rw data/*/*
rw data/*/*/*
rw data/*/*/*/*
(I like to keep all the script data inside a data directory and organized into subdirectories—you can choose your own structure, though)

Be careful not to give the NPC-server rights to scripts or levels unless you trust everyone on RC. Anyone with script or level rights could then download them.

Either way you choose for storing data, be sure to think about how you plan to structure it first. If you use files, my recommendation would be to use a file for each player rather than one file for every player. Otherwise, it will still be loading all of that data into memory every time you check the player's mail.

If you have any questions I'm happy to answer them.
__________________

Last edited by cbk1994; 04-03-2011 at 08:50 PM.. Reason: typo
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 05:35 PM.


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