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 02-23-2007, 07:21 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Gani Solutions!

Ive come up to a solution to all the resent gani problems, mainly that a gani is not able to read data from other players. I'll refer to the HUD gani I made on Mythic (most parts of it have been removed though).


This is a non-working example of it:

PHP Code:
player.attr[20] = "ml_hud.gani"
PHP Code:
function onPlayerEnters() setTimer(.05);

function 
onTimeOut()

  if (
mousex in |player..5player.2.5| && mousey in |player.1player.3|) {
    
hideimgs(300309);
    
ShowHUD();
    for (
04++) changeimgzoom(300 i.7);
  }

  
setTimer(.05);
}

function 
ShowHUD()
{
  
showimg(304"ml_gui-hphud.png"player.1.5 getimgwidth("ml_gui-hphud.png")/16/2player.1.5 - (19/16)/2);
  
showimg(305"ml_gui-hphud.png"player.1.5 getimgwidth("ml_gui-hphud.png")/16/6/16player.1.5 - (19/16)/4/16);

  
changeimgpart(304003713);
  
changeimgpart(30501424/(player.fullhearts/player.hearts) + 15);

  
changeimgvis(3053);

This example will not work since apparently, player.fullhearts is not readable for other players along with several other things. So with this, you will only be able to see your own health bar.

However, you can easily create an array-like player.attr and store the data in that.

PHP Code:
player.attr[20] = "ml_hud.gani";
player.attr[21] = @{player.heartsplayer.fullhearts}; 
PHP Code:
function onPlayerEnters() setTimer(.05);

function 
onTimeOut()

  if (
mousex in |player..5player.2.5| && mousey in |player.1player.3|) {
    
hideimgs(300309);
    
ShowHUD();
    for (
04++) changeimgzoom(300 i.7);
  }

  
setTimer(.05);
}

function 
ShowHUD()
{
  
showimg(304"ml_gui-hphud.png"player.1.5 getimgwidth("ml_gui-hphud.png")/16/2player.1.5 - (19/16)/2);
  
showimg(305"ml_gui-hphud.png"player.1.5 getimgwidth("ml_gui-hphud.png")/16/6/16player.1.5 - (19/16)/4/16);

  
changeimgpart(304003713);
  
changeimgpart(30501424/(player.attr[21].tokenize()[1]/player.attr[21].tokenize()[0]) + 15);

  
changeimgvis(3053);

This example, will work. Not only for the current player, you will be able to see other player's health bars as well. Remember that you have to update player.attr[21] every time that the player's HP changes, possibly in a timeout.


NOTE: Whenever you use onCreated() in a gani, it will only be triggered the FIRST time the gani is shown. If you do onPlayerEnters(), it will be triggered every time you enter a level AND when you update the script of the gani.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #2  
Old 02-23-2007, 07: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
hmm, would this work if the player.attr[21] were the same?
I need some help with my flaot text and I gotta test this method
__________________
Reply With Quote
  #3  
Old 02-23-2007, 07:39 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Chompy View Post
hmm, would this work if the player.attr[21] were the same?
I need some help with my flaot text and I gotta test this method :]
Yes, it would.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #4  
Old 02-23-2007, 08:06 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
I was about to make a thread about making player.attr support arrays!
I suppose this will do though, thank you!
Reply With Quote
  #5  
Old 07-20-2007, 07:07 AM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
ADD: I ran into this problem again, and I think that I should tell everyone what the REALLY IMPORTANT part is that WILL make it function properly.


Example 1 (non working):

PHP Code:
player.attr[21] = @{ "foo""bar" };
player.attr[22] = "yourganiname.gani"
PHP Code:
SCRIPT
function onPlayerEnters() setTimer(.05);

function 
onTimeOut()
{
  
player.chat "[" player.attr[21][0] @ "]";
  
setTimer(.05);
}
SCRIPTEND 
This will set your chat to: [foo]

However, if you try to change player.attr[21] to something else (atleast serversided, didnt try to do it on clientside) - your chat will not update. I guess this is because attr is not supposed to be used as an array, but, it WILL work if you tokenize the attr array.


Example 2 (working):

PHP Code:
player.attr[21] = @{ "foo2""bar2" }; 
PHP Code:
SCRIPT
function onPlayerEnters() setTimer(.05);

function 
onTimeOut()
{
  
player.chat "[" player.attr[21].tokenize()[0] @ "]";
  
setTimer(.05);
}
SCRIPTEND 

I hope this will be of more help.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #6  
Old 07-20-2007, 07:26 AM
PrinceOfKenshin PrinceOfKenshin is offline
That guy with a beard
PrinceOfKenshin's Avatar
Join Date: May 2004
Location: Ontario, Canada
Posts: 819
PrinceOfKenshin has a spectacular aura aboutPrinceOfKenshin has a spectacular aura about
very nice can you explain to me how to make a gani script im not good at it
__________________


Quote:
Game Master (Server): Greetings PrinceOfKenshin, there are new posts on the forums that demand your urgent attention! God speed, the fate of the world is in your hands. If you fail, middle earth will forever be in the darkness and your children will be enslaved by McKain.
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 06:49 PM.


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