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 08-03-2008, 01:45 AM
TheStan TheStan is offline
Stan?
Join Date: May 2008
Location: U.S.
Posts: 100
TheStan is on a distinguished road
Send a message via AIM to TheStan Send a message via MSN to TheStan
Custom Keys

PHP Code:
//#CLIENTSIDE
function onCreated() {
  if (!
client.keyupdate) {
    
setkeys();
  }
}
function 
onPlayerChats() {
  
temp.toks null;
  
  
toks player.chat.tokenize();
  if (
toks[0].starts("/")) {
    if (
toks[0].substring(1).length() == 1) {
      if (
toks[1].length() == 1) {
        
setNewKey(toks[0].substring(1), toks[1]);
      }
    }
    else {
      if (
toks[0].substring(1) == "fixkeys") {
        
fixKeys();
      }
    }
  }
}
public function 
setkeys() {
  
temp.key null;
  
temp.out null;
  
  
temp.keys = {
    {
"a""a"},
    {
"b""b"},
    {
"c""c"},
    {
"d""d"},
    {
"e""e"},
    {
"f""f"},
    {
"g""g"},
    {
"h""h"},
    {
"i""i"},
    {
"j""j"},
    {
"k""k"},
    {
"l""l"},
    {
"m""m"},
    {
"n""n"},
    {
"o""o"},
    {
"p""p"},
    {
"q""q"},
    {
"r""r"},
    {
"s""s"},
    {
"t""t"},
    {
"u""u"},
    {
"v""v"},
    {
"w""w"},
    {
"x""x"},
    {
"y""y"},
    {
"z""z"}
  };
  for (
keykeys) {
    
out @= (key[0] @ key[1]);
  }
  
client.keys out;
  
client.keyupdate true;
}
public function 
getSetKey(skey) {
  
temp.key null;
  
  for (
keyclient.keys) {
    if (
key[0] == skey) {
      return 
key[1];
    }
  }
}
public function 
setNewKey(oldkeynewkey) {
  
temp.key null;

  for (
keyclient.keys) {
    if (
key[0] == oldkey) {
      
key[1] = newkey;
    }
    if (
key[0] == newkey) {
      
key[1] = oldkey;
    }
  }
}
public function 
fixKeys() {
  
temp.key null;
  
  for (
keyclient.keys) {
    if (
key[0] == null) {
      
client.keys.delete(this.keys.index(key));
    }
    
key[0] = lowercase(key[0]);
    
key[1] = lowercase(key[0]);
  }
  if (
client.keys.size() != 26) {
    
setkeys();
  }
}
function 
onKeyPressed(codekey) {
  switch(
key) {
    case 
getSetKey("q"): // inventory
      /* Toggle inventory here, for example
        Inventory.toggle();
        
        Inventory having toggle()
        as a public function */
    
break;
  }

Not too long ago someone made a thread about having a static list of keys to be replaced etc., if for example you wanted custom keys. I believe the person who made the thread was Rufus.

I tried to replicate that with this, except this is more for player-to-player configuration if each individual player wanted to have his or her own custom keys.

Example being, if you wanted s to do the q functions etc. Pretty much, this is for player comfortability. If it doesn't work properly let me know so I can do some fixing etc.
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 07:13 PM.


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