Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-12-2010, 07:14 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
setting teams in events.

PHP Code:
function onPlayerChats(){
if(
player.guild.starts("Events")){
if(
player.chat="/setteams"){
players.remove(player.account);
playerscount-1;
player.chat=int((playerscount-1)/4)@"/"@playerscount-1;
for (
i=0;i<playerscount-1;i++){
if(!(
players[int(i)].guild.starts("Events"))){
players[int(i/12)].setlevel2("event_ttw-lobby.nw",23.5,30);
players[int(i/12)].guild "TTW Team 1";
players[int(i/8)].setlevel2("event_ttw-lobby.nw",44,30);
players[int(i/8)].guild "TTW Team 2";
players[int(i/4)].setlevel2("event_ttw-lobby.nw",23.5,44.5);
players[int(i/4)].guild "TTW Team 3";
players[int(i)].setlevel2("event_ttw-lobby.nw",44,44.5);
players[int(i)].guild "TTW Team 4";
}
}
}
}

it keeps making the event's team as a player... how do i remove that.?
also is there any ways to make this script better?
Reply With Quote
  #2  
Old 08-12-2010, 08:21 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
ever heard of code styling? (if you haven't, google it!)

i doubt anyone would help you without you putting some effort in learning how to style your code.

PHP Code:
function exampleOfStyling() {
  if (
value == foo) {
    
doFoo();
  }
  else if (
value == bar) {
    if (
bar == 5) {
      
doBar();
    } else 
doBarTwo();
  }

it will also make your code much easier to read for others.
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #3  
Old 08-12-2010, 08:35 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
For Loop Explanation: http://forums.graalonline.com/forums...11&postcount=4

You also can't modify the 'players' array.

Here's a common method for placing each person a different team, by just using an alternating boolean/flag.

PHP Code:
function setupTeams() {
  
// Initialize flag so first player is added to the Red team
  
temp.red true;
  
// Loop through players in level
  
for (temp.plyrplayers) {
    
// Ignore Events Team / Admin
    
if (!temp.plyr.guild.starts("Events")) {
      
// Check if setting to Red team.
      
if (temp.red) {
        
// Set guild to Red
        
temp.plyr.guild "Red";
        
// Reset flag so next player is blue
        
temp.red false;
      } else {
        
// Set guild to Blue
        
temp.plyr.guild "Blue";
        
// Set flag so next player is red
        
temp.red true;
      }
    }
  }

__________________
Quote:
Reply With Quote
  #4  
Old 08-12-2010, 08:36 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
Quote:
Originally Posted by Deas_Voice View Post
ever heard of code styling? (if you haven't, google it!)

i doubt anyone would help you without you putting some effort in learning how to style your code.

PHP Code:
function exampleOfStyling() {
  if (
value == foo) {
    
doFoo();
  }
  else if (
value == bar) {
    if (
bar == 5) {
      
doBar();
    } else 
doBarTwo();
  }

it will also make your code much easier to read for others.
ahh! fine...
PHP Code:
function onPlayerChats(){
  if(
player.guild.starts("Events")){
    if(
player.chat="/setteams"){
      
players.remove(player.account);
      
playerscount-1;
      
player.chat=int((playerscount-1)/4)@"/"@playerscount-1;
      for (
i=0;i<playerscount-1;i++){
        if(!(
players[int(i)].guild.starts("Events"))){
          
players[int(i/12)].setlevel2("event_ttw-lobby.nw",23.5,30);
          
players[int(i/12)].guild "TTW Team 1";
          
players[int(i/8)].setlevel2("event_ttw-lobby.nw",44,30);
          
players[int(i/8)].guild "TTW Team 2";
          
players[int(i/4)].setlevel2("event_ttw-lobby.nw",23.5,44.5);
          
players[int(i/4)].guild "TTW Team 3";
          
players[int(i)].setlevel2("event_ttw-lobby.nw",44,44.5);
          
players[int(i)].guild "TTW Team 4";
        }
      }
    }
  }

Reply With Quote
  #5  
Old 08-12-2010, 09:21 PM
Dnegel Dnegel is offline
Rjax Shizibz
Join Date: Jul 2009
Posts: 1,334
Dnegel will become famous soon enough
Quote:
Originally Posted by xMane View Post
PHP Code:
function onPlayerChats(){
if(
player.guild.starts("Events")){
if(
player.chat="/setteams"){
players.remove(player.account);
playerscount-1;
player.chat=int((playerscount-1)/4)@"/"@playerscount-1;
for (
i=0;i<playerscount-1;i++){
if(!(
players[int(i)].guild.starts("Events"))){
players[int(i/12)].setlevel2("event_ttw-lobby.nw",23.5,30);
players[int(i/12)].guild "TTW Team 1";
players[int(i/8)].setlevel2("event_ttw-lobby.nw",44,30);
players[int(i/8)].guild "TTW Team 2";
players[int(i/4)].setlevel2("event_ttw-lobby.nw",23.5,44.5);
players[int(i/4)].guild "TTW Team 3";
players[int(i)].setlevel2("event_ttw-lobby.nw",44,44.5);
players[int(i)].guild "TTW Team 4";
}
}
}
}

Oh what a mess.
Reply With Quote
  #6  
Old 08-12-2010, 09:38 PM
xMane xMane is offline
NPC-Server (Server)
xMane's Avatar
Join Date: May 2010
Posts: 59
xMane is on a distinguished road
also why doesnt
PHP Code:
if(hasweapon("weaponname")) 
works?
Reply With Quote
  #7  
Old 08-12-2010, 09:41 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by xMane View Post
also why doesnt
PHP Code:
if(hasweapon("weaponname")) 
works?
because hasWeapon() is GS1 and un-supported in GS2
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #8  
Old 08-12-2010, 10:03 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
The GS2 version of that function:

PHP Code:
public function hasWeapon(wepname) {
  return (
findweapon(wepnamein player.weapons);

__________________
Quote:
Reply With Quote
  #9  
Old 08-12-2010, 10:15 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
PHP Code:
if(player.chat="/setteams"){ 
needs to be

PHP Code:
if(player.chat=="/setteams"){ 
This isn't just personal preference, it's necessary because otherwise the engine tries to assign a value to player.chat.

You can simplify your script very easily:

PHP Code:
function onPlayerChats() {
  if (
player.guild == "Events Team") {
    if (
player.chat == "/setteams") {
      
temp.teams = { // team name, level, x, y
                     
{"TTW Team 1""event_ttw-lobby.nw"23.530},
                     {
"TTW Team 2""event_ttw-lobby.nw"4430},
                     {
"TTW Team 3""event_ttw-lobby.nw"23.544.5},
                     {
"TTW Team 4""event_ttw-lobby.nw"4444.5}
                   };
      
      
temp.0;
      for (
temp.pl players) {
        if (
pl.guild == "Events Team") {
          continue;
        }
        
        
temp.team teams[teams.size()];
        
pl.guild team[0];
        
pl.setLevel2(team[1], team[2], team[3]);
        
++;
      }
    }
  }

__________________
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 09:52 PM.


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