Jump to content

Key Control


Recommended Posts

  • Root Admin

Copied From Murs initial Post (no code changed)

[b]Key Control[/b]
Keys are what decide what users can access in game. They are like flags to indicate all sorts of things and to track what player did and achieved. A special category of keys are the ones that you can set from the MDScript. They are just like the keys used to setup the entire realm, just that they have a prefix "rpcq-". You might notice that the same prefix is set on the Clickable items, well its no coincidence. Clickable items run as clickables if you don't have the key to access them and run as something else if you do have the key. Currently there are no clickables that have something behind them to run, but some important clickables that had are the Loreroot back entrance and the Drachorn Cave, meaning that if you got the key from a mdscript you could have entered the cave and get plenty of drachorns or have permanent access to LR back entrance. So pay attention to MDScript, it might be more interesting than you think.

Enabling more clickable items to do something behind their keys will be done if i see people realy understand how to use and not ab(use) them. Combining strict rules with total freedom might not be possible afterall, anyway the system allows it right now so who knows what will be in the future of MD.

For now, scripted keys are excelent way to track quest progress, and make scripts "know" what the player evolution with that script is.

There is a new feature for data storage, that could be used just the same way, but i strongly think that keys have a major use along with that. Data storage and keys will have different evolution path because they are tehnicaly different things. Keys are saved with the user, data is separated.

Differences between data storage and keys
Data storage, unlike keys, can store lots of data of all sorts, but they also get deleted once they get empty. Its no way to track what data a user has outside the clickable objects or MDScript. Keys can be tracked in game interface and used under many circumstances. Keys are very bad for holding actual data, they are just flags that are on or off. Only info keys hold is the time and place they were received and thats for logging reasons mostly. Both keys and data storage have their advantages and disadvantages and their different uses. They are not one and the same thing, even if under current situation they have similar use.

Function to manage keys:


Gives the keys to the player.


Removes/takes the keys from the player


Checks if the player has specific keys, returns true if all keys are in the players possession , false otherwise

keys = a string with all the keys you want to give , take, or check. It doesnt support arrays, the parameter should be a string with comma separated values


echo "Congrats you have all the keys";
echo "You do not have all needed keys";

[php]if(..some rule here...){
@vk[] = 'key1';

if(..some other rule...){
@vk[] = 'key2';

@vs = implode(",",@vk);

[php]//replace keys
//for example player just delivered a package and rceived next task

//takes initial key away, so it wont be used again
//gives other keys in replace to continue

//final key could trigger a reward [/php]

[b]Sharing keys[/b]
Keys are global. A key named "greenbox" will be the same for that player if checked by any item or script in the realm. TO avoid key collisions you should name your keys in original way or even better , you should add a prefix to them.

Example of good key names: playername-greenbox , or zzg3-greenbox, greenbox-tree-quest23
Example of bad key names: box, package, key1, somekey, general, ..

Sharing keys is very interesting when multiple editors want to syncronize their quests. For example an item scripted by an editor could check for a key given by an other editor/quest to see if that user finished that quest first.

[b]Key secrecy[/b]
Because keys can be set by any editor, keeping your keys named complicated and secret is most important to avoid cheating. If you trust all the other editors, you can ignore that advice. Other editors can not see your code, except if you script on public items (there is a special category of items that share content and script across any editor).

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Forum Statistics

    Total Topics
    Total Posts
  • Recently Browsing

    • No registered users viewing this page.
  • Upcoming Events

    No upcoming events found
  • Recent Event Reviews

  • Create New...