I'm trying to write a script that will perform certain actions upon another person entering and leaving the server. Taking from Tokath's "HocusFocus.cs" script, I attempted to employ the same method in a trial run:
HocusFocus.cs
Event::Attach(eventClientJoin, Focus::Connected);
Event::Attach(eventClientChangeTeam, Focus::JoinedCitizen);
Event::Attach(eventClientDrop, Focus::Dropped);
Event::Attach(eventClientMessage, Focus::Monitor);
function Focus::Connected (%client) {
if ($Focus::ConnectInsult == 1 && $Focus::Script == "on") {
%client = client::getname(%client);
for (%i=0; $Focus::Target[%i] != ""; %i++) {
if (%client == $Focus::Target[%i]) {
%c = 0;
for (%x=0; $Focus::ConnectMessage[%x] != ""; %x++) {
%c++;
}
%rnd = floor(getRandom() * %c);
%connectmessage = String::replace($Focus::ConnectMessage[%rnd], "%target%", %client);
say(0, %connectmessage);
}
}
}
}
function Focus::JoinedCitizen (%client, %team) {
%stuff here
}
function Focus::Dropped(%client) {
%stuff here
}
Now that's all fine and dandy. I don't need anything that complicated, and for testing purposes, I'm just going to have my script say something in global.
myscript.cs
event::Attach(eventClientJoin, yellJoin);
event::Attach(eventClientChangeTeam, yellCitizen);
event::Attach(eventClientDrop, yellDrop);
function yellJoin(%client) {
say(0,client::getname(%client) @ " joined the game, biznatch.");
}
function yellCitizen(%client, %team) {
if(%team==0) {
say(0,client::getname(%client) @ " joined team " @ client::getteam(%client) @ ", biznatch.");
}
}
function yellDrop(%client) {
say(0,client::getname(%client) @ " left the game, biznatch.");
}
But, for some reason, the functions attached to "eventClientChangeTeam" and "eventClientDrop" don't execute. I've been considering using straight-up
function onClientJoin(%client) {
}
...but I feel like that's going to be a headache because it's at the root of Tribes, and if I have multiple, different functions calling onClientJoin, they will overwrite each other and cause all sorts of panic.
Can anyone help me figure out why eventClientDrop and eventClientChangeTeam doesn't work like they're supposed to?