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
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
substring(start, length)
__________________
Follow my work on social media post-Graal:Updated august 2025.
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
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
Quote:
Originally Posted by projectigi View Post
PHP Code:
obj.substring(index[,length]) 
the length parameter is optional =/ atleast the wiki says so
:o
__________________
Follow my work on social media post-Graal:Updated august 2025.
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
  #16  
Old 02-24-2008, 08:09 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
once you've set the event, set a message and it'll inform all the people with that weapon that an event is about to begin.
__________________
Reply With Quote
  #17  
Old 02-24-2008, 10:09 PM
Switch Switch is offline
o.o
Switch's Avatar
Join Date: Jan 2007
Location: Philadelphia
Posts: 3,038
Switch has a spectacular aura about
Send a message via MSN to Switch
Quote:
Originally Posted by CountBleck View Post
This doesnt work.. When I say /warptoevent theres nothing and noone ever gets the popup for the event.
Quote:
Originally Posted by CountBleck View Post
So how are people meant to get the the event?
I'm sorry, but all I can say to you is that you're a clueless leecher.

I just needed to say that.
__________________
Oh squiggly line in my eye fluid. I see you lurking there on the peripheral of my vision.
But when I try to look at you, you scurry away.
Are you shy, squiggly line?
Why only when I ignore you, do you return to the center of my eye?
Oh, squiggly line, it's alright, you are forgiven.
Reply With Quote
  #18  
Old 02-24-2008, 10:24 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
Quote:
Originally Posted by cbkbud View Post
Why not use multi-dimensional arrays?
Probably because I didn't understand the concept of MD arrays back then. There are alot of scripts I should probably redo but I have not the effort.
Reply With Quote
  #19  
Old 02-24-2008, 10:30 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
Quote:
Originally Posted by Twinny View Post
Probably because I didn't understand the concept of MD arrays back then. There are alot of scripts I should probably redo but I have not the effort.
Fair enough.

I use to remember doing things like

PHP Code:
this.eventNames = { "lol""foo""bar" };
this.eventLevels = { "event_poo.nw""rawr.nw""onlinestartlocal.graal" };
this.eventX = { 301040 };
this.eventY = { 222435 }; 
which actually makes yours look organized
__________________
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 12:39 PM.


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