Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-28-2006, 06:47 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Event System

Simple Event system which can be used as a base for a much better system

PHP Code:
/*Open Sourced! Some asks for it - you give it */
function onActionServerSide(cmd) {
  
/* Set Event */
  
if (cmd == "setevent") {
    
EventList();
    
this.ec this.event.index(params[1]);
    if (
this.ec > -1) {
      
serverr.eventname this.event[this.ec];
      
serverr.eventlevel this.event[this.ec+1];
      
serverr.eventx this.event[this.ec+2];
      
serverr.eventy this.event[this.ec+2];
    }
    else {
      
player.chat "Event Not Found"/* Check below in EventList(); */
    
}
  }    
  
/* Set Message */
  
else if (cmd == "setmessage") {
    if (
serverr.eventname != NULL) {
      
serverr.eventmessage params[1];
      for (
pl allplayers) {
        
pl.triggerclient(this.name,"EventSet");
      }
    }
  }
  else if (
cmd == "clear") {
    
serverr.eventname "";
    
serverr.eventlevel "";
    
serverr.eventx     "";
    
serverr.eventy     "";
    
serverr.eventmessage "";
    for (
pl allplayers) {
        
pl.triggerclient(this.name,"Clear");
    }
  }
  else if (
cmd == "warptoevent") {
    
setlevel2(serverr.eventlevel,serverr.eventx,serverr.eventy);
  }       
}

function 
EventList() {
  
//Eventname,level,x,y
  
this.event = {
    
"Event Name","Event level",x,y,
    
"Event 2 Name","Event 2 level",x,y,
  };
}



//#CLIENTSIDE
function onActionClientSide() {
  if (
params[0] == "EventSet") {
    
setevent();
  }
  else if (
params[0] == "Clear") {
    
hideimg(201);
    
ebutton.hide();
  }
}

function 
onPlayerchats() {
if (
player.guild == "Events Team") {
  if (
player.chat.starts("/setevent")) {
    
triggerserver("gui",this.name,"setevent",player.chat.substring(10,-1));
  }
  else if (
player.chat.starts("/message")) {
    
triggerserver("gui",this.name,"setmessage",player.chat.substring(9,-1));
  }
  else if (
player.chat.starts("/clear")) {
    
triggerserver("gui",this.name,"clear");
  } }   
}

function 
onCreated(){
  new 
GuiButtonCtrl(ebutton) {
    
profile "GuiBlueButtonProfile";
    
x       screenwidth 100;
    
y       screenheight 50;
    
extent  "100 50";
    
text    "Play Event";
    
visible false;
  }  
}

function 
setevent() {
  
ebutton.show();
  
showText20110screenheight-40"Verdana""b"serverr.eventname@": " serverr.eventmessage).layer=4;
}

