Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   showing GUI for all players (https://forums.graalonline.com/forums/showthread.php?t=75560)

Cherrykao 07-16-2007 06:59 AM

showing GUI for all players
 
according to my understanding, GUI's are clientside. i've been scratching my head for a while on how I could show a specific GUI for all players no matter where they are on the server.

In a specific level, a staff player chats "/commands" to bring up a GUI which has buttons with commands. On one of the buttons, he can click on it and it should show a GUI at the upper right hand corner of the screen for everyone on the server. This new GUI which appears has a button that allows players to click on it to warp into the room. This is like an event warper.

I have the actual code in a CLASS and the CLASS is attached to an NPC in a level using the "join" function: join staffcommand;

The script is around 500-700 lines of codes, so I don't think i'll post the code here. I'm just curious on how to get the GUI to show for everyone on the server if this is possible.

DustyPorViva 07-16-2007 07:05 AM

What you would do, is triggerserver in the weapon(this is for the person starting the warp thing), and then triggerclient all the players to display the GUI.

Cherrykao 07-16-2007 07:26 AM

can you show an example? i tried it before, but couldn't get it to work:

PHP Code:

function onActionServerside() {
  
player.triggerclient("Clientside",this.name,NULL);
}


//#CLIENTSIDE
function onPlayerChats() {
  if (
player.chat == "/commands") {
    
triggerserver("Serverside"this.name,NULL);
  }
}

function 
onActionClientside() {
  new 
GuiDrawingPanel("dp_eventgui") {
    
width 320;
    
height 64;
    
= ((screenwidth width) - 10);
    
10;
    
clearall();
    
drawimage(0,0,"imagegui.png");
    
canMove false;
    
canResize 0;
    
visible 1;
    
canClose 1;
    
canMaximize 0;
    
canMinimize 0;
    
    new 
GuiBitmapButtonCtrl("bmpbtn_joinevent") {
      
width 30;
      
height 30;
      
260;
      
21;
      
normalbitmap "button.png";
      
mouseoverbitmap "button1.png";
      
pressedbitmap "button.png";
    }
  } 
// gui end



DustyPorViva 07-16-2007 07:34 AM

I don't know GS2 well enough, and I don't remember much about serverside.
But it'd be something like:
PHP Code:

for (i:playerscount) {
  
with(player.i).triggerclient("Clientside",this.name,NULL); 


Or something like that, I think I just butchered it, but I'm sure you get the idea. That, or wait for someone who knows to show up :(

xXziroXx 07-16-2007 07:41 AM

Nice try Dusty, but I recommend going with this instead:

PHP Code:

function onActionServerside() {
  for (
plallplayerspl.triggerClient("gui"name"");


:D

EDIT: Make sure all players actually have the wNPC!

Gambet 07-16-2007 07:52 AM

Quote:

Originally Posted by xXziroXx (Post 1331125)
Nice try Dusty, but I recommend going with this instead:

PHP Code:

function onActionServerside() {
  for (
plallplayerspl.triggerClient("gui"name"");


:D

EDIT: Make sure all players actually have the wNPC!



You don't need the "gui" while using triggerclient, or at least I've never used it and don't know if it makes a difference or not.

I've always done:

PHP Code:

player.triggerclient(name,params[0],params[1],etc...); 


Cherrykao 07-16-2007 07:54 AM

the thing is that this isn't a weapon. it's an NPC script attached to an actual NPC in a level, so i still can't get this to work.

Gambet 07-16-2007 07:55 AM

Quote:

Originally Posted by Cherrykao (Post 1331131)
the thing is that this isn't a weapon. it's an NPC script attached to an actual NPC in a level, so i still can't get this to work.


You can't triggerclient in level NPCs, you'd have to use attr[]'s to communicate from server to client.

Cherrykao 07-16-2007 08:04 AM

can you post a simple example for me to work on?

Gambet 07-16-2007 08:10 AM

Quote:

Originally Posted by Cherrykao (Post 1331138)
can you post a simple example for me to work on?



Just assign attr[] variables on the server. In the brackets, you put a number. attr[1] is automatically pre-defined for the player's hat, so you won't be able to use that. I believe attr[]'s go up to 30 or so. You can just do something like

PHP Code:

attr[10] = "Test"


on the serverside, and you'll be able to read attr[10] on the clientside.

Cherrykao 07-16-2007 10:11 PM

just curious if it is it possible to attach a class to every single level in a server through a script or do i have to manually edit every single level and attach "join class"; to an NPC??

DustyPorViva 07-16-2007 10:24 PM

Why not just make it a WNPC in that case?

bscharff 07-17-2007 03:15 AM

//ActionServerSide Stuff
for (i=0;i<allplayerscount;i++) {
with (allplayers[i]){
//Insert The GUI Code Here
}}
//ClientSide Stuff

killerogue 07-17-2007 03:29 AM

Did anyone notice he used triggerserver wrong? O.o


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

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