* (c) Copyright 1998-2002, ITB CompuPhase
* This file is provided as is (no warranties).
*/
#if defined _core_included
#endinput
#endif
#define _core_included
native heapspace();
native funcidx(const name[]);
native numargs();
native getarg(arg, index=0);
native setarg(arg, index=0, value);
native strlen(const string[]);
native strpack(dest[], const source[]);
native strunpack(dest[], const source[]);
native tolower(c);
native toupper(c);
native swapchars(c);
native random(max);
/* We use the Small versions in adminlib.inc instead
native min(value1, value2);
native max(value1, value2);
*/
native clamp(value, min=cellmin, max=cellmax);
native getproperty(id=0, const name[]="", value=cellmin, string[]="");
native setproperty(id=0, const name[]="", value=cellmin, const string[]="");
native deleteproperty(id=0, const name[]="", value=cellmin);
native existproperty(id=0, const name[]="", value=cellmin)
#include <core>
#include <string>
#define CHAR_INVALID -1
#define FALSE 0
#define NULL_CHAR 0
#define PERIOD_CHAR 46
#define QUOTE_CHAR 34
#define TRUE 1
/* Returns 1 if the current user has the required auth level, 0 otherwise */
stock check_auth( iAuthLevel ) {
new iResult = access(iAuthLevel,"");
if (iResult!=0) iResult = 1;
return iResult;
}
/* Returns the lesser of a and b */
stock min(a,b) {
if (a<b) return a;
else return b;
return 1;
}
/* Returns the greater of a and b */
stock max(a,b) {
if (a>b) return a;
else return b;
return 1;
}
/* Executes a command while providing the nicely formatted output */
stock execute_command(sUser[], sCommand[], sHalfLifeCmd[], sData[]) {
new sRconCmd[MAX_DATA_LENGTH];
say_command(sUser,sCommand,sData);
snprintf(sRconCmd, MAX_DATA_LENGTH, "%s %s", sHalfLifeCmd, sData);
exec(sRconCmd);
}
/* Nicely formats the current command */
stock format_command(sUser[],sCommand[],sData[],sText[]) {
snprintf(sText, MAX_TEXT_LENGTH, "Command: %s used command %s %s", sUser, sCommand, sData);
}
/* Logs a command */
stock log_command(sUser[],sCommand[],sData[]) {
new sText[MAX_TEXT_LENGTH];
format_command(sUser,sCommand,sData,sText);
log(sText);
}
/* NumToStr courtesy of Nathan O'Sullivan (http://nathan.qgl.org/halflifeadmin/numtostr.txt) */
stock numtostr(num,str[]) {
new Base = 1;
new Digits = 1;
new i = 0;
/* Special case: 0 */
if (num == 0) {
str[i++] = '0';
str[i++] = NULL_CHAR;
} else {
/* If we've got a negative number, add a negative sign
to the string, and multiply the number by -1 */
if (num < 0) {
str[i++] = '-';
num *= -1;
}
/* Ok. We've got at least one digit. Keep multiplying by
10 till we get a higher number than what we've got. Note
that this will leave Digits 1 higher than what we want (eg,
if Num was 7, Digits will be 2 */
while (Base <= num) {
Base *= 10;
Digits++;
}
/* Because Digits is higher, use --Digits rather than Digits--.
Also, divide Base before using it. */
while (--Digits > 0) {
Base /= 10;
str[i++] = '0' + (num - (num % Base)) / Base;
num = num % Base;
}
str[i++] = NULL_CHAR;
}
}
/* Command to use when the person doesn't have the proper permissions. */
stock reject_message(iPublic = 0) {
new sText[MAX_TEXT_LENGTH];
getstrvar("admin_reject_msg",sText,MAX_TEXT_LENGTH);
if(strlen(sText) < 2)
strcpy(sText, "You do not have access to this command.", MAX_TEXT_LENGTH);
if (iPublic == 0) {
selfmessage(sText);
} else {
say(sText);
}
}
/* 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.
*/
stock say_command(sUser[],sCommand[],sData[], iOverride = 0) {
new iQuiet;
new sText[MAX_TEXT_LENGTH];
iQuiet = getvar("admin_quiet");
if (iQuiet==0) {
format_command(sUser,sCommand,sData,sText);
say(sText);
} else if (iQuiet==1 || iOverride==1) {
format_command("Admin",sCommand,sData,sText);
say(sText);
} else {
log_command(sUser,sCommand,sData);
}
}
/* 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. Ie,
new str[20] = "This is a test"
new first[20];
new second[20];
strbreak(str,first,second, 20);
first is now equal to "This", and second is now equal to "is a test". If
str[] had been "^"This is^" a test", first would be "This is" and second would
be "a test".
At maximum maxlen characters will be copied. */
stock strbreak(str[], first[], second[], maxlen, flen=sizeof first, slen=sizeof second ) {
new i = 0;
new j = 0;
new NullPos = CHAR_INVALID;
new Quote = FALSE;
new SpacePos = CHAR_INVALID;
new iFirstEnd;
new iSecondEnd;
if (maxlen == 0)
maxlen = strlen(str);
// Find the position of the first unquoted space and the terminating NULL character
for(i=0; i<=strlen(str); i++)
particle_t *( *R_AllocParticle ) ( void ( *callback ) ( struct particle_s *particle, float frametime ) );
void ( *R_BlobExplosion ) ( float * org );
void ( *R_Blood ) ( float * org, float * dir, int pcolor, int speed );
void ( *R_BloodSprite ) ( float * org, int colorindex, int modelIndex, int modelIndex2, float size );
void ( *R_BloodStream ) ( float * org, float * dir, int pcolor, int speed );
void ( *R_BreakModel ) ( float *pos, float *size, float *dir, float random, float life, int count, int modelIndex, char flags );
void ( *R_Bubbles ) ( float * mins, float * maxs, float height, int modelIndex, int count, float speed );
void ( *R_BubbleTrail ) ( float * start, float * end, float height, int modelIndex, int count, float speed );
void ( *R_BulletImpactParticles ) ( float * pos );
void ( *R_EntityParticles ) ( struct cl_entity_s *ent );
void ( *R_Explosion ) ( float *pos, int model, float scale, float framerate, int flags );
void ( *R_FizzEffect ) ( struct cl_entity_s *pent, int modelIndex, int density );
void ( *R_FireField ) ( float * org, int radius, int modelIndex, int count, int flags, float life );
void ( *R_FlickerParticles ) ( float * org );
void ( *R_FunnelSprite ) ( float *org, int modelIndex, int reverse );
void ( *R_Implosion ) ( float * end, float radius, int count, float life );
void ( *R_LargeFunnel ) ( float * org, int reverse );
void ( *R_LavaSplash ) ( float * org );
void ( *R_MultiGunshot ) ( float * org, float * dir, float * noise, int count, int decalCount, int *decalIndices );
void ( *R_MuzzleFlash ) ( float *pos1, int type );
void ( *R_ParticleBox ) ( float *mins, float *maxs, unsigned char r, unsigned char g, unsigned char b, float life );
void ( *R_ParticleBurst ) ( float * pos, int size, int color, float life );
void ( *R_ParticleExplosion ) ( float * org );
void ( *R_ParticleExplosion2 ) ( float * org, int colorStart, int colorLength );
void ( *R_ParticleLine ) ( float * start, float *end, unsigned char r, unsigned char g, unsigned char b, float life );
void ( *R_PlayerSprites ) ( int client, int modelIndex, int count, int size );
void ( *R_Projectile ) ( float * origin, float * velocity, int modelIndex, int life, int owner, void (*hitcallback)( struct tempent_s *ent, struct pmtrace_s *ptr ) );
void ( *R_RicochetSound ) ( float * pos );
void ( *R_RicochetSprite ) ( float *pos, struct model_s *pmodel, float duration, float scale );
void ( *R_RocketFlare ) ( float *pos );
void ( *R_RocketTrail ) ( float * start, float * end, int type );
void ( *R_RunParticleEffect ) ( float * org, float * dir, int color, int count );
void ( *R_ShowLine ) ( float * start, float * end );
void ( *R_SparkEffect ) ( float *pos, int count, int velocityMin, int velocityMax );
void ( *R_SparkShower ) ( float *pos );
void ( *R_SparkStreaks ) ( float * pos, int count, int velocityMin, int velocityMax );
void ( *R_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int spread, int rendermode );
void ( *R_Sprite_Explode ) ( TEMPENTITY *pTemp, float scale, int flags );
void ( *R_Sprite_Smoke ) ( TEMPENTITY *pTemp, float scale );
void ( *R_Sprite_Spray ) ( float * pos, float * dir, int modelIndex, int count, int speed, int iRand );
void ( *R_Sprite_Trail ) ( int type, float * start, float * end, int modelIndex, int count, float life, float size, float amplitude, int renderamt, float speed );
void ( *R_Sprite_WallPuff ) ( TEMPENTITY *pTemp, float scale );
void ( *R_StreakSplash ) ( float * pos, float * dir, int color, int count, float speed, int velocityMin, int velocityMax );
void ( *R_TracerEffect ) ( float * start, float * end );
void ( *R_UserTracerParticle ) ( float * org, float * vel, float life, int colorIndex, float length, unsigned char deathcontext, void ( *deathfunc)( struct particle_s *particle ) );
particle_t *( *R_TracerParticles ) ( float * org, float * vel, float life );
void ( *R_TeleportSplash ) ( float * org );
void ( *R_TempSphereModel ) ( float *pos, float speed, float life, int count, int modelIndex );
TEMPENTITY *( *R_TempModel ) ( float *pos, float *dir, float *angles, float life, int modelIndex, int soundtype );
TEMPENTITY *( *R_DefaultSprite ) ( float *pos, int spriteIndex, float framerate );
TEMPENTITY *( *R_TempSprite ) ( float *pos, float *dir, float scale, int modelIndex, int rendermode, int renderfx, float a, float life, int flags );
int ( *Draw_DecalIndex ) ( int id );
int ( *Draw_DecalIndexFromName ) ( char *name );
void ( *R_DecalShoot ) ( int textureIndex, int entity, int modelIndex, float * position, int flags );
void ( *R_AttachTentToPlayer ) ( int client, int modelIndex, float zoffset, float life );
void ( *R_KillAttachedTents ) ( int client );
BEAM *( *R_BeamCirclePoints ) ( int type, float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
BEAM *( *R_BeamEntPoint ) ( int startEnt, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
BEAM *( *R_BeamEnts ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
BEAM *( *R_BeamFollow ) ( int startEnt, int modelIndex, float life, float width, float r, float g, float b, float brightness );
void ( *R_BeamKill ) ( int deadEntity );
BEAM *( *R_BeamLightning ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed );
BEAM *( *R_BeamPoints ) ( float * start, float * end, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
BEAM *( *R_BeamRing ) ( int startEnt, int endEnt, int modelIndex, float life, float width, float amplitude, float brightness, float speed, int startFrame, float framerate, float r, float g, float b );
dlight_t *( *CL_AllocDlight ) ( int key );
dlight_t *( *CL_AllocElight ) ( int key );
TEMPENTITY *( *CL_TempEntAlloc ) ( float * org, struct model_s *model );
TEMPENTITY *( *CL_TempEntAllocNoModel ) ( float * org );
TEMPENTITY *( *CL_TempEntAllocHigh ) ( float * org, struct model_s *model );
TEMPENTITY *( *CL_TentEntAllocCustom ) ( float *origin, struct model_s *model, int high, void ( *callback ) ( struct tempent_s *ent, float frametime, float currenttime ) );
void ( *R_GetPackedColor ) ( short *packed, short color );
short ( *R_LookupColor ) ( unsigned char r, unsigned char g, unsigned char b );