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-31-2008, 05:59 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Troubles with gani scripts

I'm using gani scripts for the display heart and nick/chat display on Maloria, but I'm running into trouble. For one thing, they don't always show up for everyone...sometimes they do, sometimes they don't, for no apparent reason. They also don't always work in the GMAP, but, like the other problem, sometimes they do.

It's all very frustrating, and I'm not entirely experienced with gani scripts, so if anyone has an idea, please help. D:
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #2  
Old 01-31-2008, 06:07 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 had pretty much the same problem a while back. It had to do with image objects getting destroyed. Hell Raven helped me out with it. I'm not sure if it applies in your case (you didn't provide a script :P), but here's a link to that thread:

http://forums.graalonline.com/forums...ad.php?t=72305
__________________
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
  #3  
Old 01-31-2008, 07:18 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Well, it's not a problem with playerenters, since I'm not using that. Most of the scripts aren't entirely mine, but rather old maloria script, but I edited them.

The Heart display script:
PHP Code:
function onCreated() {
  
showimg(200"mal_heartanim.gif", (player.0.5)%64, (player.2)%64);
  
setTimer(0.05);
}

function 
onTimeout() {
  
findimg(200).player.0.5;
  
findimg(200).player.2;

  if (
player.attr[8] == NULL) {
    
temp.healthcheck 0;

    
findimg(100).player.0.5;
    
findimg(100).player.2;
  
    
temp.healthcheck player.attr[4] * 100;

    if (
temp.healthcheck in |96100|) findimg(200).red 0.1;
    else if (
temp.healthcheck in |9195|) findimg(200).red 0.2;
    else if (
temp.healthcheck in |8690|) findimg(200).red 0.3;
    else if (
temp.healthcheck in |8185|) findimg(200).red 0.4;
    else if (
temp.healthcheck in |7680|) findimg(200).red 0.5;
    else if (
temp.healthcheck in |7175|) findimg(200).red 0.6;
    else if (
temp.healthcheck in |6670|) findimg(200).red 0.7;
    else if (
temp.healthcheck in |6165|) findimg(200).red 0.8;
    else if (
temp.healthcheck in |5660|) findimg(200).red 0.9;
    else if (
temp.healthcheck in |5155|) findimg(200).red 1;
    else if (
temp.healthcheck in |4650|) findimg(200).green 0.9;
    else if (
temp.healthcheck in |4145|) findimg(200).green 0.8;
    else if (
temp.healthcheck in |3640|) findimg(200).green 0.7;
    else if (
temp.healthcheck in |3135|) findimg(200).green 0.6;
    else if (
temp.healthcheck in |2630|) findimg(200).green 0.5;
    else if (
temp.healthcheck in |2125|) findimg(200).green 0.4;
    else if (
temp.healthcheck in |1620|) findimg(200).green 0.3;
    else if (
temp.healthcheck in |1115|) findimg(200).green 0.2;
    else if (
temp.healthcheck in |610|) findimg(200).green 0.1;
    else if (
temp.healthcheck in |15|) findimg(200).green 0;
  }
  else if (
player.attr[8] == "black") {
    
with (findimg(200)) {
      
mode red green blue 0;
    }
  }
  else if (
player.attr[8] == "white") {
    
with (findimg(200)) {
      
mode red green blue 1;
    }
  }
    
  
  
setTimer(0.05);

player.attr[4] is hp/maxhp (ignore the part with player.attr[8], I'm probably gonna remove it)

Here's the nickname display script:
PHP Code:
function onCreated() onTimeOut();
function 
onTimeOut() {
  if (!
clientr.stealth) {
    
temp.nick player.attr[10].tokenize("(");
    
temp.width1 = (temp.nick[0].length()*6)/16;
    
temp.width2 = (player.attr[11].length()*6)/16;
    
showtext(200player.x+1.5-(temp.width1/2), player.y+3"Verdana""b"temp.nick[0]);
    
changeimgcolors(200111.85);
    
changeimgzoom(200.6);
    
showtext(201player.x+1.5-(temp.width2/2), player.y+3.75"Verdana""b"player.attr[11]);
    
changeimgcolors(201111.85);
    
changeimgzoom(201.6);
  }
  else 
hideimgs(200201);
  
setTimer(0.05);

player.attr[10] is the players nickname

And then this is the chat display script. (It's quite messy, the guy who originally made it wasn't the best scripter)
PHP Code:
function onPlayerEnters() Init();
function 
onTimeOut() Init();
function 
Init() {
  if (
player.chat.length() > 0) {
    if(
this.mode != 1)
      
this.mode=1;
    if(
this.char != player.attr[16].length()) {
      
this.char player.attr[16].length();
      
hideimgs(200,400);
    }
    if(
this.text != player.attr[16] || this.chatx != (player.x) ||this.chaty != (player.y+2) || this.chatz != (player.z+2.5)) {
      
this.text player.attr[16];
      
temp.tokens wraptext(56,NULL,player.chat);
      
this.chatx player.x;
      
this.chaty player.y+2;
      
this.chatz player.z+2.5;
      for(
i=0;i<temp.tokens.size();i++) {
    
temp.width = (temp.tokens[i].length()*4)/16;
        
showtext2(200+i,this.chatx-(temp.width/2),this.chaty,this.chatz+(temp.tokens.size()-1)-i,"Comic Sans","b",temp.tokens[i]);
        
//Temporary color
        
changeimgcolors(200+i,1,1,1,1);
        
changeimgzoom(200+i,client.textsize);
        
findImg(200+i).layer++;
        
showtext2(300+i,this.chatx+.2-(temp.width/2),this.chaty+.2,this.chatz+(temp.tokens.size()-1)-i,"Comic Sans","b",temp.tokens[i]);
        
changeimgcolors(300+i,0,0,0,.5);
        
changeimgzoom(300+i,client.textsize);
      }
    }
  }
  else {
    if(
this.mode == 1) {
      
this.mode 0;
      
hideimgs(200,400);
    }
  }
  
setTimer(0.05);

I do, however, use onPlayerEnters() in the main system script. I do something like this:
PHP Code:
player.attr[7] = "";
player.attr[7] = "ganiname.gani"
To reset the gani script.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #4  
Old 01-31-2008, 08:02 AM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
You should be using onPlayerEnters, not onCreated. Gani scripts don't function very well with onCreated and onPlayerEnters is only called when the player seeing the gani first sees it for that instance, not when you actually enter a level.

Also, you should check for every player what their attrs are.

Like if I was doing it and was using you as a test subject, in a clientside test npc I would put:
PHP Code:
//#CLIENTSIDE
function onCreated() {
  
player.chat findplayer("zokemon").attr[2]; // (2 as an example)

I would see if both me and you had the same result in our chats. Then I would just replace zokemon with coreys and again check both of our chat's. Kinda hard to do that when you have chat disabled though so maybe a trigger serverside and an echo(account @ ": " @ result);
__________________
Do it with a DON!
Reply With Quote
  #5  
Old 01-31-2008, 04:35 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Well, I can always enable chat to test that, but also I have another problem. The function textwidth() doesn't work in gani scripts for some reason, and...it's a bit of a problem. I need the width of the text to properly center it. Is there some other way to accurately get the text width?

Oh, also, in the Heart Display gani it's showing an animated heart above the player. But for some reason, under the animation, it shows an un-animated version of that heart (the first frame of it, I guess)
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #6  
Old 01-31-2008, 05:00 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by coreys View Post
Is there some other way to accurately get the text width?
wraptext2() ?
Reply With Quote
  #7  
Old 01-31-2008, 05:54 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
wraptext and wraptext2 don't get the width.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #8  
Old 01-31-2008, 06:03 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Well, wraptext2 works with the width set in pixels, so you could maybe get what you want with it.
Reply With Quote
  #9  
Old 01-31-2008, 06:05 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
what you need is gettextwidth() instead of textwidth()
__________________
Reply With Quote
  #10  
Old 01-31-2008, 08:19 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Chompy View Post
what you need is gettextwidth() instead of textwidth()
Exactly. textwidth is from GS1 and thus does not use quotes for the string within it (just like most gs1 string related commands).

If you try to do textwidth(this.chat, params) (don't know the placement of the arguements) you would simply get 9 all the time .
__________________
Do it with a DON!
Reply With Quote
  #11  
Old 01-31-2008, 08:46 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Actually it was returning 0. I just didn't work at all. lol
But yeah, thanks Chompy!

Now to get that display heart to work right. >.<
It disappears whenever you go into a different level or whenever the WNPC that sets the player.attr[] for the gani is updated, or sometimes just not at all.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #12  
Old 01-31-2008, 10:08 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Did you use onPlayerEnters like I said?
__________________
Do it with a DON!
Reply With Quote
  #13  
Old 01-31-2008, 10:30 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Yes, I did.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #14  
Old 01-31-2008, 10:47 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Try something like this:

PHP Code:
function onCreated()
  
onPlayerEnters();
function 
onPlayerEnters()
  
functionThatLeadsToCoreScript(); 
Doing that in all my gani scripts.
Reply With Quote
  #15  
Old 01-31-2008, 11:53 PM
zokemon zokemon is offline
That one guy...
zokemon's Avatar
Join Date: Mar 2001
Location: Sonoma County, California
Posts: 2,925
zokemon is a jewel in the roughzokemon is a jewel in the rough
Send a message via ICQ to zokemon Send a message via AIM to zokemon Send a message via MSN to zokemon Send a message via Yahoo to zokemon
Quote:
Originally Posted by Crow View Post
Try something like this:

PHP Code:
function onCreated()
  
onPlayerEnters();
function 
onPlayerEnters()
  
functionThatLeadsToCoreScript(); 
Doing that in all my gani scripts.
Like I said, onCreated is pointless in gani scripts. Just don't use it.
__________________
Do it with a DON!
Reply With Quote
  #16  
Old 02-02-2008, 08:22 AM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Blah, I'm still having trouble with peoples names and display hearts not always showing up and problems with GMAPs.
__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
Reply With Quote
  #17  
Old 02-02-2008, 01:28 PM
Crow Crow is offline
ǝɔɐɹq ʎןɹnɔ
Crow's Avatar
Join Date: Dec 2006
Location: Germany
Posts: 5,153
Crow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond reputeCrow has a reputation beyond repute
Quote:
Originally Posted by zokemon View Post
Like I said, onCreated is pointless in gani scripts. Just don't use it.
That was actually the tiny part that got my gani scripts to work, so I have no idea what you are talking about.
Reply With Quote
  #18  
Old 02-07-2008, 04:40 PM
coreys coreys is offline
N-Pulse Assistant Manager
coreys's Avatar
Join Date: Mar 2005
Posts: 2,180
coreys has a spectacular aura about
Send a message via AIM to coreys Send a message via MSN to coreys Send a message via Yahoo to coreys
Yeah, I've figured that the nick display gani stops showing when you go into the overworld, even if you come back into another level.
This is what I have for that script:
PHP Code:
function onPlayerEnters() {
  
this.nick "";
  
this.guild "";
  
onTimeOut();
}
function 
onTimeOut() {
  if (!
clientr.stealth) {
    if (
this.nick != player.attr[10] || this.guild != player.attr[11])
      
updateNick();
    for (
i=0i<4i++) {
      
changeimgcolors(200+iplayer.attr[17], player.attr[18], player.attr[19], .8);
      
changeimgzoom(200+ithis.size);
    }
    
changeimgcolors(202000.3);
    
changeimgcolors(203000.3);
  }
  else 
hideimgs(200,203);
  if (
this.font != player.attr[21] || this.style != player.attr[22] || this.size != player.attr[23])
    
updateNick();
  
setTimer(0.05);
}
function 
updateNick() {
  
hideimgs(200,203);
  
this.font player.attr[21];
  
this.style player.attr[22];
  
this.size player.attr[23];
  
this.nick player.attr[10];
  
this.guild player.attr[11];
  
temp.this.nick.tokenize("(");
  
temp.width1 gettextwidth(this.sizethis.fontthis.styletemp.n[0])/16;
  
temp.width2 gettextwidth(this.sizethis.fontthis.stylethis.guild)/16;
  
showtext(200player.x+1.5-(temp.width1/2), player.y+3this.fontthis.styletemp.n[0]);
  
showtext(201player.x+1.5-(temp.width2/2), player.y+3.75this.fontthis.stylethis.guild);
  
showtext(202player.x+1.5+(1/8)-(temp.width1/2), player.y+3+(1/8), this.fontthis.styletemp.n[0]);
  
showtext(203player.x+1.5+(1/8)-(temp.width2/2), player.y+3.75+(1/8), this.fontthis.stylethis.guild);
  for (
i=0i<4i++) {
    
changeimgcolors(200+iplayer.attr[17], player.attr[18], player.attr[19], .85);
    
changeimgzoom(200+ithis.size);
    
findImg(200+i).attachtoowner true;
  }
  
changeimgcolors(202000.85);
  
changeimgcolors(203000.85);
  
findImg(200).layer++;
  
findImg(201).layer++;

Also, my heart display keeps turning black at random times, and I can't really figure out why...
PHP Code:
function onCreated() {
  
showimg(200"mal_heartanim.gif", (player.0.5)%64, (player.2)%64);
  
setTimer(0.05);
}
function 
onPlayerEnters() {
  
showimg(200"mal_heartanim.gif", (player.0.5)%64, (player.2)%64);
  
setTimer(0.05);
}
function 
onTimeout() {
  
findimg(200).player.0.5;
  
findimg(200).player.2;

  
temp.healthcheck player.attr[4]*100;

  
findimg(200).player.0.5;
  
findimg(200).player.2;
  if (
temp.healthcheck in |96100|) temp.colors = {0,1};
  else if (
temp.healthcheck in |9195|) temp.colors = {.05,.95};
  else if (
temp.healthcheck in |8690|) temp.colors = {.1,.9};
  else if (
temp.healthcheck in |8185|) temp.colors = {.15,.85};
  else if (
temp.healthcheck in |7680|) temp.colors = {.2,.8};
  else if (
temp.healthcheck in |7175|) temp.colors = {.25,.75};
  else if (
temp.healthcheck in |6670|) temp.colors = {.3,.7};
  else if (
temp.healthcheck in |6165|) temp.colors = {.35,.65};
  else if (
temp.healthcheck in |5660|) temp.colors = {.4,.6};
  else if (
temp.healthcheck in |5155|) temp.colors = {.45,.55};
  else if (
temp.healthcheck in |4650|) temp.colors = {.5,.5};
  else if (
temp.healthcheck in |4145|) temp.colors = {.55,.45};
  else if (
temp.healthcheck in |3640|) temp.colors = {.6,.4};
  else if (
temp.healthcheck in |3135|) temp.colors = {.65,.35};
  else if (
temp.healthcheck in |2630|) temp.colors = {.7,.3};
  else if (
temp.healthcheck in |2125|) temp.colors = {.75,.25};
  else if (
temp.healthcheck in |1620|) temp.colors = {.8,.2};
  else if (
temp.healthcheck in |1115|) temp.colors = {.85,.15};
  else if (
temp.healthcheck in |610|) temp.colors = {.9,.1};
  else if (
temp.healthcheck in |15|) temp.colors = {.95,.05};
  
findImg(200).red temp.colors[0];
  
findImg(200).green temp.colors[1];
  
findImg(200).blue 0;
  
setTimer(0.05);

__________________

Quote:
*SlikRick: so should I even ask about your aim status?
*Xor: well if you want to
*Xor: but i am LARPING
*SlikRick: While on a computer?
*Xor: yes
*Xor: in my living room
*SlikRick: ahh
*Xor: i have a fort setup to hide from beasts
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 12:19 AM.


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