Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-12-2007, 04:57 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
My First Code in the Gallery -spar

Umkay, this is a spar script and you would place the npc in the center of ur spar

commands:
Focus = to turn on focus
Focus off = to turn off focus
Start = to start count down
/In = to enter spar
/out = to leave spar
End = to stop the count down

PHP Code:
//#CLIENTSIDE
function onPlayerChats(){
  if (
player.chat=="focus"){
    
setfocus(30.5,25);//the center of ur spar
  
}
  if (
player.chat=="focus off"){
    
resetfocus();
  }
  if(
playerx>12 && playerx<52){//first x is the top left corner of ur spar quare and the second is the botem right
    
if(playery>13 && playery<41){//same for here accept its y
      
if (player.chat=="start"){//place this npc in the middle of ur spar
        
this.chat "You have 5 seconds untill start!";
        
sleep(2);
        
this.chat "3";
        
sleep(1);
        
this.chat "2";
        
sleep(1);
        
this.chat "1";
        
sleep(1);
        
this.chat "Spar!";
        
sleep(1);
        
this.chat "Spar";
        
sleep(.1);
        
this.chat "pa";
        
sleep(.1);
        
this.chat "";
      }
      if (
player.chat=="end"){
        
this.chat "";
      }
    }
  }
  if (
player.chat=="/in"){
    
enableweapons();
    
disablepause();
    
player.30.5;//middle of ur spar
    
player.25.5;//middle of ur spar
  
}
  if (
player.chat=="/out"){
    
enablepause();
    
disableweapons();
    
player.30.5;//the out side of ur spar
    
player.46;//the out side of ur spar
  
}
  if (
player.chat=="heal"){
    
player.hearts player.fullhearts;
  }
}
function 
onPlayerDies(){
  
player.30.5;//the out side of ur spar
  
player.46;//the out side of ur spar
}
function 
onPlayerEnters(){
  
enablepause();
  
disableweapons();
}
function 
onPlayerLeaves(){
enablepause();
enableweapons();


u just have to replace the x and y coordinates
__________________
**FLIP OUT**

Last edited by theHAWKER; 06-13-2007 at 03:52 AM..
Reply With Quote
  #2  
Old 06-12-2007, 05:38 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
A good start
I would just do something about that you can say /heal when you're inside the fighting area though
__________________
Reply With Quote
  #3  
Old 06-12-2007, 07:10 PM
Grey Grey is offline
Classic Developer
Grey's Avatar
Join Date: Mar 2007
Location: Wales, UK
Posts: 134
Grey will become famous soon enough
Send a message via AIM to Grey
Not a bad start. There is a bracket missing at the very end of the code, but I suspect maybe you accidently cut that off when you pasted the code?

In terms of improving scripting style/optimizing the script I'd suggest looking into switch statements maybe to avoid using so many if statements for checking the chat.

ie.

PHP Code:
if (player.chat == cmd) {
  switch (
cmd) {
    case 
"start": {
    
//stuff that happens when the player says start here.
    
break;
    }
    case 
"/in": {
    
//stuff for 'in' here
    
break;
    }
  }

And also when you check the player's x and y for starting the spar the way you have done it is okay, but it would be better to have done:

PHP Code:
if (player.x in |12,52| && player.y in |13,41|) { 
//stuff here

Reply With Quote
  #4  
Old 06-12-2007, 07:53 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Why is it clientside?
__________________
Reply With Quote
  #5  
Old 06-13-2007, 03:53 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Quote:
Originally Posted by Chompy View Post
A good start
I would just do something about that you can say /heal when you're inside the fighting area though
I just use a trust system xD

Quote:
Originally Posted by xAndrewx View Post
Why is it clientside?
i dont think it works server side...
__________________
**FLIP OUT**
Reply With Quote
  #6  
Old 06-13-2007, 08:33 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
You're aware that you can't edit your hearts clientside and once you say start, only YOU can see the message?
__________________
Reply With Quote
  #7  
Old 06-13-2007, 04:58 PM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Quote:
Originally Posted by xAndrewx View Post
You're aware that you can't edit your hearts clientside and once you say start, only YOU can see the message?
it works fine for me
__________________
**FLIP OUT**
Reply With Quote
  #8  
Old 06-14-2007, 09:40 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Did you test it out with anyone? You may have seen the message but since it is clientside, the other person wouldn't see anything.

As Andrew said, hearts cannot be set clientside no matter what. Triggers are needed as only serverside can right to the variable.
Reply With Quote
  #9  
Old 06-15-2007, 02:40 AM
theHAWKER theHAWKER is offline
**FLIP OUT**
theHAWKER's Avatar
Join Date: Mar 2006
Location: canada, vancouver
Posts: 768
theHAWKER is an unknown quantity at this point
Quote:
Originally Posted by Twinny View Post
Did you test it out with anyone? You may have seen the message but since it is clientside, the other person wouldn't see anything.
well good for my first almost working script (in GS2) xD
__________________
**FLIP OUT**
Reply With Quote
  #10  
Old 07-12-2007, 12:47 AM
ff7chocoboknight ff7chocoboknight is offline
Skyzer Zolderon
ff7chocoboknight's Avatar
Join Date: Dec 2006
Location: New Hampshire, United States
Posts: 725
ff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to allff7chocoboknight is a name known to all
Send a message via AIM to ff7chocoboknight Send a message via MSN to ff7chocoboknight
the first enablepause() should be disablepause()

I've noticed that this is a script from graal.net converted into GS2
__________________
Reply With Quote
Reply


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:55 PM.


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