Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Custom/Default Toggle (https://forums.graalonline.com/forums/showthread.php?t=87692)

fowlplay4 08-30-2009 11:48 PM

Custom/Default Toggle
 
Well this is basically a weapon script for switching your server from a default to a custom mode. Which essentially is the first step in developing custom systems for your server.

I generally give this it's own weapon script and list it first in weaponorder= in the serveroptions, because having the enables and disables all over the place is messy and you can end up with unneeded bugs. I.e: Zodiac's old map opening on crossing level link bug.

It's very basic so feel free to expand upon it in your own implementations, which may include special conditions for the different modes and so on.

PHP Code:

/*
   Allows easy-toggling between Default and Custom systems.
*/
//#CLIENTSIDE

function onPlayerEnters() {
  if (
this.defaultmode) {
    
onDefaultMode();
  } else {
    
onCustomMode();
  }
}

function 
onCustomMode() {
  
showstats(1024);
  
enablefeatures(allfeatures-2-4-8-0x100-0x200-0x400-0x800-0x2000-0x40-0x10-0x20);
  
disablemap();
  
disablepause();
  
disableweapons();
  
disableselectweapons();  
}

function 
onDefaultMode() {
  
enablemap();
  
enablepause();
  
enableweapons();
  
enableselectweapons();
  
enablefeatures(allfeatures);
  
showstats(allstats);  


If you have no need to switch between the two, feel free to use the onCustomMode function for your own use, of course you'll have to alter the enablefeatures flag portion to meet your custom needs :)

On the Zodiac Dev server I use the following script to toggle between the modes.

PHP Code:

function ChatBar.onAction() {
  if (
ChatBar.text == "/classicmode") {
    
ChatBar.text "";
    
this.defaultmode = !this.defaultmode;
    for (
temp.wepplayer.weapons) {
      
wep.trigger("PlayerEnters""");
    }
  }



Gambet 09-02-2009 06:32 AM

I can see where others would find this useful, nice release. :)


All times are GMT +2. The time now is 09:53 AM.

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