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
  #1  
Old 01-16-2007, 06:10 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Post Help

I just recently scripted a mailing system and I am now scripting the part that states who has the most letters sent.

PHP Code:
for (iallplayers){
temp.player findPlayer(i);
this.sentmail.(@temp.player) = temp.player.clientr.sentmailamt;

I get it to output in the flags of the npc 'Mail':
PHP Code:
sentmail.MandangoP2P=19
sentmail
.rapidwolve=2
sentmail
.Spike5656=
I then use a function 'calcMostSent' to determine who sent the most I am stumped at this part, I have no clue what to do. I've tried:
PHP Code:
for (jthis.sentmail.getdynamicvarnames()){
if (
this.sentmail.(@j) > this.sentmail(@j[j+j-1]){
this.mostsent this.sentmail.(@j);
this.mostsentacc j;
}

Don't even ask why I did that, because I was just guessing X_x. I tried alot of other ways but it hasn't worked. Can somebody help me?

Last edited by Rapidwolve; 01-16-2007 at 06:20 AM..
Reply With Quote
  #2  
Old 01-16-2007, 07:22 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
PHP Code:
temp.keys getstringkeys("this.sentmail.");
setarray(temp.mostsent2); // account & number sent
for (temp.0temp.temp.keys.size(); temp.++) {
  
temp.current makevar("this.sentmail." temp.keys[temp.i]);
  if (
temp.current temp.mostsent[1]) {
    
temp.mostsent[1] = temp.current;
    
temp.mostsent[0] = temp.keys[temp.i];
  }
}
return 
temp.mostsent[0]; 
I prefer using makevar() since the other way seems to get funky sometimes.
__________________
Reply With Quote
  #3  
Old 01-17-2007, 03:00 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Once again you helped me
Reply With Quote
  #4  
Old 01-17-2007, 06:10 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
PHP Code:
for (jthis.sentmail.getdynamicvarnames()){
if (
this.sentmail.(@j) > this.sentmail(@j[j+j-1]){
this.mostsent this.sentmail.(@j);
this.mostsentacc j;
}

PHP Code:
if (this.sentmail.(@j) > this.sentmail(@j[j+j-1]){ 
i guess it could work if you change it to, and you forgot a closing )

PHP Code:
if (this.sentmail.(@j) > this.(@ "sentmail" j[j+j-1])){ 
or did you try to do this
PHP Code:
if (this.sentmail.(@j) > this.sentmail.(@j[j+j-1])){ 
Reply With Quote
  #5  
Old 01-17-2007, 06:16 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 projectigi View Post
PHP Code:
for (jthis.sentmail.getdynamicvarnames()){
if (
this.sentmail.(@j) > this.sentmail(@j[j+j-1]){
this.mostsent this.sentmail.(@j);
this.mostsentacc j;
}

PHP Code:
if (this.sentmail.(@j) > this.sentmail(@j[j+j-1]){ 
i guess it could work if you change it to, and you forgot a closing )

PHP Code:
if (this.sentmail.(@j) > this.(@ "sentmail" j[j+j-1])){ 
or did you try to do this
PHP Code:
if (this.sentmail.(@j) > this.sentmail.(@j[j+j-1])){ 
he only missed a bracet :O

if (this.sentmail.(@j) > this.sentmail(@j[j+j-1]){

should be

if (this.sentmail.(@j) > this.sentmail(@j[j+j-1])){

NPC Code:

if (this.sentmail.(@j) > this.sentmail(@j[j+j-1])){

__________________
Reply With Quote
  #6  
Old 01-17-2007, 08:13 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by Chompy View Post
NPC Code:

if (this.sentmail.(@j) > this.sentmail(@j[j+j-1])){

That wouldn't work, because it would be trying to call the 'sentmail' function, the correct way to do it was already stated: this.(@"sentmail" @ j[j+j-1]), or by using makevar()
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 01-17-2007, 08:30 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Inverness View Post
I prefer using makevar() since the other way seems to get funky sometimes.
this.(@varname) is more efficient and less cluttered. It's 'funky' in the original post because he's using the for-each loop variables incorrectly.

Quote:
Originally Posted by projectigi View Post
i guess it could work if you change it to, and you forgot a closing )

PHP Code:
if (this.sentmail.(@j) > this.(@ "sentmail" j[j+j-1])){ 
or did you try to do this
PHP Code:
if (this.sentmail.(@j) > this.sentmail.(@j[j+j-1])){ 
Neither works. j is most likely a string. I don't know what str + str -1 makes. Nor can I be certain what str[str+str-1] does.

Quote:
Originally Posted by Chompy View Post
NPC Code:

if (this.sentmail.(@j) > this.sentmail(@j[j+j-1])){


PHP Code:
temp.arr this.sentmail.getdynamicvarnames();
temp.max = {-1,{""}};
for (
jtemp.arr) {
  
temp.sent this.sentmail.(@j);
  if (
temp.sent temp.max[0]) {
    
temp.max = {temp.sent,{j}};
  } elseif (
temp.sent == temp.max[0]) temp.max[1].add(j);
}
return 
temp.max[1]; 
Or something of that sort.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #8  
Old 01-17-2007, 10:52 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Tolnaftate2004
this.(@varname) is more efficient and less cluttered. It's 'funky' in the original post because he's using the for-each loop variables incorrectly.
How exactly is it more efficient?
__________________
Reply With Quote
  #9  
Old 01-18-2007, 12:56 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
Quote:
Originally Posted by Inverness View Post
How exactly is it more efficient?
My guess is that is just has to access the variable, rather than have to call a function.

Not a big difference really ... I was just never a big fan of makevar.... (but you know that already :P).
__________________
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
  #10  
Old 01-18-2007, 01:11 AM
Rapidwolve Rapidwolve is offline
Registered User
Join Date: Jul 2006
Posts: 1,241
Rapidwolve is an unknown quantity at this point
Quote:
Originally Posted by Inverness View Post
How exactly is it more efficient?
I never understood how it was more efficient either but I use it now because I dont want to type makevar all the time
Reply With Quote
  #11  
Old 01-18-2007, 01:33 AM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by Inverness View Post
How exactly is it more efficient?
I think Stefan said it somewhere. I went looking for it, but I couldn't find it.

But logically, one could assume that the makevar function is just doing a (@var) thing anyway.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #12  
Old 01-18-2007, 01:37 AM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Tolnaftate2004 View Post
I think Stefan said it somewhere. I went looking for it, but I couldn't find it.

But logically, one could assume that the makevar function is just doing a (@var) thing anyway.
Logically it would perform (@ var) in iteration for each part.of.the.variable, I suppose, not sure if that is how it is actually working though.
Reply With Quote
  #13  
Old 01-18-2007, 07:28 AM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Rapidwolve View Post
I never understood how it was more efficient either but I use it now because I dont want to type makevar all the time
Typeing makevar is not a problem with me it takes no time at all. And I don't need to use makevar in the mudlib anyhow since I have functions for that. I like makevar because it looks better to me than the other option.
__________________
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 - 2024, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.