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


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

Support us

Support us


 - forum
 - support
 - suggestions
 - mailinglists
 - irc channel


Get Firefox!

Script Functions

The following is a list of the Admin Mod specific additions to the Small language. For reference to the native Small functions, refer to the .INC files in your \admin\scripting\include directory and the current Small documentation from the latest AM release is avaiable here.

Command Syntax


access(lev, username) Return whether the user username has access to level lev. Use "" for the current user.
auth(user) Check the password for this user against the clients pw. Use "" for current player.
ban(player, time) Quick ban of player for time minutes. The player can be any one of nickname, WONid or playerID.

If the time is 0 then the ban is permanent.
censor_words(sString) Replaces every occurence of a word from the list in the file defined by the words_file cvar with asterixes (***).
centersay(string,time,red,green,blue) Print out string to all clients for time seconds with the color (r,g,b).
changelevel(mapname) Change the level immediately to the level specified in mapname. This works just like the rcon changelevel command.
check_auth(iAuthLevel) Returns 1 if the current user has the required iAuthLevel level, 0 otherwise.
check_immunity(sTarget) Returns 1 if the sTarget has immunity.
check_param(sParam) Returns 1 if sParam is '1' or 'on'...0 for anything else.
check_user(username) Return whether username is a valid current user on the server.
check_words(string) Returns 0 if string contains one of the words in the file defined by the words_file cvar. Returns 1 otherwise.
consgreet(sMessage) Display the contents of a text file named in sMessage to the current client in the console. The file has to have the extension '.txt'.
convert_string(iHLString, sSmallString, iMaxLength) Used to convert iHLString from the Half-Life engine into sSmallString for a maximim of iMaxLength to be used in your scripts.
currentmap(map,length) Return the current map name into map with a maximum of length characters.
deletefile(sFilename) Delete the file sFilename from disk.
exec(command) Run command on the server.
execclient(client,cmd) Execute a Half-Life command denoted as cmd on the client computer.
execute_command(sUser, sCommand, sHalfLifeCmd, sData) Executes a command while providing the nicely formatted output.
fileexists(sFilename) Check to see if the file sFilename exists.
filesize(sFilename[], fsize_unit:tUnit = lines) Get the size of the file sFilename.
Size can be either in bytes or in lines, depending on tUnit. tUnit can be one of bytes or lines. For tUnit = bytes the size in bytes gets returned, for tUnits = lines the number of lines in the file is returned.
format_command(sUser,sCommand,sData,sText) Nicely formats the current command into sText.
get_serverinfo(key,info,n) Read a server variable (key) into the variable info for a max length of n.
get_userindex(username,&index) Put the index of username into index. This is used in other commands like playerinfo.
get_userinfo(name,key,info,n) Read a key variable (setinfo type) from the client name into info for a max length of n
get_username(string,string1,n) Copies the username of the player defined in string (either userid or wonid) into string1, for a maximum of n characters.
get_userorigin(user,&X,&Y,&Z) Retrieve the user's origin in the world. This command is usually used with the teleport command.
get_userSessionID(string,&SessionID) Get the SessionID of the user identified by string. This is great for unique identification of players during a LAN game.
get_userWONID(string,&WONID); Place the WonId of the user specified by string in the WONID variable.
get_vaultdata(sKey, sData, iMaxLength) Read the value of the sKey item from the vault placing the value in sData for a maximun length of iMaxLength.
getstrvar(string,dest, length) Put the value of the halflife variable string into dest for a maximum of length characters.
gettarget(sPlayer, sTargetName, iMaxLength, iRange) This function will populate the sTargetName variable to a maximum length of imaxLength with the Name of the Player within the passed sPlayers view. The SessionID of the target is also returned from the function.

If iMaxLength is 0 then no name will be returned. That means if you don't need the name, you can just do gettarget(user, "", 0); If the first parameter is an empty string, then it will act like pointto(), assuming to check the target for the invoking admin.
getteamcount(team) Returns the number of players on team number team.
getvar(string) Get the value of the halflife variable string. ( i.e mp_footsteps)
glow(sTarget, iRed = 0, iGreen = 0, iBlue = 0) Applies a glowing shell to the sTarget with the colour attributes of iRed, iGreen and iBlue. Values of zero for all colours means no glow.
godmode(sPlayer, iOnOff) Set sPlayer to God Mode. This will make the player immune to ALL game damage.
help([keyword]) Display to the current user the help contained in the admin_help.cfg for the keyword. If the keyword is blank, all help topis are displayed.
kick(nickname/playerid) Kick the player defined by nickname/playerid from the server.
kill_timer(iTimer) Kill a running timer identified by the timer number iTimer.
list_maps() Displays a list of the maps in the mapcycle to all client screens.
listspawn(sClass) Return a list of spawned items into sClass
log(string) Log string to the server logfile.
log_command(sUser,sCommand,sData) Logs a command to the HL log file.
look_in_dir(sDirectory, sMatch, sFilename, iNumber)

