PDA

View Full Version : Add and play Event System


Twinny
08-24-2006, 05:13 PM
One of the most frequent things I am asked for on playerworlds is an event system. This is a simple event system which is easy to add and use.


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("-Esystem","EventSet");
}
}
}
else if (cmd == "clear") {
serverr.eventname = "";
serverr.eventlevel = "";
serverr.eventx = "";
serverr.eventy = "";
serverr.eventmessage = "";
for (pl : allplayers) {
pl.triggerclient("-Esystem","Clear");
}
}
else if (cmd == "warptoevent") {
setlevel2(serverr.eventlevel,serverr.eventx,server r.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","-Esystem","setevent",player.chat.substring(10));
}
else if (player.chat.starts("/message")) {
triggerserver("gui","-Esystem","setmessage",player.chat.substring(9));
}
else if (player.chat.starts("/clear")) {
triggerserver("gui","-Esystem","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", [email protected]": " @ serverr.eventmessage).layer=4;
}

function ebutton.onAction() {
triggerserver("gui","-Esystem","warptoevent");
}



This setup requires that you name your weapon -Esystem. If you wish to use another name simply find/replace all counts of -Esystem within this script.

Angel_Light
08-24-2006, 10:50 PM
This setup requires that you name your weapon -Esystem. If you wish to use another name simply find/replace all counts of -Esystem within this script.

You could of put 'name' where that is so it wont confuse simple minded scripters XD anyways nice script! :P