Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-03-2008, 01:53 PM
[email protected] sid.gottlieb@googlemail.com is offline
Banned
Join Date: Mar 2008
Posts: 861
sid.gottlieb@googlemail.com will become famous soon enough
cool summon

summons people if you spell their name wrong!!!

account/nickname:- Sidney/feltcher, Darlene/snowblower, PFA/starfish

[/summon] Sid, felt - Summons Sidney
Dar, snow - Summons Darlene
PFA, star - Summons PFA

PHP Code:
function onActionServerside(temp.commandtemp.account) {
    if (
command == "summon"findPlayer(account).setlevel2(player.level.nameplayer.xplayer.y);
}

//#CLIENTSIDE
function onPlayerChats() {
    if (
player.chat.starts("/summon")) {
        
temp.chat player.chat.substring(7).trim();
        for (
temp.iallplayers
            if (
i.account.starts(chat) || i.nick.starts(chat)) {
                
i.account;
                break;
            }
        }
    
        
triggerserver("weapon"this.name"summon"i);
    }

Reply With Quote
  #2  
Old 04-03-2008, 04:57 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
You might consider using something like this that was posted by me. There is a whole thread about this in the code gallery, called 'Function findName()'.

PHP Code:
public function findName

  
this.look = { "account""communityname""nick""id" }; 
   
  for ( 
temp.allplayers 
  { 
    for ( 
temp.this.look 
    { 
      if ( 
makevar"temp.a." temp.) == 
      { 
        return 
temp.a.account
      } 
    } 
  } 
   
  for ( 
temp.allplayers 
  { 
    for ( 
temp.this.look 
    { 
      if ( 
makevar"temp.a." temp.).starts) ) 
      { 
        return 
temp.a.account
      } 
    } 
  } 
   
  return 
false

Which is basically a cleaner, reusable way of what you did.

And then please, use braces for each function so you do this:

PHP Code:
if ( true )
{
  
banana();

instead of this:
PHP Code:
if ( true banana(); 
Makes it easier to read.
__________________
Reply With Quote
  #3  
Old 04-03-2008, 09:41 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by cbkbud View Post
You might consider using something like this that was posted by me. There is a whole thread about this in the code gallery, called 'Function findName()'.

PHP Code:
public function findName

  
this.look = { "account""communityname""nick""id" }; 
   
  for ( 
temp.allplayers 
  { 
    for ( 
temp.this.look 
    { 
      if ( 
makevar"temp.a." temp.) == 
      { 
        return 
temp.a.account
      } 
    } 
  } 
   
  for ( 
temp.allplayers 
  { 
    for ( 
temp.this.look 
    { 
      if ( 
makevar"temp.a." temp.).starts) ) 
      { 
        return 
temp.a.account
      } 
    } 
  } 
   
  return 
false

Which is basically a cleaner, reusable way of what you did.
Actually, she was using a method for finding names that started with the parameter, yours check if it equals.

And Sidney, I would suggest using
PHP Code:
...
for(
temp.players) {
  if (
i.account.pos(chat) > -|| i.nick.pos(chat) > -1  || i.communityname.pos(chat) > -1) {
    
i.account;
    break;
  }
}
... 
or something like that, so if their nick/account/community contains the parameter, it will return their account, instead of just checking if their account/nick etc. starts with the parameter

Quote:
Originally Posted by cbkbud View Post
And then please, use braces for each function so you do this:

PHP Code:
if ( true )
{
  
banana();

instead of this:
PHP Code:
if ( true banana(); 
Makes it easier to read.
You don't need them if there is a single line action after the if statement, it's all about personal preference.

And it isn't spelled 'braces', that something different
__________________
Reply With Quote
  #4  
Old 04-03-2008, 09:45 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by Chompy View Post
Actually, she was using a method for finding names that started with the parameter, yours check if it equals.

And Sidney, I would suggest using
PHP Code:
...
for(
temp.players) {
  if (
i.account.pos(chat) > -|| i.nick.pos(chat) > -1  || i.communityname.pos(chat) > -1) {
    
i.account;
    break;
  }
}
... 
or something like that, so if their nick/account/community contains the parameter, it will return their account, instead of just checking if their account/nick etc. starts with the parameter



You don't need them if there is a single line action after the if statement, it's all about personal preference.

And it isn't spelled 'braces', that something different
No, they are braces.

Braces: { }
Brackets: [ ]

And I am checking if there is an exact match first, THEN if there is starting, not just exact ...
__________________
Reply With Quote
  #5  
Old 04-03-2008, 11:59 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by cbkbud View Post
No, they are braces.

Braces: { }
Brackets: [ ]
Hmm, actually I found out they are all brackets, but braces is a different name for {}'s..

( ) round brackets or parentheses
[ ] square brackets or box brackets
{ } curly brackets or braces
< > angle brackets or chevrons

braces is kind of a synonym for brackets
And, from the wiki:

Quote:
Originally Posted by Wikipedia
Therefore, when it is necessary to avoid any possibility of confusion, such as in computer programming, it may be best to use the term curly bracket rather than brace.

Quote:
Originally Posted by cbkbud View Post
And I am checking if there is an exact match first, THEN if there is starting, not just exact ...
Dude, do you know how many loops there is in your script?
And you don't need 4 for loops to check obj.starts() and obj equals, could be done in 2 for loops, actually even in 1 for loop..
__________________

Last edited by Chompy; 04-04-2008 at 12:21 AM..
Reply With Quote
  #6  
Old 04-04-2008, 05:21 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
It was an example, I know it could be optimized better. It was just to show the type of thing you could do.

About the braces -- I've always heard {} were braces, () were parenthesis, and [] were brackets. Perhaps I've taken the wrong computer classes, or just not a large enough variety of them.
__________________
Reply With Quote
  #7  
Old 04-04-2008, 11:00 AM
napo_p2p napo_p2p is offline
oh snaps
napo_p2p's Avatar
Join Date: Sep 2003
Location: Pismo Beach, California
Posts: 2,118
napo_p2p has a spectacular aura aboutnapo_p2p has a spectacular aura about
Send a message via AIM to napo_p2p Send a message via MSN to napo_p2p
I call {} curly braces. It's sort of redundant, though, now that I look at it...
__________________
Scito hoc super omnia.
Haec vita est tua una sola.
Dum vita superest, utere maxime quoque puncto, momento, et hora quae habes.
Tempus neminem non manet.
Noli manere tempus.
Carpe Diem

Seize the Day.
Reply With Quote
  #8  
Old 04-05-2008, 03:27 AM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by cbkbud View Post
About the braces -- I've always heard {} were braces, () were parenthesis, and [] were brackets. Perhaps I've taken the wrong computer classes, or just not a large enough variety of them.
No, you're right. That's what they're ACTUALLY called.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #9  
Old 04-05-2008, 04:12 AM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Switch View Post
No, you're right. That's what they're ACTUALLY called.
Read the wikipedia It's actually a (curly) bracket but has an other name for it, which is brace.
__________________
Reply With Quote
  #10  
Old 04-05-2008, 04:37 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by [email protected] View Post
Darlene/snowblower
:o
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 07:17 PM.


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