Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Finimg, showimg, hideimg index? (https://forums.graalonline.com/forums/showthread.php?t=134264158)

Adddeeee 08-10-2011 12:13 AM

Finimg, showimg, hideimg index?
 
Hi!

Thinking of creating a health system. I searched the forum and have come to the conclusion that I need to use findimg(), hideimg() and showimg().

When using either I need to specify an index. I need to know the index of the "heart" images in order to hide them and display any other images instead.

Where do I find all the indexes of the default images drawn on the screen?

And does it matter what index I put to my own "hearts" images?

Thank you :)

Twinny 08-10-2011 12:23 AM

Thats handled by something different. You can find how to modify those graphics via http://wiki.graal.net/index.php/Showstats

Adddeeee 08-10-2011 12:43 AM

Ahaaa...thought that was for hiding the hearts shown over the players head when hit.

But what if I want to add new images? Can I choose whaterver index I want to? Doesn't it exist any list with restricted indexes?

Twinny 08-10-2011 12:50 AM

Indexes up to 200 can be seen by all players. Starting with 201+, only the local player will see the images. Just remember to use layer 4 so they draw to GUI layer rather than tile layer.

What happens with an image under 201 but on layer 4? I'm not rightly sure :confused:

Adddeeee 08-10-2011 12:52 AM

Okay :) Where do I deside the layer no. ?

Thanks!

WhiteDragon 08-10-2011 12:57 AM

This is the documentation for findimg:

TServerNPC.findimg(int) - returns object

It, more specifically, returns a TShowImg, which is a type of object.



Let's see what we can do with TShowImgs... type /scripthelp TShowImg in RC.

A bunch of stuff should pop up, including something like...

TShowImg.layer - integer

This is what we want.



So to actually use this information:

PHP Code:

temp.findimg(201);
temp.i.layer 4


Adddeeee 08-10-2011 01:02 AM

Thank you :) Feeling kind of dumb now when you just find all that info in such a short time! Still struggling to get used to the detective work that has to be done!

But I'm getting there! Thank you all ! :)

WhiteDragon 08-10-2011 01:12 AM

No problem. Much of GS2 mastery is gaining familiarity with all the functions and quirks of the language. /scripthelp goes a long way but hardly the whole way. The various wikis (http://wiki.graal.net and http://wiki.graal.us) are also useful.

Adddeeee 08-11-2011 02:00 PM

Thank you for your replies earlier :)

I managed to get my own images shown instead of the default hearts. Although, we've decided to use a health bar instead of just images.

But I'm not really a fan of the onTimeout function used. Feels like it could be done without a timer running constantly?

Isn't there any event that handels onPlayerHurt or do I need to write such an event by myself?

Here's the code we use:

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiControlProfile("TextProfile"
  {
    
fontcolor "0 0 0";
    
fonttype "Arial";
    
fontsize 25;
    
fontstyle "b";
  }
    
  new 
GuiProgressCtrl("HealthControl_Bar"
  {
    
profile GuiBlueProgressProfile;
    
width 360;
    
height 40;
    
screenwidth width 20;
    
10;
    
progress player.hearts/player.fullhearts;
    
    new 
GuiTextCtrl("HealthConrol_Text"
    {
      
profile TextProfile;
      
HealthControl_Bar.width this.width 2;
      
10;
      
height 20;
      
width 80;
      
text player.hearts SPC "/" SPC player.fullhearts;
    } 
  }
  
  
onTimeout();
}

function 
onTimeout()
{
  
HealthControl_Bar player.hearts/player.fullhearts;
  
HealthControl_Text.text player.hearts SPC "/" SPC player.fullhearts;
  
setTimer(0.5);



Mark Sir Link 08-11-2011 02:11 PM

ya, it's onPlayerHurt

Adddeeee 08-11-2011 02:25 PM

Ah thank you :)

This may be a little OT, but do you know where to find a list of all the default events? And even more OT, do you know where to find a list of the default client flags?

Thank you!

fowlplay4 08-11-2011 03:41 PM

1 Attachment(s)
You can find a list of events in commands.rtf (GS1, just convert them to GS2), found in your Graal folder provided you installed the level editor.

Search: playerhurt

You can find player flags in scriptfunctions_client.txt, generated by Graal.exe when you start it with the -listscriptfunctions parameter. Attached it for you anyway.

Search: TServerPlayer

Fulg0reSama 08-11-2011 03:45 PM

Quote:

Originally Posted by Adddeeee (Post 1663032)
Ah thank you :)

This may be a little OT, but do you know where to find a list of all the default events? And even more OT, do you know where to find a list of the default client flags?

Thank you!

http://gscript.graal.net/Index

fowlplay4 08-11-2011 05:06 PM

Quote:

Originally Posted by Adddeeee (Post 1663041)
Unable to find the onPlayerHurt in the events category. It doesn't exist any after all? Also, I can't seem to find any default client flags. Or aybe there are no default client flags available?

The documentation just isn't complete.

Edit: I guess you found the client flags.

callimuc 08-11-2011 08:22 PM

Quote:

Originally Posted by fowlplay4 (Post 1663036)
You can find a list of events in commands.rtf (GS1, just convert them to GS2), found in your Graal folder provided you installed the level editor.

Search: playerhurt

You can find player flags in scriptfunctions_client.txt, generated by Graal.exe when you start it with the -listscriptfunctions parameter. Attached it for you anyway.

Search: TServerPlayer

I think this is also very helpful for commands. I don“t know if it includes events but I think it got the basic stuff which would be important ;)

