If you like this and find this useful, think about donating a small amount. Development & administrating this site takes allot of our time. Time, we don't get paid and we also have to pay the server this runs on. Please help us keeping this all up by donating,
thank you !











LOADING

SMLIB (Function Stock Library for Sourcemod)

About SMLIB


SMLib is a collection of function stocks for sourcemod written by the basic principle that every line of code should only exist one time.
In the past I've catched myself reinventing the wheel again and again and again in every plugin I wrote. That's why I started - together with Chanz - writing on a set of stock include files, with the aim to write reusable code I can call everywhere. The code of our plugins should be as easily readable as a book.
After many months of writing dozen of sourcemod plugins and hundred of functions this is what came out.

Note: some functions have been written but not tested yet, so please report any bugs & errors in this thread.

Linux Compiler: Be sure to download the latest version on the Sourcemod Snapshot page, the old linux compiler did have some bugs.


Download:

License:

Git(-hub):






Installation




Discussion

Function List:
SMLib 0.11 Beta

GNU General Public License 3.0

https://github.com/bcserv/smlib/

I recommend hardlinking your git folder into your scripting/include/ folder, so that you can easily keep your smlib up2date.
Windows (>= Vista): mklink /D \path\to\include\smlib \path\to\git\smlib\trunks
Linux: ln -s /path/to/sourcemod/scripting/include/smlib /path/to/git/smlib/trunks

Simply extract the contents of this zip file into your sourcemod folder.
Then add #include <smlib> at the top of your sm plugin file and you are done.
Documentation of the Functions can be found below or inside the .inc files, but we will also put online a dynamic Javascript API-Reference later.

http://forums.alliedmods.net/showthread.php?p=1398699

Listing 350 functions. Hover of the functions to get a description.      > Open in a new page
// File: arrays.inc
stock Array_FindValue(any:array[], size, any:value, start=0);
stock Array_FindString(const String:array[][], size, const String:str[], bool:caseSensitive=true, start=0);
stock Array_FindLowestValue(any:array[], size, start=0);
stock Array_FindHighestValue(any:array[], size, start=0);
stock Array_Fill(any:array[], size, any:value, start=0);
stock Array_Copy(const any:array[], any:newArray[], size);

