Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-11-2010, 05:54 PM
cyan3 cyan3 is offline
Registered User
cyan3's Avatar
Join Date: Nov 2005
Location: England
Posts: 2,919
cyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant futurecyan3 has a brilliant future
Level Restriction Script

Here is a slightly modified version of a script that I'm using for a restricted store house for the Crescent Pirates on Kingdoms Debug. It probably isn't perfect so I'd be grateful for any comments that could help me improve it.

Installation
To get the script working correctly a few things will have to be edited with the script.
  1. Change "server.access = {{"cyan3",true}};" on line 8 to another relevant account name. This will automatically add the account as an admin on creation of the script.
  2. Change "server.access = {{"cyan3",true}};" on line 33 to a relevant account name. This account will stay as an admin when the :resetaccess command is called.
  3. Change "player.setlevel2("mylevel.nw", 30, 30);" to the levelname and x/y of the level you want to restrict access to.

Script Commands
Commands for admins:
  • :addadmin <accountname> - Adds the account as an admin.
  • :addaccess <accountname> - Gives account access to the level.
  • :removeaccess <accountname> - Removes account from accessing the level.
  • :resetaccess - Resets the list of all accounts expect the one specified in the script.
  • :viewaccess - Outputs a list admins and accounts with access.

PHP Code:
//Made by Felix Lionheart (*cyan3)

function onCreated() {
  
this.setShape(1,6*16,2*16);
  
  if (
server.access.size() <= 0) {
  
    
server.access = {{"cyan3",true}};
 }
}

function 
onPlayerChats() {
// only admins can use these commands
  
for (temp.access server.access) {
   if (
temp.access[0] == player.account) {
   if (
temp.access[1] == true) {

    if (
player.chat.starts(":addadmin")) { // add account to admin
    
server.access.add({player.chat.substring(10),true});
    
player.say2(player.chat.substring(10) @ " has been added as an" NL "Admin.");
  } else if (
player.chat.starts(":addaccess")) { // add account to access
    
server.access.add({player.chat.substring(11),false});
    
player.say2(player.chat.substring(11) @ " has been added.");
  } else if (
player.chat.starts(":removeaccess")) { //remove account as access
    
for (i=0i<server.access.size(); i++) {
     if (
server.access[i][0] == player.chat.substring(14)) { temp.index i;
     
server.access.delete(i);
     
player.say2(player.chat.substring(14) @ " has been removed.");
    }
   }

  } else if (
player.chat.starts(":resetaccess")) { // resets the access list
    
server.access = {{"cyan3",true}};
    
player.say2("Access list has been reset.");

  } else if (
player.chat.starts(":viewaccess")) { // output list of access
    
sendrpgmessage("<b>List of accounts with access:<b>");
    for (
temp.accesslist server.access) {
      
sendrpgmessage(accesslist);
      
player.say2("Text arrived in the RPG console." NL "Press F2 to view it!");
     }
    }
   }
  }
 }
}

function 
onPlayerTouchsMe() {
  for (
temp.access server.access) {
    if (
temp.access[0] == player.account) {
    
player.setlevel2("mylevel.nw"3030);
  } else {
    
player.say2("You are not allowed to enter!");
   }
  }
 } 
Attached Files
File Type: txt levelrestrictionscript.txt (1.7 KB, 264 views)
Reply With Quote
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 06:06 PM.


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