New GS2 commands.rtf

Adddeeee 08-11-2011 08:32 PM

Thank you! That updated commands.rtf helped a lot :)

Mark Sir Link 08-11-2011 08:43 PM

function onPlayerHurt definitely invokes on the clientside if you were still having issues with it.

However, you will need to rescript how healing works on your server (namely detecting if a player is in a bed and changing the heart drop items? rescript pots?) so that it would throw an event or trigger the health display to update as well if you don't want to use a timeout

Adddeeee 08-11-2011 08:54 PM

Hm...it works part time.

The player.chat works, but the GUI doesn't update.

PHP Code:

//#CLIENTSIDE
function onCreated()
{
  new 
GuiControlProfile(ATextProfile
  {
    
fontcolor "0 0 0";
    
fonttype "Arial";
    
fontsize 25;
    
fontstyle "b";
  }
    
  new 
GuiProgressCtrl("HealthControl_Bar"
  {
    
profile GuiBlueProgressProfile;
    
width 360;
    
height 40;
    
screenwidth width 20;
    
10;
    
progress player.hearts/player.fullhearts;
    
    new 
GuiTextCtrl("HealthConrol_Text"
    {
      
profile ATextProfile;
      
HealthControl_Bar.width this.width 2;
      
10;
      
height 20;
      
width 80;
      
text player.hearts SPC "/" SPC player.fullhearts;
    } 
  }
}

function 
onPlayerHurt()
{
  
player.chat "HURT";
  
HealthControl_Bar player.hearts/player.fullhearts;
  
HealthControl_Text.text player.hearts SPC "/" SPC player.fullhearts;



fowlplay4 08-11-2011 09:21 PM

I would recommend checking the names in your GUI.

Particularly: new GuiTextCtrl("HealthConrol_Text")

xXziroXx 08-12-2011 12:49 PM

You seem to have missed something.

Change

PHP Code:

HealthControl_Bar player.hearts/player.fullhearts

into

PHP Code:

HealthControl_Bar.progress player.hearts/player.fullhearts

in your onPlayerHurt() function.

Mark Sir Link 08-12-2011 08:40 PM

Quote:

Originally Posted by xXziroXx (Post 1663216)
You seem to have missed something.

Change

PHP Code:

HealthControl_Bar player.hearts/player.fullhearts

into

PHP Code:

HealthControl_Bar.progress player.hearts/player.fullhearts

in your onPlayerHurt() function.

yep

Adddeeee 08-12-2011 09:01 PM

Oh my, isn't that clumsy!

Should've double checked those things before I posted. Really sorry for taking up your time with spelling errors :S

Thank you though, it works now :)


All times are GMT +2. The time now is 09:32 AM.

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