// File: clients.inc
stock Client_SetHideHud(client, flags);
stock bool:Client_IsValid(client, bool:checkConnected=true);
stock bool:Client_IsIngame(client);
stock bool:Client_IsIngameAuthorized(client);
stock Client_FindBySteamId(const String:auth[]);
stock Client_FindByName(const String:name[], bool:partOfName=true, bool:caseSensitive=false);
stock Obs_Mode:Client_GetObserverMode(client);
stock bool:Client_SetObserverMode(client, Obs_Mode:mode, bool:updateMoveType=true);
stock Obs_mode:Client_GetObserverLastMode(client);
stock Client_SetObserverLastMode(client, Obs_Mode:mode);
stock Client_GetViewOffset(client, Float:vec[3]);
stock Client_SetViewOffset(client, Float:vec[3]);
stock Client_GetObserverTarget(client);
stock Client_SetObserverTarget(client, entity, bool:resetFOV=true);
stock Client_GetFOV(client);
stock Client_SetFOV(client, value);
stock bool:Client_DrawViewModel(client);
stock Client_SetDrawViewModel(client, bool:drawViewModel);
stock Client_SetThirdPersonMode(client, enable=true);
stock Client_IsInThirdPersonMode(client);
stock bool:Client_ScreenFade(client, duration, mode, holdtime=-1, r=0, g=0, b=0, a=255, bool:reliable=true);
stock Client_GetClones(client, cloneList[]);
stock bool:Client_IsOnLadder(client);
stock Water_Level:Client_GetWaterLevel(client);
stock Float:Client_GetSuitSprintPower(client);
stock Client_SetSuitSprintPower(client, Float:power);
stock Client_GetCount(bool:countInGameOnly=true, bool:countFakeClients=true);
stock Client_GetFakePing(client, bool:goldSource=true);
stock Client_GetClosestToClient(client);
stock Client_GetLastPlaceName(client, String:buffer[], size);
stock Client_GetScore(client);
stock Client_SetScore(client, value);
stock Client_GetDeaths(client);
stock Client_SetDeaths(client, value);
stock Client_GetArmor(client);
stock Client_SetArmor(client, value);
stock Float:Client_GetSuitPower(client);
stock Client_SetSuitPower(client, Float:value);
stock Client_GetActiveDevices(client);
stock Float:Client_GetNextDecalTime(client);
stock bool:Client_CanSprayDecal(client);
stock Client_GetVehicle(client);
stock bool:Client_IsInVehicle(client);
stock Client_RemoveAllDecals(client);
stock bool:Client_ExitVehicle(client);
stock bool:Client_RawAudio(client, const emitter, const String:soundfile[], Float:length = 0.0, pitch = 100);
stock bool:Client_RawAudioToAll(const emitter, const String:soundfile[], Float:length = 0.0, pitch = 100);
stock Client_Impulse(client, value);
stock Client_GetWeaponsOffset(client);
stock Client_GetActiveWeapon(client);
stock Client_GetActiveWeaponName(client, String:buffer[], size);
stock Client_SetActiveWeapon(client, weapon);
stock bool:Client_ChangeWeapon(client, const String:className[]);
stock Client_ChangeToLastWeapon(client);
stock Client_GetLastActiveWeapon(client);
stock bool:Client_GetLastActiveWeaponName(client, String:buffer[], size);
stock Client_SetLastActiveWeapon(client, weapon);
stock Client_EquipWeapon(client, weapon, bool:switchTo=false);
stock bool:Client_DetachWeapon(client, weapon);
stock Client_GiveWeapon(client, const String:className[], bool:switchTo=true);
stock Client_GiveWeaponAndAmmo(client, const String:className[], bool:switchTo=true, primaryAmmo=-1, secondaryAmmo=-1, primaryClip=-1, secondaryClip=-1);
stock bool:Client_RemoveWeapon(client, const String:className[], bool:firstOnly=true, bool:clearAmmo=false);
stock Client_RemoveAllWeapons(client, const String:exclude[]="", bool:clearAmmo=false);
stock Client_HasWeapon(client, const String:className[]);
stock Client_GetWeapon(client, const String:className[]);
stock Client_GetWeaponBySlot(client, slot);
stock Client_GetDefaultWeapon(client);
stock bool:Client_GetDefaultWeaponName(client, String:buffer[], size);
stock Client_GetFirstWeapon(client);
stock Client_GetWeaponCount(client);
stock bool:Client_IsReloading(client);
stock bool:Client_SetWeaponClipAmmo(client, const String:className[], primaryClip=-1, secondoaryClip=-1);
stock bool:Client_GetWeaponPlayerAmmo(client, const String:className[], &primaryAmmo=-1, &secondaryAmmo=-1);
stock bool:Client_SetWeaponPlayerAmmo(client, const String:className[], primaryAmmo=-1, secondaryAmmo=-1);
stock Client_SetWeaponPlayerAmmoEx(client, weapon, primaryAmmo=-1, secondaryAmmo=-1);
stock Client_SetWeaponAmmo(client, const String:className[], primaryAmmo=-1, secondaryAmmo=-1, primaryClip=-1, secondaryClip=-1);
stock Client_GetNextWeapon(client, &index = 0);
stock bool:Client_PrintHintText(client, const String:format[], any:...);
stock Client_PrintHintTextToAll(const String:format[], any:...);
stock bool:Client_PrintKeyHintText(client, const String:format[], any:...);
stock Client_PrintKeyHintTextToAll(const String:format[], any:...);
stock Client_PrintToChatRaw(client, const String:message[], subject=0, bool:isChat=false);
stock Client_PrintToChat(client, bool:isChat, const String:format[], any:...);
stock Client_PrintToChatExclude(client);
stock Client_PrintToChatAll(bool:isChat, const String:format[], any:...);
stock Client_PrintToChatEx(clients[], numClients, bool:isChat, const String:format[], any:...);
stock Client_PrintToConsole(client, const String:format[], any:...);
stock Client_Print(client, ClientHudPrint:destination, const String:format[], any:...);
stock Client_Reply(client, const String:format[], any:...);
stock bool:Client_Shake(client, command=SHAKE_START, Float:amplitude=50.0, Float:frequency=150.0, Float:duration=3.0);
stock bool:Client_IsAdmin(client);
stock bool:Client_HasAdminFlags(client, flags=ADMFLAG_GENERIC);
stock bool:Client_IsInAdminGroup(client, const String:groupName[], bool:caseSensitive=true);
stock bool:Client_IsLookingAtWall(client, Float:distance=40.0);
stock Client_GetClass(client);
stock Client_SetClass(client, class, bool:persistant=false);
stock Client_GetButtons(client);
stock Client_SetButtons(client, buttons);
stock Client_AddButtons(client, buttons);
stock Client_RemoveButtons(client, buttons);
stock Client_ClearButtons(client);
stock bool:Client_HasButtons(client, buttons);
stock Client_GetChangedButtons(client);
stock Client_SetMaxSpeed(client, Float:value);
stock Client_SetScreenOverlay(client, const String:path[]);
stock Client_SetScreenOverlayForAll(const String:path[]);
stock Client_Mute(client);
stock Client_UnMute(client);
stock bool:Client_IsMuted(client);
stock bool:Client_MatchesFilter(client, flags);
stock Client_Get(clients[], flags=CLIENTFILTER_ALL);
stock Client_GetRandom(flags=CLIENTFILTER_ALL);
stock Client_GetNext(flags, start=1);
stock Float:Client_GetMapTime(client);

