Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #16  
Old 11-21-2009, 10:19 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
I haven't tested, but having a subvariable on an array or string literal seems a bit odd to me.

Why not just use a TStaticVar?

All that would need to be changed is that getGuildList() would need to return an array of TStaticVars, rather than say account names.

Note: If you are using a player object or something though, that would work as it extends a TGraalVar and should support subvariables.
Reply With Quote
  #17  
Old 11-22-2009, 02:35 AM
sssssssssss sssssssssss is offline
Cyril Rain
sssssssssss's Avatar
Join Date: May 2003
Location: Texas, USA
Posts: 1,134
sssssssssss will become famous soon enough
I have it when a guild registers, it sets up a ton of things like
this.guilds.GUILDNAME=members with access
this.guilds.GUILDNAME.kills
this.guilds.GUILDNAME.levels
this.guilds.GUILDNAME.deaths
this.guilds.GUILDNAME.rupees
this.guilds.GUILDNAME.ec
theres more too, just trying to pull the guilds with top 5 kills and post them in a gui with the code I posted a few before this.

so if SDE registered, it'd set up vars, like so:
this.guilds.SDE
this.guilds.SDE.kills
this.guilds.SDE.deaths
this.guilds.SDE.rupees

and say SNC

this.guilds.SNC
u get the picture. So Im trying to pull all the this.guilds.GUILDNAME.kills for each guild registered, sort it, get the top 5 kills, then say like "Guildname: Kills" line by line a gui.
__________________
Cyril Rain
Creator and leader of SLX
Admin of Elysium
Elysium's Facebook Page: http://facebook.com/GraalOnlineElysium
Graal Forum Thread: http://forums.graalonline.com...
Graalians Thread: http://www.graalians.com...


Reply With Quote
  #18  
Old 11-22-2009, 03:58 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
PHP Code:
public function getTopAbyss(){
  
temp.guilds getGuildList();
  for (
i=0i<temp.guilds.size(); i++) {
    
temp.guilds[i].kills this.guilds.(@temp.guilds[i]).kills;
  }
  
temp.guilds.sortbyvalue("kills"nulltrue);
  echo(
temp.guilds);

Jer, I think you were a little messed up with your loop and setting the variable as temp.g.kills, because based off what Chris posted you need to save it as a subvariable in the array, though I've never used array.sortbyvalue() before.
__________________
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
  #19  
Old 11-22-2009, 04:15 AM
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
Quote:
Originally Posted by Switch View Post
Jer, I think you were a little messed up with your loop and setting the variable as temp.g.kills, because based off what Chris posted you need to save it as a subvariable in the array, though I've never used array.sortbyvalue() before.
The code I posted works, as I tested it successfully.

This is basically what you'll need, you've tried enough to deserve it.

PHP Code:
public function getTop5() { 
  
// Initialize Array and Kills Structure  
  
temp.guildzname getGuildList();  
  
// Loop and Record Kills in the Array Member's sort variable  
  
for (temp.gtemp.guildzname) {  
    
temp.g.kills this.guilds.(@temp.g).kills;  
  }
  
// Sort 
  
temp.guildzname.sortbyvalue("kills"nullfalse);
  
// Loop through Sorted Data
  
for (temp.0temp.5temp.i++) {
    
// Determine Variables
    
temp.temp.guildzname[temp.i];
    
temp.kills this.guilds.(@temp.g).kills;
    
temp.str = (temp."'s kills: " temp.kills);
    
// Add formatted string to data array
    
temp.data.add(temp.str);
  }
  
// Return the data array  
  
return temp.data;  

__________________
Quote:
Reply With Quote
  #20  
Old 11-22-2009, 04:23 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 fowlplay4 View Post
The code I posted works, as I tested it successfully.
Well sort by value's 3rd param, in your posted script just now, has to be true for descending value.
But anyways.

PHP Code:
public function getTopAbyss(){
  
temp.guilds getGuildList();
  for (
temp.temp.guilds) {
    
temp.g.kills this.guilds.(@temp.g).kills;
  }
  
temp.guilds.sortbyvalue("kills"nulltrue);
  echo(
temp.guilds);

Echoed
NPC Code:
The script of NPC db_registeredguilds has been updated by Switch
Wolfs,Owner,Poop,SDE,BTK
The script of NPC db_registeredguilds has been updated by Switch
BTK,SDE,Poop,Wolfs,Owner
The script of NPC db_registeredguilds has been updated by Switch
SDE,BTK,Wolfs,Owner,Poop



While this
PHP Code:
public function getTopAbyss(){
  
temp.guilds getGuildList();
  for (
i=0i<temp.guilds.size(); i++) {
    
temp.guilds[i].kills this.guilds.(@temp.guilds[i]).kills;
  }
  
temp.guilds.sortbyvalue("kills"nulltrue);
  echo(
temp.guilds);

Echoed
NPC Code:
The script of NPC db_registeredguilds has been updated by Switch
BTK,Poop,Owner,Wolfs,SDE
The script of NPC db_registeredguilds has been updated by Switch
Owner,BTK,Poop,Wolfs,SDE
The script of NPC db_registeredguilds has been updated by Switch
Owner,BTK,Poop,Wolfs,SDE


Note that BTK, Owner, and Poop all have 0 kills, so they can have a random order, and Wolfs has 2 kills and SDE has 22 kills.
__________________
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
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 07:36 PM.


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