Author Topic: "eventClientJoin" vs "onClientJoin", and Presto  (Read 2476 times)

0 Members and 1 Guest are viewing this topic.

KoRo

  • Fat, Emo Robot
  • Centurian Lord
  • ********
  • Posts: 3,436
  • Reputation: +14/-6
"eventClientJoin" vs "onClientJoin", and Presto
« on: March 4, 2014 06:19 pm CST »
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
Code: [Select]
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

Code: [Select]
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
Code: [Select]
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?
« Last Edit: March 4, 2014 06:25 pm CST by KoRo »

KoRo

  • Fat, Emo Robot
  • Centurian Lord
  • ********
  • Posts: 3,436
  • Reputation: +14/-6
Re: "eventClientJoin" vs "onClientJoin", and Presto
« Reply #1 on: March 7, 2014 01:02 am CST »
As an added conversation piece:

Many have expressed their negative feelings about Presto, and truthfully, the only useful thing about it that I use is the event::attach(%event, %function) function. If so many of you dislike presto, do you happen to have any better alternatives that provide a similar function which would allow me to attach functions to in-game events? Furthermore, is there a way to optimize this process? It seems like a somewhat unreliable function, especially if there is a lot going on simultaneously (i.e. hitting a bot, getting hit, casting a spell, bots joining teams, all at the same time).