// File: colors.inc
stock Color_ChatSetSubject(client);
stock Color_ChatClearSubject();
stock Color_ParseChatText(const String:str[], String:buffer[], size);
stock Color_TagToCode(const String:tag[], &subject=-1);
stock Color_StripFromChatText(const String:input[], String:output[], size);

// File: concommands.inc
stock bool:ConCommand_HasFlags(const String:command[], const flags);
stock ConCommand_AddFlags(const String:command[], const flags);
stock ConCommand_RemoveFlags(const String:command[], const flags);

// File: convars.inc
stock bool:Convar_HasFlags(Handle:convar, flags);
stock Convar_AddFlags(Handle:convar, flags);
stock Convar_RemoveFlags(Handle:convar, flags);
stock bool:Convar_IsValidName(const String:name[]);

// File: crypt.inc
stock Crypt_Base64Encode(const String:sString[], String:sResult[], len, sourcelen=0);
stock Crypt_Base64Decode(const String:sString[], String:sResult[], len);
stock Crypt_Base64MimeToUrl(const String:sString[], String:sResult[], len);
stock Crypt_Base64UrlToMime(const String:sString[], String:sResult[], len);
stock Crypt_MD5(const String:str[], String:output[], maxlen);
stock Crypt_RC4Encode(const String:input[], const String:pwd[], String:output[], maxlen);
stock Crypt_RC4EncodeBinary(const String:input[], str_len, const String:pwd[], String:output[], maxlen);

// File: debug.inc
stock Debug_FloatArray(const Float:array[], size=3);

// File: dynarrays.inc
stock bool:DynArray_GetBool(Handle:array, index, block=0, bool:asChar=false);

// File: edicts.inc
stock Edict_FindByName(const String:name[]);
stock Edict_FindByHammerId(hammerId);
stock Edict_GetClosest(Float:vecOrigin_center[3], bool:clientsOnly=false, ignoreEntity=-1);
stock Edict_GetClosestToEdict(edict, bool:clientsOnly=false);

// File: effects.inc
stock bool:Effect_DissolveEntity(entity, DissolveType:dissolveType=DISSOLVE_NORMAL);
stock bool:Effect_DissolvePlayerRagDoll(client, DissolveType:dissolveType=DISSOLVE_NORMAL);
stock Effect_Fade(entity, fadeOut=true, kill=false, fast=true, EffectCallback:callback=INVALID_FUNCTION, any:data=0);
stock Effect_FadeIn(entity, fast=true, EffectCallback:callback=INVALID_FUNCTION, any:data=0);
stock Effect_FadeOut(entity, kill=false, fast=true, EffectCallback:callback=INVALID_FUNCTION, any:data=0);
stock Effect_DrawBeamBoxToClient();
stock Effect_DrawBeamBoxToAll();
stock Effect_DrawBeamBox();

