Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   A script I think EVERY server should have. :] (https://forums.graalonline.com/forums/showthread.php?t=134262292)

BboyEatsbacon 03-03-2011 03:46 AM

A script I think EVERY server should have. :]
 
Hey everyone. Here is a pretty basic script I threw together... I know its not that much, but it's something. :D

BboyEatsbacon 03-03-2011 03:54 AM

Sorry, didn't make it a PHP code last time. Here! :)
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/hug") {
    
setani("grab", "");
    
player.chat = "";
  }
  if (
player.chat == "/sit") {
    
setani("sit", "");
    
player.chat = "";
  }
  if (
player.chat == "/dance") {
    
setani("dance", "");
    
player.chat = "";
  }
} 


Shards-Of-Fate 03-03-2011 04:16 AM

You know, part of me was worried it would be staff boots. I'm actually kind of relieved.

kia345 03-03-2011 04:33 AM

As long as you don't have a hat economy, otherwise they'll use hug on someone who traded nude pictures for hats and she'll cry and call it harassment and get it removed.

MattKan 03-03-2011 04:51 AM

Quote:

Originally Posted by BboyEatsbacon (Post 1634209)
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/dance") {
    
setani("dance", "");
    
player.chat = ""; 



There's no default dance gani, though

fowlplay4 03-03-2011 05:09 AM

Use ChatBar.onAction() for Chat Commands instead.

PHP Code:

//#CLIENTSIDE
function ChatBar.onAction() {
  switch (
ChatBar.text.trim()) {
    case 
"/hug":   temp.gani = "grab";  break;
    case 
"/sit":   temp.gani = "sit";   break;
    case 
"/dance": temp.gani = "dance"; break;
  }
  if (
temp.gani.type() != -1) {
    
ChatBar.text = "";
    
player.setani(temp.gani, "");
  }
} 


WhiteDragon 03-03-2011 05:13 AM

Probably bad form to check if a variable exists with

if (var) {...}

because it's coercing the variable to an integer, which could technically coerce to 0 and make the if fail in certain cases where the variable does exist.

Perhaps if (var.type() != -1) {...} is the best way to do it.

Vinka 03-03-2011 02:24 PM

Nice, I want this on my server.. But I´m pretty much a newb at this, how would I go about adding it to my server? I´m guessing by making it a weapon? and all the players who login will get that weapon? Or should I add this to classes?

Thanks in advance.

ffcmike 03-03-2011 05:17 PM

Quote:

Originally Posted by BboyEatsbacon (Post 1634209)
Sorry, didn't make it a PHP code last time. Here! :)
PHP Code:

//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/hug") {
    
setani("grab", "");
    
player.chat = "";
  }
  if (
player.chat == "/sit") {
    
setani("sit", "");
    
player.chat = "";
  }
  if (
player.chat == "/dance") {
    
setani("dance", "");
    
player.chat = "";
  }
} 


I don't understand why anybody would want this type of thing as a chat command, for a start it doesn't feel natural or that you're really controlling your character in the same way that you'd slash by pressing S, it doesn't look very professional, you also get alot of people expecting it to work on servers where it is not supported due to it not being a completely aparent feature (though the same applies to emoticons), and end up trying variations of it with ":" as a prefix for example, when it simply does not exist.

With something such as assigning hotkeys for this type of thing and even allowing players to customise which keys they would like to use you're not only removing delay of typing, but you'd also be providing a method inwhich for players to discover that the feature exists.
Even something simplistic and easy enough for a new developer to create such as firing a weapon could be more appropriate.

callimuc 03-03-2011 07:39 PM

Well thats a good idea ^^ maybe like on UN the skills

BboyEatsbacon 03-04-2011 11:22 PM

@ffcmike: Now I feel like a noob for posting this....


All times are GMT +2. The time now is 01:58 AM.

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