Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-16-2012, 03:45 AM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by BlueMelon View Post
Just a tip, your code lacks of comments.
I'd rather see clear code and functions/variables with appropriate names. Comments should only really be used when it might be unclear to another coder what you're trying to do.

I hate seeing stuff like this:
PHP Code:
// set hp to 100
this.hp 100
Unless you're trying to explain an algorithm to someone who isn't familiar with the language, having too many comments is just annoying.
__________________
Reply With Quote
  #2  
Old 09-16-2012, 03:00 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
You should use something like this:
Quote:
Originally Posted by Twinny View Post
This is what I did for Classic iPhone stealth (removed some other parts to provide this),

Weapon: -Staff/Stealth
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
player.attr[22] = "unstealth.gani";
}

function 
ChatBar.onAction() {
  if (
ChatBar.text == "/stealth") {
    
toggleStealth();
    
ChatBar.text "";
  }
}

function 
toggleStealth() {
  
this.stealth = !this.stealth;
  if (
this.stealth)
    
player.attr[22] = "stealth.gani";
  else
    
player.attr[22] = "unstealth.gani";

in the gani,
PHP Code:
function onPlayerEnters() {
  if (
clientr.isStaff)
    
player.alpha 0.4;
  else
    
player.alpha 0;

So, all staff can see the stealthed person at half alpha while no-one else can see them.



also, something like this
Quote:
Originally Posted by boolean View Post
PHP Code:
function onPlayerChats()
{    
   if(
player.chat.starts("/add"))
      
triggerServer("gui"this.name"add"NULLplayer.chat.tokenize()[1]);
 
   if(
player.chat.starts("/remove"))
      
triggerServer("gui"this.name"remove"NULLplayer.chat.tokenize()[1]);
 
   if(
player.chat == "/exceptions")
   {
      
triggerServer("gui"this.name"view");
      
player.chat "";
   }
 
   if(
player.chat.starts("/add") || player.chat.starts("/remove"))
      
player.chat "";

should be changed to something like this
PHP Code:
function onPlayerChats() {
  
temp.toks player.chat.tokenize();  
  if (
player.chat.starts("/add")) {
    
triggerServer("gui"this.name"add"NULLtemp.toks[1]);
    
player.chat " ";
  }
 
  else if (
player.chat.starts("/remove")) {
    
triggerServer("gui"this.name"remove"NULLtemp.toks[1]);
    
player.chat " ";
  }
  else if (
player.chat == "/exceptions") {
    
triggerServer("gui"this.name"view");
    
player.chat " ";
  }


styling your codes would also be something you should try out
__________________
MEEP!
Reply With Quote
  #3  
Old 09-16-2012, 03:10 PM
boolean boolean is offline
it wasn't me
boolean's Avatar
Join Date: Sep 2011
Posts: 16
boolean is on a distinguished road
Quote:
Originally Posted by callimuc View Post
styling your codes would also be something you should try out
lol

and yes it is changing the opacity for the players within the list of "exceptions"

PHP Code:
temp.pl.triggerClient("gui"this.helperplayer.accounttemp.exists temp.alpha temp.alpha == 0.5 1); 
Honestly, I think the onPlayerChats() event becomes so boilerplate at this point I could care less as to how I interact with it
__________________
Reply With Quote
  #4  
Old 09-16-2012, 05:14 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by boolean View Post
lol
sorry, just realized it was the styling (with the brackets in a new line, etc.) which has been irritating me
__________________
MEEP!
Reply With Quote
Reply

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 10:16 PM.


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