AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011 (https://forums.alliedmods.net/showthread.php?t=148387)

KyleS 02-26-2011 04:27

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Quote:

Originally Posted by psychonic (Post 1423665)
Creating the handle to the convar isn't the slow part; finding the var is.

SM calls FindVar to first make sure the convar exists before looking to see if it already has a handle to it. FindVar iterates through all cvars and commands, doing string compares.

This is why it is slow even if SM already has a handle to it, and thus, why you should still cache the handle.

Do we need to FindConVar every map change? or will once suffice (storing it for the plugins lifetime)?

berni 02-26-2011 04:44

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Quote:

Originally Posted by Kyle12 (Post 1423895)
Do we need to FindConVar every map change? or will once suffice (storing it for the plugins lifetime)?

one time is enough, it's not something that changes on mapchange.

berni 02-26-2011 11:13

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
New smlib update available: smlib 0.10.0 beta
Compatibility breaks: yes

This is a very big release with a powerful chat color parser, allows you to
print colored text message to the chat, it basically works like exvel
' colors.inc, but it is more flexible, faster and supports more colors.
Those are the color tags you can use in eg. Client_PrintToChat() (see colors.inc in the meanwhile):


{N}, {O}, {R}, {RB}, {B}, {BR}, {T}, {L}, {GRA}, {G}, {OG}, {BLA}


More Info on Colors:
Click Me!

Changes:

Quote:

  • 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(), suggested 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 Steam_GetPublicIP() if available)
  • Added MAX_TEAM_NAME_LENGTH in teams.inc

Download here.

Leonardo 02-26-2011 11:25

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
Quote:

Added Function Crypt_MD5()
hurray!

also
Quote:

Renamed Function Server_GetIP() to Server_GetIP()
I don't get it o.o

bl4nk 02-26-2011 17:35

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Quote:

Originally Posted by psychonic (Post 1423665)
SM calls FindVar to first make sure the convar exists before looking to see if it already has a handle to it.

You're right. I only quickly looked over it before and thought that I saw the cache lookup before the FindVar call. My memory isn't what it use to be. :(

Chanz 02-27-2011 06:08

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
Full >90% credit goes to Berni I had have nothing little to do with it. Good job man!

berni 02-27-2011 12:18

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
Quote:

Originally Posted by Chanz (Post 1424650)
Corrected:


Also full credit goes to Berni I had have nothing to do with it. Good job man!

You actually did 4 things of the change list :wink:

and yeh, I was in a hurry yesterday, change list should be fine now 8)

FaTony 02-28-2011 14:28

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
3 more stocks:
PHP Code:

/**
 * Checks if a ConCommand has one or more flags set.
 *
 * @param    command        ConCommand name.
 * @param    flags        Flags to check.
 * @return                True if flags are set, false otherwise.
 */
stock bool:ConCommand_HasFlags(const String:command[], const flags)
{
    return 
bool:(GetCommandFlags(command) & flags);
}

/**
 * Adds one or more flags to a ConCommand.
 *
 * @param    command        ConCommand name.
 * @param    flags        Flags to add.
 * @noreturn
 */
stock ConCommand_AddFlags(const String:command[], const flags)
{
    new 
newFlags GetarFlags(command);
    
newFlags |= flags;
    
SetCommandFlags(commandnewFlags);
}

/**
 * Removes one ore more flags from a ConCommand.
 *
 * @param    command        ConCommand name.
 * @param    flags        Flags to remove
 * @noreturn
 */
stock ConCommand_RemoveFlags(const String:command[], const flags)
{
    new 
newFlags GetCommandFlags(command);
    
newFlags &= ~flags;
    
SetCommandFlags(commandnewFlags);



KawMAN 03-03-2011 05:28

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
Hi,

Please add something like Team_FindByName that return team index of team with specific name or -1 when can't find.

Also in teams.inc function Team_GetEdict(index)
PHP Code:

        if (!Entity_ClassNameMatches(entity"team_manager"true)) {
            return -
1;
        } 

instead "return -1;" should't be "continue;" ?

asherkin 03-03-2011 08:59

Re: SMLIB 0.10.0 BETA (over 300 Function Stocks) | updated 26.02.2011
 
Quote:

Originally Posted by KawMAN (Post 1427000)
Please add something like Team_FindByName that return team index of team with specific name or -1 when can't find.

LOL, at least try searching.

http://docs.sourcemod.net/api/index....d=show&id=501&


All times are GMT -4. The time now is 21:59.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.