Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Event System (https://forums.graalonline.com/forums/showthread.php?t=69020)

Twinny 09-28-2006 06:47 AM

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();
  
showText( 201, 10, screenheight-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....

xAndrewx 09-28-2006 08:41 AM

player.chat.substring(10)
doesn't substring require two params? :O
I've never seen it accept one :D

Twinny 09-28-2006 08:54 AM

Didn't even see that >_< yet i think it works anyways? x_x

xXziroXx 09-28-2006 02:29 PM

substring(start, length)

Twinny 09-28-2006 02:54 PM

Even though it works fine i'll change it just for you guys -_-

Skyld 09-28-2006 05:23 PM

Quote:

Originally Posted by Twinny (Post 1223249)
Even though it works fine i'll change it just for you guys -_-

Why bother? It was fine before.

projectigi 09-28-2006 05:25 PM

PHP Code:

obj.substring(index[,length]) 

the length parameter is optional =/ atleast the wiki says so

xAndrewx 09-28-2006 06:28 PM

Could someone explain why only 1 param is needed? Would leaving it as blank / not there mean untill it ends?

Skyld 09-28-2006 09:26 PM

Quote:

Originally Posted by xAndrewx (Post 1223293)
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".

xAndrewx 09-28-2006 09:28 PM

Quote:

Originally Posted by Skyld (Post 1223360)
Yes.
PHP Code:

temp.foo = "Bar";
echo(
temp.foo.substring(1)); 

produces "ar".

Yay, now learn to respond to my MSN! xx

xXziroXx 09-28-2006 10:11 PM

Quote:

Originally Posted by projectigi (Post 1223274)
PHP Code:

obj.substring(index[,length]) 

the length parameter is optional =/ atleast the wiki says so

:o

CountBleck 02-24-2008 07:10 AM

This doesnt work.. When I say /warptoevent theres nothing and noone ever gets the popup for the event.

xAndrewx 02-24-2008 09:59 AM

There's only three commands, each one needing an "Events Team" tag. Here are those three commands:

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

cbk1994 02-24-2008 05:37 PM

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.5, 40, "utopia_money.png" },
                  { 
"Chance", "utopia_events_chance.nw", 8, 17, "utopia_ec.gif" },
                  { 
"LMS", "utopia_events_lms.nw", 30, 7, "ut_icon-57.gif" },
                  { 
"Laser Tag", "utopia_events_lt-lobby.nw", 32, 19, "utopia_igun-icon.png" },
                  { 
"Lucky Prize", "utopia_events_luckyprize.nw", 27.5, 26.5, "utopia_ec.gif" },
                  { 
"Ring", "utopia_events_ring.nw", 34, 24, "utopia_igun-icon.png" },
                  { 
"Spar Tourney", "utopia_events_spararena.nw", 31, 21.9, "ut_icon-57.gif" },
                  { 
"Tag Team Spar", "utopia_events_tagteam.nw", 32.3, 21.2, "utopia_weapon-Chaingun-icon.gif" },
                  { 
"Gravity Race", "utopia_event-gravity.nw", 5.8, 56, "utopia_empty.png" },
                  { 
"Trick Race", "utopia_events_trickrace.nw", 12, 22, "utopia_staffblock.gif" },
                  { 
"Quiz", "utopia_events_quiz.nw", 40, 24.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...

CountBleck 02-24-2008 07:32 PM

Quote:

Originally Posted by xAndrewx (Post 1376445)
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?

xAndrewx 02-24-2008 08:09 PM

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.

Switch 02-24-2008 10:09 PM

Quote:

Originally Posted by CountBleck (Post 1376438)
This doesnt work.. When I say /warptoevent theres nothing and noone ever gets the popup for the event.

Quote:

Originally Posted by CountBleck (Post 1376499)
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.

Twinny 02-24-2008 10:24 PM

Quote:

Originally Posted by cbkbud (Post 1376472)
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.

cbk1994 02-24-2008 10:30 PM

Quote:

Originally Posted by Twinny (Post 1376530)
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 = { 30, 10, 40 };
this.eventY = { 22, 24, 35 }; 

which actually makes yours look organized :)


All times are GMT +2. The time now is 03:16 PM.

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