Sitemap

 - news
 - newsarchive
 - overview
 - faq
 - installation
 - help
 - commands
 - scripting
 - plugins
 - fun
 - the team
 - credits
 
 - AM online store
 - SourceForge
 

Download

 - Linux v.2.50.60
 - Win v.2.50.60
 - older versions
 - Inoffical version
 - tools
 

Support us


Support us

Community

 - forum
 - support
 - suggestions
 - mailinglists
 - irc channel
 

Choice


Get Firefox!
   

Tutorials


A private message system for admins.

The private message system allows users with security of 256 to send messges to each other. The format of the finished command is:

code:
admin_psay 'user' 'message'

The trick here is we are going to use the parseuser function found in the snippets section to allow us to support userid's and usernames with or without spaces.

The first thing we need to do is get those snippets into our script.The ones we need are strnsplit and parseuser. Go get them from the from the snippets section. I'll wait...

Ok, now that you have the snippets we need, lets put them in the admin.sma. The snippets we have will become what is know as helper functions. These must be placed at the top of the source file because the compiler has to see they exists before you can use them. This brings up the topic of function prototypes, but that's another story. So for now, order matters.

Locate the end of the helper functions. The big END OF HELPER FUNCTIONS might be a clue and just within the helper functions section, add the strnsplit adn the the parseuser snippets in that order.

Now on to the guts...

Just after the helper section you will find the first admin command, admin_say. The code following the command declaration is guts of the command. Skip it. We don't want to look at it. The end of the admin_say is denoted by the curly brace "}" in the first column of a line. After this curly brace we need to insert our new admin command. Here is the code:

code:
admin_psay(a[]) {

if ( auth("") != 1 || access(LEV256)!=1) {
message(user,\
"You don't have access to this command");
return;
}

new msg[100];
new pmsg[100];
new user_name[100];
new rc;

parseuser(a,user_name,msg);

rc = check_user(user_name);
if( rc>0 ) {
new real_user[MAX_NAME_LENGTH];
get_username(user_name,real_user,\
MAX_NAME_LENGTH);
strncpy(pmsg, "Private Message from ( ", \
strlen("^aPrivate Message from ( "));
strncat(pmsg, user,100);
strncat(pmsg, " ) ",100);
strncat(pmsg, msg, 100);

messageex(real_user,pmsg,print_chat);
} else {
strncpy(pmsg, "User: ", strlen("User: "));
strncat(pmsg, user_name, 100);
strncat(pmsg, " not found", 100);
message(user,pmsg);
}
}

Now I know I could go into great detail as to what, how and why this command is the way it is but I would enlighten a third of you, bore a third of you and confuse the rest of you. So if you have questions about the command, ask in the forums.

Now that we have our command guts, we just need a way to call it. Search for the following line (without quotes): "admin_say(data)". You should find something like this:

code:
if( streq(command,"admin_say",strlen(command))==1 )
admin_say(data);
else if( streq(command,"admin_map",strlen(command))==1)
admin_map(data);

Insert the following lines before the "else if" but after the "admin_say(data);".

code:
else if( streq(command,"admin_psay",strlen(command))==1)
admin_psay(data);

This procedure we are in, is the admin command dispatcher (makes it sound important eh?). In short, this is the procedure that is called by the AdminMod to handle all of the scripted commands. Now we just recompile and install our new script, give ourselves 256 access and start sending messages to yourself to test it!

-[ Dio ]-




 

AScript

 - news
 - news archive
 - plugins
 - submitting
 - faq
 - functions
 - helpers
 - tutorials
 
 - Small Site
 

Affiliates

 - AScript
 - MetaMod
 - Adminmod.de
 

Sponsors


SourceForge.net Logo
 
 

Get Halflife Admin Mod at SourceForge.net. Fast, secure and Free Open Source software downloads.    CS Server     ||    

  [ Half-Life Admin Mod © Alfred Reynolds 2000-2025 ] - [ site design and programming by Jägermeister ]