![]() |
LeaveMessage()
This is my first post in the Code Gallery, I am looking for good critique to improve my coding/styling etc.
If you like my code, feel free to use/edit it. Also I think this is quite a good example for using DataBase NPCs :o So I made this 4 functions: LeaveMessage(Account, MSG, DataBase) Will create/add a Message to a Database as an array (named as the Account of the Receiver.) CheckMessage(Account, DataBase) Will return how many Messages are saved for an Account in a DataBase. GetMessage(Account, Database, ID) Will return a Message. If ID is not provided, the first one. DeleteMessage(Account, Database, ID) Will delete a Message, if ID is not provided the first one. PHP Code:
|
could you give an example how to use it?
oh and doing "if (Account && MSG && DataBase) {" isn't very efficient IMO but i could be wrong. |
You've used "with()" to access DB NPC data where as in the rest of the script, you're not. Stick to one or the other. I prefer using this:
PHP Code:
Quote:
Quote:
|
I just skimmed over it, but if this is for a mail system or something similar, it'd be best to use textfiles. There was a mail system on Era not too long ago that used a DBNPC and it became so full that it caused extreme lag throughout the server everytime it was accessed. Nobody could figure out what was causing it until I think trying to open the DB manually crashed the server completely.
Not positivie, but I'm pretty sure that's what happened. |
Quote:
|
Quote:
And yes, it can be used for a Mail-System, I didn't know that it's better to save it into text files :o, well now I do, =P. Example: PHP Code:
|
You should generally try a cache- you don't want to be modifying a text document every five seconds.
|
All times are GMT +2. The time now is 10:26 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.