// File: entities.inc
stock Entity_IsValid(entity);
stock Entity_FindByName(const const String:name[], const String:class[]="");
stock Entity_FindByHammerId(hammerId, const String:class[]="");
stock Entity_FindByClassName(startEntity, const String:className[]);
stock bool:Entity_ClassNameMatches(entity, const String:className[], partialMatch=false);
stock bool:Entity_NameMatches(entity, const String:name[]);
stock Entity_GetName(entity, String:buffer[], size);
stock Entity_SetName(entity, const String:name[], any:...);
stock Entity_GetClassName(entity, String:buffer[], size);
stock Entity_SetClassName(entity, const String:className[]);
stock Entity_GetTargetName(entity, String:buffer[], size);
stock Entity_SetTargetName(entity, const String:name[], any:...);
stock Entity_GetGlobalName(entity, String:buffer[], size);
stock Entity_SetGlobalName(entity, const String:name[], any:...);
stock Entity_GetParentName(entity, String:buffer[], size);
stock Entity_SetParentName(entity, const String:name[], any:...);
stock Entity_GetHammerId(entity);
stock Float:Entity_GetRadius(entity);
stock Entity_SetRadius(entity, Float:radius);
stock Entity_GetMinSize(entity, Float:vec[3]);
stock Entity_SetMinSize(entity, Float:vecMins[3]);
stock Entity_GetMaxSize(entity, Float:vec[3]);
stock Entity_SetMaxSize(entity, Float:vecMaxs[3]);
stock Entity_SetMinMaxSize(entity, Float:vecMins[3], Float:vecMaxs[3]);
stock Entity_GetSpawnFlags(entity);
stock Entity_SetSpawnFlags(entity, flags);
stock Entity_AddSpawnFlags(entity, flags);
stock Entity_RemoveSpawnFlags(entity, flags);
stock Entity_ClearSpawnFlags(entity);
stock bool:Entity_HasSpawnFlags(entity, flags);
stock Entity_Flags:Entity_GetEFlags(entity);
stock Entity_SetEFlags(entity, Entity_Flags:flags);
stock Entity_AddEFlags(entity, Entity_Flags:flags);
stock Entity_RemoveEFlags(entity, Entity_Flags:flags);
stock bool:Entity_HasEFlags(entity, Entity_Flags:flags);
stock Entity_MarkSurrBoundsDirty(entity);
stock Entity_GetFlags(entity);
stock Entity_SetFlags(entity, flags);
stock Entity_AddFlags(entity, flags);
stock Entity_RemoveFlags(entity, flags);
stock Entity_ToggleFlag(entity, flag);
stock Entity_ClearFlags(entity);
stock SolidFlags_t:Entity_GetSolidFlags(entity);
stock Entity_SetSolidFlags(entity, SolidFlags_t:flags);
stock Entity_AddSolidFlags(entity, SolidFlags_t:flags);
stock Entity_RemoveSolidFlags(entity, SolidFlags_t:flags);
stock Entity_ClearSolidFlags(entity);
stock bool:Entity_SolidFlagsSet(entity, SolidFlags_t:flagMask);
stock SolidType_t:Entity_GetSolidType(entity);
stock Entity_SetSolidType(entity, SolidType_t:value);
stock bool:Entity_IsSolid(entity);
stock Entity_GetModel(entity, String:buffer[], size);
stock Entity_SetModel(entity, const String:model[]);
stock Entity_GetModelIndex(entity);
stock Entity_SetModelIndex(entity, index);
stock Entity_SetMaxSpeed(entity, Float:value);
stock Collision_Group_t:Entity_GetCollisionGroup(entity);
stock Entity_SetCollisionGroup(entity, Collision_Group_t:value);
stock Entity_GetAbsOrigin(entity, Float:vec[3]);
stock Entity_SetAbsOrigin(entity, Float:vec[3]);
stock Entity_GetAbsAngles(entity, Float:vec[3]);
stock Entity_SetAbsAngles(entity, Float:vec[3]);
stock Entity_GetLocalVelocity(entity, Float:vec[3]);
stock Entity_SetLocalVelocity(entity, const Float:vec[3]);
stock Entity_GetBaseVelocity(entity, Float:vec[3]);
stock Entity_SetBaseVelocity(entity, const Float:vec[3]);
stock Entity_GetAbsVelocity(entity, Float:vec[3]);
stock Entity_SetAbsVelocity(entity, const Float:vec[3]);
stock bool:Entity_IsLocked(entity);
stock Entity_Lock(entity);
stock Entity_UnLock(entity);
stock Entity_GetHealth(entity);
stock Entity_SetHealth(entity, value, ignoreMax=false, kill=true);
stock Entity_AddHealth(entity, value, ignoreMax=false, kill=true);
stock Entity_TakeHealth(entity, value, ignoreMax=false, kill=true);
stock Entity_GetMaxHealth(entity);
stock Entity_SetMaxHealth(entity, value);
stock Float:Entity_GetDistanceOrigin(entity, const Float:vec[3]);
stock Float:Entity_GetDistance(entity, target);
stock bool:Entity_InRange(entity, target, Float:distance);
stock bool:Entity_EnableMotion(entity);
stock bool:Entity_DisableMotion(entity);
stock Entity_Freeze(entity);
stock Entity_UnFreeze(entity);
stock Entity_PointAtTarget(entity, target, const String:name[]="");
stock Entity_PointHurtAtTarget(entity, target, const String:name[]="");
stock bool:Entity_IsPlayer(entity);
stock Entity_Create(const String:className[], ForceEdictIndex=-1);
stock bool:Entity_Kill(kenny);
stock Entity_KillAllByClassName(const String:className[]);
stock Entity_GetOwner(entity);
stock Entity_SetOwner(entity, newOwner);
stock Entity_GetGroundEntity(entity);
stock bool:Entity_Hurt(entity, damage, attacker=0, damageType=DMG_GENERIC, const String:fakeClassName[]="");
stock Entity_GetParent(entity);
stock Entity_RemoveParent(entity);
stock Entity_SetParent(entity, parentEntity);

