Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   Scheduleevent/trigger class (https://forums.graalonline.com/forums/showthread.php?t=83003)

Pelikano 12-04-2008 12:16 PM

Scheduleevent/trigger class
 
I've got two small questions:

1) Can I start a scheduleevent Clientside and run it Serverside?
Example:

PHP Code:

function onTest() {
// blabla
}
//#CLIENTSIDE
function onCreated() {
scheduleevent(5,"Test","");


2) How do I trigger a class?
I know about: "triggerserver("gui",this.name,blabla);
But how do I trigger a class using triggerserver? "class" instead of "gui" doesn't seem to work.

xXziroXx 12-04-2008 12:41 PM

1) No.

2) Errr? I don't think you know how classes work. When a script is joined to a class, that class becomes a part of that script.

Programmer 12-04-2008 01:26 PM

Quote:

Originally Posted by Pelikano (Post 1446636)
I've got two small questions:

1) Can I start a scheduleevent Clientside and run it Serverside?

2) How do I trigger a class?
I know about: "triggerserver("gui",this.name,blabla);
But how do I trigger a class using triggerserver? "class" instead of "gui" doesn't seem to work.

1.) This is an impossibility as of yet.

2.) You don't "trigger" a class in the traditional sense, you must first join the class to the script so you can trigger it. This is how classes work, by the way:

PHP Code:

// Class "dothis-test"
//#CLIENTSIDE
function onDoThis()
{
    echo(
"Doing this...");
}

// Weapon
//#CLIENTSIDE
function onCreated()
{
    
this.join("dothis-test");
    
scheduleEvent(5"DoThis"null); 


What the join method does is merge the class into the script, so the actual code viewed by the interpreter is this:

PHP Code:

// Weapon
//#CLIENTSIDE
function onCreated()
{
    
scheduleEvent(5"DoThis"null); 
}

function 
onDoThis()
{
    echo(
"Doing this...");



Inverness 12-04-2008 05:58 PM

Classes are like code that is copy-pasted into an object when you join the class to it. Though the OnCreated() in a class is run at the time it is joined to an object.

WhiteDragon 12-04-2008 11:46 PM

Yeah, as aforementioned, a class doesn't actually exist.

Strictly speaking, a class is just flat text.

Either you join the class to a weapon, or to an npc.

Then, you can either trigger the weapon (with triggerserver) or the npc (with triggeraction and the coordinates of the npc).

cbk1994 12-05-2008 05:17 AM

For #1, try something like this:

PHP Code:

function onActionServerSide(cmd) {
  if (
cmd == "meep") {
    
// destroy the planet
  
}
}
//#CLIENTSIDE
function onCreated() {
  
scheduleevent(5"Something""");
}
function 
onSomething() {
  
triggerserver("gui"name"meep");



Pelikano 12-06-2008 11:59 AM

Thanks :D

Now I know what classes are.
Well, I was just a little confused because of "putnpc2()", but now I know that putnpc2 creates an empty NPC where you put in a "class".


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

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