Author Topic: Event Triggering  (Read 2288 times)

Sorry, I'm not very good at scripting, especially when working with closed source code. 
Quick question, how do I

For Example
How would I code when an admin connects to the server, it displays a message.  (granted I know it already displays a message, I just need the example)

What is the code for "if admin connects" or "if non admin connects"

probably like client On Connect or something then if is admin / superadmin then it makes a message

Code: [Select]
package adminAlert{
function GameConnection::OnConnect(%client){
 Parent::OnConnect(%client);
 if(%client.isAdmin || %client.isSuperAdmin)
  messageAll('','%1 is admin or super admin idk',%client.name);
}
};
ActivatePackage(adminAlert);

you might try that, i cant promise it works or anything, didnt test. hopefully if the client is auto-admined when joining the server, the program will have taken care of that by the time it gets done running the parent onconnect function.

Didn't seem to work, you were missin a few brackets anyways.

I still just need to know how to trigger something like..

If(Event event occurs) such as connecting to the server
{
Some piece of code that is triggered by that event.
}

you were missin a few brackets anyways.
If there is only one statement inside the if, the curly brackets are optional.

Well, depends...do you want to add to something already in but DSO'd? If so use the package system then parent the function.

oh wait i just realized that a client doesnt get auto-admined until after their id has been authenticated. im still trying to figure out what function is called when this happens (when your console echoes "Authentication Successful" or something, then "+=bl _id: 160" and "+=no auto admin" or something idk). anyways youd have to test if they are admin after this has happened in order for it to work.
another problem with that is the authentication check is called intermittently during a user's stay on a server, not just when they first connect. you could put some code in there to only display a message the first time they are authenticated or something, otherwise youd get the message at seemingly random times periodically.
am i making any sense. whatever ill post again when i figure this out or not idk.

I believe that is checking the authentication of your key, to make sure that somehow your key isn't unauthentic.

just use onConnectionAccepted and add a schedule with the correct arguments and viola.