// File: files.inc
stock bool:File_GetBaseName(const String:path[], String:buffer[], size);
stock bool:File_GetDirName(const String:path[], String:buffer[], size);
stock bool:File_GetFileName(const String:path[], String:buffer[], size);
stock File_GetExtension(const String:path[], String:buffer[], size);
stock File_AddToDownloadsTable(const String:path[], bool:recursive=true, const String:ignoreExts[][]=_smlib_empty_twodimstring_array, size=0);
stock File_ReadDownloadList(const String:path[]);
stock File_LoadTranslations(const String:file[]);
stock File_ToString(const String:path[], String:buffer[], size);
stock bool:File_StringToFile(const String:path[], String:str[]);
stock bool:File_Copy(const String:source[], const String:destination[]);
stock bool:File_CopyRecursive(const String:path[], const String:destination[], bool:stop_on_error=false, dirMode=493);

// File: game.inc
stock bool:Game_End();
stock bool:Game_EndRound(team=0, bool:forceMapReset=false, bool:switchTeams=false);

// File: general.inc
stock PrecacheMaterial(const String:material[]);
stock bool:IsMaterialPrecached(const String:material[]);
stock PrecacheParticleSystem(const String:particleSystem[]);
stock bool:IsParticleSystemPrecached(const String:particleSystem[]);
stock FindStringIndexByTableName(const String:table[], const String:str[]);
stock FindStringIndex2(tableidx, const String:str[]);
stock LongToIP(ip, String:buffer[], size);
stock IPToLong(const String:ip[]);
stock bool:IsIPLocal(ip);

// File: math.inc
stock any:Math_Abs(any:number);
stock bool:Math_VectorsEqual(Float:vec1[3], Float:vec2[3], Float:tolerance=0.0);
stock any:Math_Min(any:value, any:min);
stock any:Math_Max(any:value, any:max);
stock any:Math_Clamp(any:value, any:min, any:max);
stock bool:Math_IsInBounds(any:value, any:min, any:max);
stock any:Math_Overflow(any:value, any:min, any:max);
stock Math_GetRandomInt(min, max);
stock Float:Math_GetRandomFloat(Float:min, Float:max);
stock Math_GetPercentage(value, all);
stock Float:Math_GetPercentageFloat(Float:value, Float:all);
stock Math_MoveVector(const Float:start[3], const Float:end[3], Float:scale, Float:output[3]);
stock Float:Math_UnitsToMeters(Float:units);
stock Float:Math_UnitsToFeet(Float:units);

// File: server.inc
stock Server_GetIP(bool:public_=true);
stock bool:Server_GetIPString(String:buffer[], size, bool:public_=true);
stock Server_GetPort();
stock bool:Server_GetHostName(String:buffer[], size);

