Raised This Month: $40 Target: $400
 10% 

SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-24-2011 , 20:56   SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #1



SMLIB (Function Stock Library for Sourcemod) by sourcemodplugins.org



We use Github - Code contributions are welcome! - Read more here

About SMLIB

SMLib is a collection of over 300 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 here.
Protobuf support was added to the master branch on GIT (Sourcemod 1.5). If you want to support older sourcemod versions you have to put this into your plugin, or ask the people to update their Sourcemod to 1.5.

Feel free to add or suggest new functions for smlib in this thread.
I'll try to add it to smlib then.

Authors: Berni, Chanz and other Github contributors

Download:
SMLIB 0.11 BETA

License: GNU General Public License 3.0

Installation
:

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.

How To's:


Sourcemod Web IDE:

A Web-Based IDE/Compiler is available, it is able to compile plugins that include smlib or other extensions.
It has syntax highlighting and error/warning output formatting and line highlighting, check it out

Link: http://www.sourcemodplugins.org/smwebide/


Function List (More detailed list here):
Code:

// 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]);


Todo:

  • Add support for own include files to the Web IDE
  • Dynamic Javascript-API Page
  • Add template files for editors to smlib.
  • Add Chanz's plugin manager to smlib.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 02-10-2013 at 13:45.
berni is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-24-2011 , 21:01   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #2

SMLib Colors API

The smlib colors API is a very powerful system for coloring the chat,
written to be as flexible as possible (alternative colors, color overriding) while keeping an
eye on performance. It should be almost as fast as Sourcemod's native PrintToChat. It also
uses some caching techniques which means smlib's Client_PrintToChatAll() can be even faster than sourcemod's native.

Here are the color tags you can use with Color_ParseChatText() and all Client_PrintToChat() functions.

This table shows the default/hardcoded into smlib settings, but they
can be overriden by placing a smlib_colors.games.txt into the gamedata folder.



Legend:
Colors only available in Teamplay Mode (mp_teamplay 1)
The game automatically colors player nicknames into their team colors.


Things you should know...

  • Only one team/subject color can be used in one message, this doesn't mean you can color only one phrase, that means you can only use red or blue or green in one print.
  • The team specific subject colors (eg.: red, blue) are only used if at least one client is in that team that has the color, if not, the alternative color is used.
  • the {RB} and {BR} tags use either Red or Blue for coloring, depending on if a team has clients in it, if all teams are empty, green is used by default.
  • Colors that are unavailable are replaced with green by default.
Overriding the default color settings

File: gamedata/smlib_colors.games.txt

The color settings can be overriden with a gamedata file, while this shouldn't be necessary
for games like TF2, CS:S, HL2:DM, L4D(2), DOD:S, this can be very useful for older games or
upcoming games like Portal 2.

There comes a gamedata file with smlib that has the default settings for the games mentioned above,
if SayText2 isn't supported, smlib automatically disables team/subject colors itself.
Note that you don't have to distribute this file for colors to work in most cases.

Valid colors are:

"normal"
"orange"
"red"
"redblue"
"blue"
"bluered"
"team"
"lightgreen"
"gray"
"green"
"olivegreen"
"black"

Valid keyvalues are:

color_code Color Code (1 - 8)
color_alternative Defines the index of alternative color (see the chatColorInfo array in colors.inc)
color_supported Set to "true" if the color is supported, "false" otherwise.
color_subjecttype (see ChatColorSubjectType enum in colors.inc, any value higher than 0 defines a team color)
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 09-30-2012 at 18:13.
berni is offline
recon0
Veteran Member
Join Date: Sep 2007
Location: US
Old 01-25-2011 , 00:35   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #3

Very nice.
__________________
recon0 is offline
dirtyminuth
Senior Member
Join Date: Sep 2009
Old 01-25-2011 , 01:17   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #4

I should not be this excited about stocks!

Nice work and thanks for your efforts, already learning a lot just digging through the code!
__________________
dirtyminuth is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 01-25-2011 , 12:39   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #5

Gj, like it
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Peace-Maker
SourceMod Plugin Approver
Join Date: Aug 2008
Location: Germany
Old 01-25-2011 , 13:33   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #6

Nice work! No more need for my own little library You're the men!
__________________
Peace-Maker is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-25-2011 , 13:55   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #7

Thanks

If you guys need anything added, find a bug or have difficulties with something, just ask.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
miniman
Senior Member
Join Date: Aug 2009
Location: Israel
Old 01-26-2011 , 03:29   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #8

1.
PHP Code:
stock (client,  const String:className[]); 
2. Its AWESOME
miniman is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 01-26-2011 , 04:02   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #9

PHP Code:
Entity_FindByName 
this one uses a classname

PHP Code:
Entity_GetName 
this one a netpropname


Also, you don't actually have a "FindEntityByNetpropName" function, maybe add that.
(netpropname is m_iName .. i don't know what better to call it)
AtomicStryker is offline
asherkin
SourceMod Developer
Join Date: Aug 2009
Location: OnGameFrame()
Old 01-26-2011 , 06:36   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #10

Quote:
Originally Posted by AtomicStryker View Post
(netpropname is m_iName .. i don't know what better to call it)
targetname
__________________
asherkin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 12:33.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode