View Single Post
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 07-14-2011 , 19:05   Re: SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
Reply With Quote #154

It's time for a new release, we are getting closer to 1.0 stable

New smlib update available:
smlib 0.11 beta


Changes:

Quote:
  • 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()
> Download here <

This release brings a neat feature called "Client Iteration" and Client filters.

Have a look at this example code:

PHP Code:
LOOP_CLIENTS(clientCLIENTFILTER_INGAME) {
    
PrintToServer("Client %N is ingame !"client);

LOOP_CLIENTS is a Pawn Macro Function, which allows to iterate over all
client matching the specified filter quickly and easily.
It is also designed to make as few native calls as possible, getting out
the max performance possible with this (as always ).
"client" is the client index and is only valid during the loop (if this var already exists use another name).

These are the available Clientfilters, they can be combined:

PHP Code:
#define CLIENTFILTER_ALL                0        // No filtering
#define CLIENTFILTER_BOTS            ( 1    << 1  )    // Fake clients
#define CLIENTFILTER_NOBOTS            ( 1    << 2  )    // No fake clients
#define CLIENTFILTER_AUTHORIZED        ( 1 << 3  ) // SteamID validated
#define CLIENTFILTER_NOTAUTHORIZED  ( 1 << 4  ) // SteamID not validated (yet)
#define CLIENTFILTER_ADMINS            ( 1    << 5  )    // Generic Admins (or higher)
#define CLIENTFILTER_NOADMINS        ( 1    << 6  )    // No generic admins
// All flags below require ingame checking (optimization)
#define CLIENTFILTER_INGAME            ( 1    << 7  )    // Ingame
#define CLIENTFILTER_INGAMEAUTH        ( 1 << 8  ) // Ingame & Authorized
#define CLIENTFILTER_NOTINGAME        ( 1 << 9  )    // Not ingame (currently connecting)
#define CLIENTFILTER_ALIVE            ( 1    << 10 )    // Alive
#define CLIENTFILTER_DEAD            ( 1    << 11 )    // Dead
#define CLIENTFILTER_SPECTATORS        ( 1 << 12 )    // Spectators
#define CLIENTFILTER_NOSPECTATORS    ( 1 << 13 )    // No Spectators
#define CLIENTFILTER_OBSERVERS        ( 1 << 14 )    // Observers
#define CLIENTFILTER_NOOBSERVERS    ( 1 << 15 )    // No Observers
#define CLIENTFILTER_TEAMONE        ( 1 << 16 )    // First Team (Terrorists, ...)
#define CLIENTFILTER_TEAMTWO        ( 1 << 17 )    // Second Team (Counter-Terrorists, ...) 
Multiple filters can be combined:

PHP Code:
LOOP_CLIENTS(botCLIENTFILTER_INGAME CLIENTFILTER_BOTS CLIENTFILTER_ALIVE) {
    
PrintToServer("%N is a bot, ingame and alive !"bot);

There are also other functions that supported Clientfilters now: Client_MatchesFilter(), Client_Get(), Client_GetRandom(), Team_GetClientCount()

Another macro that has been added is LOOP_CLIENTWEAPONS which iterates over a client's weapons painless:

PHP Code:
LOOP_CLIENTWEAPONS(clientweaponindex) {
    
PrintToServer("%N has weapon index %d (index %d)"clientweaponindex);

client is the index of the client you want to iterate the weapons.

Enjoy
__________________
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; 07-28-2011 at 11:00.
berni is offline