// File: sql.inc
stock SQL_TQueryF(Handle:database, SQLTCallback:callback, any:data, DBPriority:priority=DBPrio_Normal, const String:format[], any:...);
stock SQL_FetchIntByName(Handle:query, String:fieldName[], &DBResult:result=DBVal_Error);
stock bool:SQL_FetchBoolByName(Handle:query, String:fieldName[], &DBResult:result=DBVal_Error);
stock Float:SQL_FetchFloatByName(Handle:query, String:fieldName[], &DBResult:result=DBVal_Error);
stock SQL_FetchStringByName(Handle:query, String:fieldName[], String:buffer[], maxlength, &DBResult:result=DBVal_Error);

// File: strings.inc
stock bool:String_IsNumeric(const String:str[]);
stock String_Trim(const String:str[], String:output[], size, const String:chrs[]=" \t\r\n");
stock String_RemoveList(String:buffer[], String:removeList[][], size, bool:caseSensitive=false);
stock String_ToLower(const String:input[], String:output[], size);
stock String_ToUpper(const String:input[], String:output[], size);
stock String_GetRandom(String:buffer[], size, length=32, const String:chrs[]="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ01234556789");

// File: teams.inc
stock bool:Team_HaveAllPlayers(bool:countFakeClients=true);
stock Team_GetClientCount(team, flags=0);
stock Team_GetClientCounts(&team1=0, &team2=0, flags=0);
stock bool:Team_GetName(index, String:str[], size);
stock bool:Team_SetName(index, const String:name[]);
stock Team_GetScore(index);
stock bool:Team_SetScore(index, score);
stock Team_EdictGetNum(edict);
stock bool:Team_IsValid(index);
stock Team_EdictIsValid(edict);
stock Team_GetEdict(index);
stock Team_GetAnyClient(index);

// File: vehicles.inc
stock Vehicle_GetDriver(vehicle);
stock bool:Vehicle_HasDriver(vehicle);
stock bool:Vehicle_ExitDriver(vehicle);
stock bool:Vehicle_TurnOn(vehicle);
stock bool:Vehicle_TurnOff(vehicle);
stock bool:Vehicle_Lock(vehicle);
stock bool:Vehicle_Unlock(vehicle);
stock bool:Vehicle_IsValid(vehicle);
stock bool:Vehicle_GetScript(vehicle, String:buffer[], size);
stock bool:Vehicle_SetScript(vehicle, String:script[]);

// File: weapons.inc
stock Weapon_GetOwner(weapon);
stock Weapon_SetOwner(weapon, entity);
stock Weapon_IsValid(weapon);
stock Weapon_Create(const String:className[], Float:absOrigin[3], Float:absAngles[3]);
stock Weapon_CreateForOwner(client, const String:className[]);
stock Weapon_GetSubType(weapon, value);
stock bool:Weapon_IsReloading(weapon);
stock Weapon_GetState(weapon);
stock bool:Weapon_FiresUnderWater(weapon);
stock Weapon_SetFiresUnderWater(weapon, bool:can=true);
stock bool:Weapon_FiresUnderWaterAlt(weapon);
stock Weapon_SetFiresUnderWaterAlt(weapon, bool:can=true);
stock Weapon_GetPrimaryAmmoType(weapon);
stock Weapon_GetSecondaryAmmoType(weapon);
stock Weapon_GetPrimaryClip(weapon);
stock Weapon_SetPrimaryClip(weapon, value);
stock Weapon_GetSecondaryClip(weapon);
stock Weapon_SetSecondaryClip(weapon, value);
stock Weapon_SetClips(weapon, primary, secondary);
stock Weapon_GetPrimaryAmmoCount(weapon);
stock Weapon_SetPrimaryAmmoCount(weapon, value);
stock Weapon_GetSecondaryAmmoCount(weapon);
stock Weapon_SetSecondaryAmmoCount(weapon, value);
stock Weapon_SetAmmoCounts(weapon, primary, secondary);
stock Weapon_GetViewModelIndex(weapon);
stock Weapon_SetViewModelIndex(weapon, index);

// File: world.inc
stock World_GetMaxs(Float:vec[3]);



Older Versions / Changelog