Allows you to look within the directory sDirectory for files matching the pattern sMatch. The iNumber is the index of the file from the matched list (0 is first match). The sFilename is filled with the file matching the passed index number. The functions returns 1 if a file for the index is found.
maptime(iWhichtime, iPrintToConsole = 0) Maptime can either return the time that has passed into the map (iWhichtime = 0) or the time left on that map (iWhichTime = 1). If you set the second parameter (PrintToConsole) to 1 the information will be printed on the console, otherwise only the time in seconds is returned.
max(a,b) Returns the greater of a and b.
maxplayercount() Returns the maximum number of players allowed on the server.
message(user,string) Send the string to user as a console message. This procedure has been superceeded by messageex() which supports more functionality.
messageex(sTarget[], sMessage[], print_type:tMessageType) Say the private message sMessage to user sTarget with print type tMessageType where tMessageType can be one of:
  1. print_console
  2. print_center
  3. print_chat
  4. print_tty
  5. print_pretty
movespawn(iIdentity, iX, iY, iZ, iXAngle, iYAngle, iZAngle) Move the spawned item identified by iIdentity to its new location defined in iX, iY, and iZ with an angle of iXAngle, iYAngle and iZAngle.
nextmap(mapname,length) If length is zero then the next map name is printed to all clients as a chat style message.

If length is greater than zero, the name of the map is placed within the mapname variable up to a maximum length of length.
noclip(sPlayer, iOnOff) Enables or disables clipping for sPlayer. When iOnOff is 1 then clipping is enabled.
numtostr(num,str) Convert the number stored in num to a string and store it in the variable str.
playercount() Returns the current number of players on the server.
playerinfo(iPlayerIndex, sName, iLength, &iUserID, &iWONID, iTeam, iDead) Get the sName, iUserId, iWONID, iTeam and iDead status of the player represented by iPlayerIndex.

The iPlayerIndex is a number between 0 and maxplayercount() that denotes a player on the server.

iLength is the maximum length of the name.
playsound(client,sound) Play a ".wav" sound on the client machine to the user.
plugin_message(sMessage) Send the message sMessage to the client who initiated the admin command. Works like selfmessage() but it prefixes the message with the plugin's name.
plugin_registercmd(Command, Function, RequiredAccess, HelpMessage) Register a client callable command with the Admin Mod. This controls
  1. the command as it is entered by the client.
  2. the internal Function in the plugin to be called.
  3. The RequiredAccess level the user must have to use this command.
  4. The HelpMessage that is displayed with admin_help
You can also use this to intercept client commands such as "say" and direct them to a function within your plugin.
plugin_registerhelp(Command, RequiredAccess, HelpMessage) Registers help text for a command in the plugin. This allows admin_help to display details about the commands in the plugins.
plugin_registerinfo(Name, Description, Version) Registers the plugin with the Admin mod.
pointto(iRange) Returns the player's slot number that you are pointing to.
readfile(filename,string,lineno,len) Read the contents of line number lineno from filename into string for a maximum of len characters.
reject_message(iPublic) Command to use when the person doesn't have the proper permissions. By passing the iPublic as 1. All clients will see the rejection message, not just the client who initialed.
reload() Reload admin mods config files.
removespawn(iIdentity) Remove the spawned entity identified by iIdentity.
resetfile(filename) Empty the file filename of all its contents.
say(string) Display the message string to everyone.
say_command(sUser,sCommand,sData, iOverride = 0) Results differ upon the setting of admin_quiet. If admin_quiet is 0, says who executed what command. If admin_quiet is 1, says 'Admin' executed what command. Otherwise, simply logs. The override option allows one to ignore admin_quiet, and always display a message.
selfmessage(sMessage) Send the message sMessage to the client who initiated the admin command.
servertime(sTimeString, iMaxLen, sFormat = "none") Stores the current time of the server into the string sTimeString of size iMaxLen. If sFormat is "none" a default format is used (e.g. "Wed Jun 30 21:49:08 1993"). sFormat, if specified, is of the form used by the strftime() system call. See the strftime man page or the manual for details.
set_serverinfo(key,value) Set the server variable key to value.
set_timer(sFunction, iWaitSeconds, iRepeatCount, sParameter = "") Start a timer that will execute the public procedure sFunction every iWaitSeconds seconds and repeat iRepeatCount times.

