Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Gani Solutions! (https://forums.graalonline.com/forums/showthread.php?t=72413)

xXziroXx 02-23-2007 07:21 PM

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.

Chompy 02-23-2007 07:38 PM

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 :D

xXziroXx 02-23-2007 07:39 PM

Quote:

Originally Posted by Chompy (Post 1281316)
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.

Chandler 02-23-2007 08:06 PM

I was about to make a thread about making player.attr support arrays!
I suppose this will do though, thank you! :)

xXziroXx 07-20-2007 07:07 AM

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. :)

PrinceOfKenshin 07-20-2007 07:26 AM

very nice can you explain to me how to make a gani script im not good at it


All times are GMT +2. The time now is 04:05 PM.

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