smlib 0.11
  • Fixed wrong call to Client_PrintHintText() in Function Client_PrintKeyHintTextToAll()
  • Changed the buffer sizes in the Client_PrintToChat Functions to something greater.
  • Added Functions Client_PrintToConsole(), Client_Print(), Client_Reply()
  • Added Function Client_IsInAdminGroup() (original code taken from Zombie:Reloaded, thanks rhelgeby)
  • Added Functions Client_Mute() and Client_IsMuted()
  • Added Functions Client_MatchesFilter(), Client_Get(), Client_GetRandom()
  • Changed File_AddToDownloadsTable() to work with pathes ending with /
  • Changed Function Team_GetClientCount() to support client filters.
  • Added Function Team_GetClientCounts() (for optimization)
  • Changed some comments
  • Added Function Client_GetNext()
  • Added very useful macro LOOP_CLIENTS
  • Added Function Game_EndRound() (TF2 only atm)
  • Fixed Client_GetChangedButtons in clients.inc
  • Fixed Team_GetEdict() not working in Left4Dead
  • Fixed the fix for Team_GetEdict()
  • Added Macro LOOP_CLIENTWEAPONS()
  • Added Function Client_GetNextWeapon()
  • Added Comments to the Macro and new functions
  • Fixed Function Client_SetScreenOverlayForAll not looping over players correctly (Thanks to Peace-Maker)
  • Optimized strukture of Team_GetEdict() to be a bit more logic.
  • Fixed wrong tag in Function Entity_GetCollisionGroup() (thanks to miniman)
  • Fixed function Client_GiveWeaponAndAmmo() not checking -1 on clips (thanks to Peace-Maker)
  • Fixed function Client_SetMaxSpeed() (thanks to GoD-Tony)
  • Added function Client_GetMapTime() (thanks to GoD-Tony)
  • Fixed functions String_ToLower() & String_ToUpper() (thanks to rhelgeby)
  • Removed double tag in Entity_GetCollisionGroup()
  • Fixed missing CloseHandle() in Function Client_IsLookingAtWall() (thanks to databomb)
  • Added functions File_ToString(), File_StringToFile(), File_Copy() (not fully tested yet)
  • Fixed function File_Copy() (endless loop)
  • Added Function File_CopyRecursive()
  • Added Function Array_Copy()
  • Added Functions Effect_DrawBeamBoxToClient(), Effect_DrawBeamBoxToAll(), Effect_DrawBeamBox() (thanks to Peace-Maker)
  • Added Function Math_Overflow()

smlib 0.10.2 | Download
  • Fixed L4D2/TF2 color settings (reported in IRC)

smlib 0.10.1 | Download
  • Added file concommands.inc
  • Added ConCommand Functions ConCommand_HasFlags(), ConCommand_AddFlags(),
    ConCommand_RemoveFlags() (Thanks to Fatony)
  • Added support for DoD:S nickname coloring to Client_PrintToChatRaw()
  • Added Parameter isChat to all Client_PrintToChat() functions
  • Fixed a bug in color parsing code
  • Enhanced color code and gamedata support
  • Added gamedata/smlib_colors.games.txt (color overriding)