If iRepeatCount is passed as 99999 then the timer will repeat forever.

The sParameter is passed to the sFunction when the timer is executed.
set_vaultdata(sKey, sData) Assign the value sData to the item defined in sKey and store it it the vault. This value can later be retrieved by using the get_vaultdata function.
slap(sPlayer) Slap the sPlayer. This causes the sPlayer to stumble in a random direction and reduces their Health Points by 5 down to a minimum of 5.
spawn(sClass, iX, iY, iZ, iXAngle, iYAngle, iZAngle) Spawn an entity of type sClass at the coordinates specified by iX, iY and iZ facing the angles iXAngle, iYAngle and iZAngle.
stock min(a,b) Returns the lesser of a and b.
strbreak(str, first, second, maxlen) Given a string str, this will attempt to break it apart at the first space that's not inside quotation marks. Quotes at the beginning and end will be stripped.
strcasecmp( string1, string2 ) Compares the two strings string1 and string2. Returns a value less that, equal to or greater than zero if string1 is found, respectively, to be less than, to match, or be greater than string2.
The comparison is not case-sensitive.
strcat( dest, source, maxlen ) Appends the string source to the string dest overwriting the '\0' character at the end of string dest and then adds a terminating '\0'. maxlen is the size of the destination array.
strchr( string, char ) Returns the zero-based index of the first occurence of the character char in the string string.

strchr() and index() are synonymous.
strcmp(string1, string2) Compares the two strings string1 and string2. Returns a value less that, equal to or greater than zero if string1 is found, respectively, to be less than, to match, or be greater than string2.
The comparison is case-sensitive.
strcount(str, searchchar) Counts the number of times searchchar appears in str.
strcpy( dest, source, maxlen ) Copy the string in source to the string dest. maxlen is the size of the destination array.
streq(strOne, strTwo) Returns 1 if two strings are exactly the same, including length, etc.
strinit(sString) Initialize a string.
strmatch(sOne, sTwo, iLength) Returns 1 if two strings are the same in the first iLength (or less if one is smaller than iLength) digits, 0 otherwise.
strncasecmp( string1, string2, num ) Compares the first num characters of the two strings string1 and string2. Returns a value less than, equal to, or greater than zero if the first num characters of string1 are found, respectively, to be less than, to match, or be greater than the first num characters of string2. The comparison is not case-sensitive.
strncat( dest, source, num, maxlen ) Appends the first num characters of string source to the end of string dest overwriting the '\0' character and then adds a terminating '\0'. maxlen is the size of the destination array.
strncmp( string1, string2, num ) Compares the first num characters of the two strings string1 and string2. Returns a value less than, equal to, or greater than zero if the first num characters of string1 are found, respectively, to be less than, to match, or be greater than the first num characters of string2.
The comparison is case-sensitive.
strncpy( dest, source, num, maxlen ) Copy num characters from the beginning of string source to the string dest. maxlen is the size of the destination array.
strstripquotes(str) Strips the quotes from the beginning and ending of str, if they exist. Ignores those in the middle.
strtonum(string) Returns the integer value stored in string.
systemtime( ) Returns the current time of the server in seconds since the Epoch (00:00:00 UTC, January 1, 1970).
teleport(string,X,Y,Z) This command will teleport the users identfied by string to the world location specified by X,Y,Z.

This command is usually used with the get_userorigin command
timeleft(iPrintToConsole = 1) Returns the number of seconds left for the current map to be played. Can have a paramter of 1 or 0. If 1, then the remaining time is printed to the console of the invoking user. If 0 is passed as parameter, no message gets printed.
typesay(sMessage, iTime, iRed, iGreen, iBlue) Print sMessage for iTime seconds to all users with a teletype effect into the lower left of the screen. The color of the text is set with iRed, iGreen, iBlue
unban(string) Remove the banned user in string from the banned list.
userlist() Display the list of users currently on the server in the console.
valid_map(map_name) Return whether this map_name is a valid map name.
version() Print out the current version of admin mod to the console.
vote(question, opt1, opt2, ..., opt9, pub_proc, pass_var) Display the question and accept any of the passed options from 1 to 9. The pub_proc is a public procedure to execute when the voting is complete. pass_var is an extra variable that is given to the pub_proc.

See Admin.sma for examples.
vote_allowed() Return whether a vote is allowed to happen right now. This is based on the vote_freq setting on the server.
writefile(sFileName,sLine, iLineNum = -1) Writes the string sLine to sFilename, on line number iLineNum of the file.



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


 - AScript
 - MetaMod

Sponsors Logo



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

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