Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Events that work in ganiscript? (https://forums.graalonline.com/forums/showthread.php?t=134262905)

Mark Sir Link 04-20-2011 11:37 AM

Events that work in ganiscript?
 
working on a custom nickname system, it appears that neither onPlayerNickChanges
or
onNickChanges

are invoked in the gani.


PHP Code:

function onPlayerEnters(){
  
with(findimg(200)){
    
player.1.5;
    
player.3;
    
attachtoowner true;
    
temp.shared.getAlignmentColor(player.ap);
    
/*red = c[0]/255;
    green = c[1]/255;
    blue = c[2]/255;*/
    
red 83;
    
green 46;
    
blue 86;
    
textshadow true;
    
//temp.c = shared.getAlignmentShadowColor()
    //shadowcolor = {c[0]/255, c[1]/255, c[2]/255};
    
text player.nick;
    
font $pref::graal::defaultfontname;
    
style "bc";
    
zoom $pref::graal::defaultfontsize 24;
    
layer 0;
  }
}

function 
onPlayerNickChanges(){
  
with(findimg(200)){
    
text player.nick;
  }



cbk1994 04-20-2011 11:41 AM

I think those are serverside only.

Mark Sir Link 04-20-2011 11:48 AM

trying something like
PHP Code:

function onPlayerChats(){
  if(
player.chat.starts("setnick")){
    
with(findimg(200)){
      
text player.nick;
    }
  }


also doesn't work

I'd hate to have to do something like unset the player.attr and then reset it after a timeout or something, but it looks like I may have to

Mark Sir Link 04-20-2011 12:11 PM

ended up duplicating the gani and am changing the attr to the 2nd gani when onPlayerNickChanges is invoked on the serverside, resetting back to original after a .1 sec scheduleevent

guess I'll have to shove a timeout into the ani itself to deal with AP, checking once every 10 or so seconds seems reasonable

cbk1994 04-20-2011 12:12 PM

Maybe try using onPlayerChanges(pl)? I doubt it will work inside a GANI script, though.

ffcmike 04-20-2011 12:22 PM

I can imagine nickname displaying having several complications if done through gani script, even if there was an event for nick changing within gani scripts you still ought to have a way to add the text "(Paused)" assuming you want to replicate default.
And what about when AP changes?

You may want nicknames to be hidden at certain times which would likely require the use of a timeout to check for them being enabled, which is something you'd want to be checking one time within a weapon rather than for every single player in a gani script.

Edit: you mentioned this just before I posted.

If there were other gani scripts active that were modifying player red, green, blue, zoom etc would these not also be applied to nickname display if it were within a gani script?

MrOmega 04-20-2011 01:14 PM

The method I use is setting the nick to an attr and check to see if they don't equal each other. I use another attr for my custom pause system.. Suppose you could do the same for AP

Mark Sir Link 04-20-2011 06:11 PM

Quote:

Originally Posted by ffcmike (Post 1644567)
I can imagine nickname displaying having several complications if done through gani script, even if there was an event for nick changing within gani scripts you still ought to have a way to add the text "(Paused)" assuming you want to replicate default.
And what about when AP changes?

You may want nicknames to be hidden at certain times which would likely require the use of a timeout to check for them being enabled, which is something you'd want to be checking one time within a weapon rather than for every single player in a gani script.

Edit: you mentioned this just before I posted.

If there were other gani scripts active that were modifying player red, green, blue, zoom etc would these not also be applied to nickname display if it were within a gani script?

For pausing, I assume I can just use a keydown to check for the pause button, then if that occurs, check ispaused, swap to the duped gani for a moment and just append (paused), then revert back to the other.

You're right about the hiding nicks though, as far as I'm aware there is still no inherent method of getting the player object who is viewing the gani, so I guess I'll have to use a weapon for this instead.

Crow 04-20-2011 06:19 PM

Quote:

Originally Posted by Mark Sir Link (Post 1644592)
You're right about the hiding nicks though, as far as I'm aware there is still no inherent method of getting the player object who is viewing the gani, so I guess I'll have to use a weapon for this instead.

If you use a client.var in a gani script, it'll always use the one of the player viewing the gani.

Mark Sir Link 04-20-2011 06:20 PM

Quote:

Originally Posted by Crow (Post 1644597)
If you use a client.var in a gani script, it'll always use the one of the player viewing the gani.

should I just reference the client var without providing the object?

PHP Code:

if(client.viewnicks

EDIT: tested that with another player, appears to be working as intended

I guess the issues I need to figure out still are how to update nick names being toggled off instantly rather than having to sit and wait for a slow timeout I plan to use for AP.

EDIT 2: apparently keydown(10) only returns true while unpausing, and will not return true while starting a pause. Only solution I can think of is using GraalControl.onKeyDown and checking if keyname == 2nd param.

Crow 04-20-2011 07:11 PM

Quote:

Originally Posted by Mark Sir Link (Post 1644598)
EDIT: tested that with another player, appears to be working as intended

Glad it does ^^

xAndrewx 04-20-2011 08:13 PM

Quote:

Originally Posted by Mark Sir Link (Post 1644598)
should I just reference the client var without providing the object?

PHP Code:

if(client.viewnicks

EDIT: tested that with another player, appears to be working as intended

I guess the issues I need to figure out still are how to update nick names being toggled off instantly rather than having to sit and wait for a slow timeout I plan to use for AP.

EDIT 2: apparently keydown(10) only returns true while unpausing, and will not return true while starting a pause. Only solution I can think of is using GraalControl.onKeyDown and checking if keyname == 2nd param.

Pausing is weird, disable default and re-make your own.

Crow 04-20-2011 09:08 PM

Quote:

Originally Posted by xAndrewx (Post 1644612)
Pausing is weird, disable default and re-make your own.

How'd you make the player invincible? ^_^

Mark Sir Link 04-20-2011 10:44 PM

Quote:

Originally Posted by xAndrewx (Post 1644612)
Pausing is weird, disable default and re-make your own.

I think my solution is just fine really. I don't really want it to show (paused) when players alt tab since it doesn't make them invincible/able to be walked through

PHP Code:

function GraalControl.onKeyDown(cks){
  if(
keyname(10) == k){
    if(
player.paused){ 
      
player.attr[14] = " (paused)";
    }
    else{
      
player.attr[14] = "";
    }
    
player.attr[13] = "un_nick2.gani";
    
setTimer(.05);
  }


I just wish an event was invoked when AP changes at this point...

Crow 04-21-2011 06:51 PM

That's some really hackish stuff you got there.


All times are GMT +2. The time now is 08:46 PM.

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