smlib 0.10.0 | Download
  • Renamed Function Client_SetMaxSpeed() to Entity_SetMaxSpeed()
  • Added Function Client_SetMaxSpeed()
  • Changed Client_GetActiveWeaponName() returns now the weapons entity index.
  • Fixed Weapon_SetPrimaryAmmoCount() setting the wrong property.
  • Fixed Weapon_GetPrimaryAmmoCount() getting the wrong property.
  • Added Function Convar_IsValidName(), suggest by FaTony
  • Added File colors.inc
  • Added Function Color_ChatSetSubject()
  • Added Function Color_ChatClearSubject()
  • Added Function Color_ParseChatText()
  • Added Function Color_TagToCode()
  • Added Function Color_GetChatColorInfo()
  • Added Function Color_StripFromChatText()
  • Added Function Client_PrintToChatRaw()
  • Added Function Client_PrintToChat()
  • Added Function Client_PrintToChatAll()
  • Added Function Client_HasAdminFlags()
  • Added Function Math_UnitsToMeters()
  • Added Function Math_UnitsToFeet()
  • Added Function Team_GetAnyClient()
  • Removed Function String_StripChatColors()
  • Enhanced function Team_GetEdict() (added caching)
  • Added wildcard extension suppport to File_AddToDownloadsTable()
  • Fixed some comments
  • Added check to Convar_IsValidName() if name is empty (suggested by FaTony)
  • Added File crypt.inc
  • Added Function Crypt_Base64Encode()
  • Added Function Crypt_Base64Decode()
  • Added Function Crypt_Base64MimeToUrl()
  • Added Function Crypt_Base64UrlToMime()
  • Added Function Crypt_MD5()
  • Added Function Crypt_RC4Encode()
  • Added Function Crypt_RC4EncodeBinary()
  • Added missing Comments to some functions.
  • Added ConVar Handle Caching to all functions (FindConVar is freaking expensive).
  • Updated smlib_test.sp
  • Added Function LongToIP()
  • Added Function IPToLong()
  • Added Function IsIPLocal()
  • math.inc: Fixed Functions Math_UnitsToMeters() and Math_UnitsToMeters()
  • Renamed Function Server_GetIP() to Server_GetIPString()
  • Added Function Server_GetIP (greatly enhanced the IP getting, added parameter public=true, uses the Steamtools function if available)
  • Added MAX_TEAM_NAME_LENGTH in teams.inc

smlib 0.9.7 | Download
  • Added Function String_GetRandom() (A powerful random String generator)
  • Added Constant SIZE_OF_INT
  • Added Parameter "start" to all Array functions
  • Added Functions Entity_GetDistanceOrigin(), Entity_GetDistance()
  • Added Functions Convar_HasFlags(), Convar_AddFlags(), Convar_RemoveFlags()
  • Added File convars.inc
  • Added argument updateMoveType to Function Client_SetObserverMode()
  • Rewrote Function Math_GetRandomInt() (Fixed extremely rare case where the returned value could have been > max), thanks to MatthiasVance
  • Renamed Function Client_HideHud() to Client_SetHideHud()
  • Changed Client_SetThirdPersonMode() to not set the movetype
  • Fixed a bug in the Entity_ Motion functions, thanks to Benjamin
  • Fixed Client_GetLastPlaceName(), thanks to FeuerSturm

smlib 0.9.6 | Download
  • Added Client button stock functions.
  • Created a plugin file smlib_test to compile all functions at once.
  • Fixed a shitload of compile errors / warnings.
  • Added Function Client_IsLookingAtWall()
  • Added Functions Client_GetClass() and Client_SetClass()
  • Corrected some function descriptions
  • Fixed Function Entity_HasSpawnFlags() (missing ()), thanks naris

smlib 0.9.4 | Download
  • Removed unnecessary parameter kill in Function Effect_FadeIn()
  • Added Entity_GetParent()
  • Added Entity_RemoveParent()
  • Added Entity_SetParent()
  • Added Math_MoveVector()
  • Fixed missing any: type at "..." parameters
  • Added missing return in Function Weapon_IsReloading(), thanks to Peace-Maker
  • Redesigned the smlib includes to allow including of single smlib includes and save some milli seconds.

smlib 0.9.3 | Download
  • Added Function String_StripChatColors() (Original code by Psychonic, thanks)
  • Added Functions Math_GetRandomInt() and Math_GetRandomFloat()
  • Added Functions Math_GetPercentage() and Math_GetPercentageFloat()

smlib 0.9.2 | Download
  • Made the argument classname of the Function Entity_FindByName() optional.
  • Added Function Entity_FindByHammerId()
  • Added Function Entity_FindByClassName() for completion.
  • Added Function Math_IsInBounds()
  • Fixed Function File_LoadTranslations()
  • Fixed Effect_DissolveEntity() (it used a wrong netprop).
  • Added parameter dissolveType to Effect_DissolveEntity() and Effect_DissolvePlayerRagDoll()
  • Fixed some comments.
  • Added a few missing comments.

smlib 0.9 | Download
  • Initial release.


Frequently Asked Questions


> What's the best way to publish smlib with my plugin ?

Place a link to this page, together with the version of smlib you used to compile the plugin.

> I have written some stock functions, can I add them to smlib ?

Yes, contact me on the forum or via private message and I will add them.
Be sure they are written cleanly, that means aligned, preferable game/mod independent, documented, and follow the coding standard.