function 
ebutton.onAction() {
  
triggerserver("gui",this.name,"warptoevent");

Figured I'd keep the levels within the script. Could use a class or a DBNPC to contain the levels...would be much more sexier if you used a DBNPC....

Last edited by Twinny; 09-28-2006 at 02:55 PM..
Reply With Quote
  #2  
Old 09-28-2006, 08:41 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
player.chat.substring(10)
doesn't substring require two params? :O
I've never seen it accept one
__________________
Reply With Quote
  #3  
Old 09-28-2006, 08:54 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Didn't even see that yet i think it works anyways?
Reply With Quote
  #4  
Old 09-28-2006, 02:29 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
substring(start, length)
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #5  
Old 09-28-2006, 02:54 PM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Even though it works fine i'll change it just for you guys -_-
Reply With Quote
  #6  
Old 09-28-2006, 05:23 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by Twinny View Post
Even though it works fine i'll change it just for you guys -_-
Why bother? It was fine before.
Reply With Quote
  #7  
Old 09-28-2006, 05:25 PM
projectigi projectigi is offline
Registered User
Join Date: Jan 2004
Posts: 403
projectigi is an unknown quantity at this point
PHP Code:
obj.substring(index[,length]) 
the length parameter is optional =/ atleast the wiki says so
Reply With Quote
  #8  
Old 09-28-2006, 06:28 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Could someone explain why only 1 param is needed? Would leaving it as blank / not there mean untill it ends?
__________________
Reply With Quote
  #9  
Old 09-28-2006, 09:26 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
Quote:
Originally Posted by xAndrewx View Post
Could someone explain why only 1 param is needed? Would leaving it as blank / not there mean untill it ends?
Yes.
PHP Code:
temp.foo "Bar";
echo(
temp.foo.substring(1)); 
produces "ar".
Reply With Quote
  #10  
Old 09-28-2006, 09:28 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
Quote:
Originally Posted by Skyld View Post
Yes.
PHP Code:
temp.foo "Bar";
echo(
temp.foo.substring(1)); 
produces "ar".
Yay, now learn to respond to my MSN! xx
__________________
Reply With Quote
  #11  
Old 09-28-2006, 10:11 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
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
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by projectigi View Post
PHP Code:
obj.substring(index[,length]) 
the length parameter is optional =/ atleast the wiki says so
:o
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #12  
Old 02-24-2008, 07:10 AM
CountBleck CountBleck is offline
Twilight Town Owner
Join Date: Feb 2008
Posts: 11
CountBleck is an unknown quantity at this point
This doesnt work.. When I say /warptoevent theres nothing and noone ever gets the popup for the event.
Reply With Quote
  #13  
Old 02-24-2008, 09:59 AM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
There's only three commands, each one needing an "Events Team" tag. Here are those three commands:

/clear
/setevent [event name]
/message [message]
__________________
Reply With Quote
  #14  
Old 02-24-2008, 05:37 PM
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
Side note:
PHP Code:
  this.event = {
    
"Event Name","Event level",x,y,
    
"Event 2 Name","Event 2 level",x,y,
  }; 
Why not use multi-dimensional arrays?

On Utopia, we are doing:

PHP Code:
  this.events = {
                  { 
"Auction""utopia_events_auction.nw"33.540"utopia_money.png" },
                  { 
"Chance""utopia_events_chance.nw"817"utopia_ec.gif" },
                  { 
"LMS""utopia_events_lms.nw"307"ut_icon-57.gif" },
                  { 
"Laser Tag""utopia_events_lt-lobby.nw"3219"utopia_igun-icon.png" },
                  { 
"Lucky Prize""utopia_events_luckyprize.nw"27.526.5"utopia_ec.gif" },
                  { 
"Ring""utopia_events_ring.nw"3424"utopia_igun-icon.png" },
                  { 
"Spar Tourney""utopia_events_spararena.nw"3121.9"ut_icon-57.gif" },
                  { 
"Tag Team Spar""utopia_events_tagteam.nw"32.321.2"utopia_weapon-Chaingun-icon.gif" },
                  { 
"Gravity Race""utopia_event-gravity.nw"5.856"utopia_empty.png" },
                  { 
"Trick Race""utopia_events_trickrace.nw"1222"utopia_staffblock.gif" },
                  { 
"Quiz""utopia_events_quiz.nw"4024.5"block.png" }
                }; 
Multi-dimensional arrays ftw

I should probably release Utopia's event system ... it's fairly more complex. Probably harder to install. Easier to use, I would imagine.

I will talk to Ork...
__________________
Reply With Quote
  #15  
Old 02-24-2008, 07:32 PM
CountBleck CountBleck is offline
Twilight Town Owner
Join Date: Feb 2008
Posts: 11
CountBleck is an unknown quantity at this point
Quote:
Originally Posted by xAndrewx View Post
There's only three commands, each one needing an "Events Team" tag. Here are those three commands:

/clear
/setevent [event name]
/message [message]

So how are people meant to get the the event?
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 06:00 PM.


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