Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > New Scripting Engine (GS2)
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-04-2008, 12:16 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
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.
Reply With Quote
  #2  
Old 12-04-2008, 12:41 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
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.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #3  
Old 12-04-2008, 01:26 PM
Programmer Programmer is offline
Coder
Programmer's Avatar
Join Date: Jan 2008
Location: -78.464422, 106.837328
Posts: 449
Programmer has a spectacular aura aboutProgrammer has a spectacular aura about
Send a message via AIM to Programmer Send a message via MSN to Programmer Send a message via Yahoo to Programmer
Quote:
Originally Posted by Pelikano View Post
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...");

__________________
- Iᴀɴ Zɪᴍᴍᴇʀᴍᴀɴ
Reply With Quote
  #4  
Old 12-04-2008, 05:58 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
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.
__________________
Reply With Quote
  #5  
Old 12-04-2008, 11:46 PM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
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).
Reply With Quote
  #6  
Old 12-05-2008, 05:17 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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");

__________________
Reply With Quote
  #7  
Old 12-06-2008, 11:59 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Thanks

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".
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:36 PM.


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