SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011
https://s3.amazonaws.com/github/ribb...een_007200.png http://www.sourcemodplugins.org/bund...plugins_sm.png
SMLIB (Function Stock Library for Sourcemod) by sourcemodplugins.org http://berni.bcserv.eu/uploads/images/github-icon.png We use Github - Code contributions are welcome! - Read more here http://www.sourcemodplugins.org/bund...urcemod/sm.png 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. http://www.sourcemodplugins.org/bund...quirements.png 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. http://www.sourcemodplugins.org/bund...od/Authors.png Authors: Berni, Chanz and other Github contributors http://www.sourcemodplugins.org/bund.../Downloads.png Download: SMLIB 0.11 BETA License: GNU General Public License 3.0 http://www.sourcemodplugins.org/bund...stallation.png 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/ http://www.sourcemodplugins.org/bund...d/Features.png Function List (More detailed list here): Code:
http://www.sourcemodplugins.org/bund...emod/Todos.png Todo:
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
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. http://www.sourcemodplugins.org/bund...lib_colors.png Legend: ² Colors only available in Teamplay Mode (mp_teamplay 1) ³ The game automatically colors player nicknames into their team colors. Things you should know...
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) |
Re: SMLIB 0.9 BETA (266 Function Stocks)
Very nice.
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
I should not be this excited about stocks! :)
Nice work and thanks for your efforts, already learning a lot just digging through the code! |
Re: SMLIB 0.9 BETA (266 Function Stocks)
Gj, like it :)
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
Nice work! No more need for my own little library:) You're the men!
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
Thanks :wink:
If you guys need anything added, find a bug or have difficulties with something, just ask. |
Re: SMLIB 0.9 BETA (266 Function Stocks)
1.
PHP Code:
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
PHP Code:
PHP Code:
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) |
Re: SMLIB 0.9 BETA (266 Function Stocks)
Quote:
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
Quote:
Quote:
However there is also Edict_FindByName, that doesn't need a classname to be specified, which searches for edicts only, edicts are all entities with index < 2048, it should be what you need :) name == m_iName == targetname, it's all the same. I don't why Valve has chosen such a weird keyvalue name for the entity name, but the keyvalue targetname is just an alias for m_iName. But don't mix this with the entity's classname, that are different functions. |
Re: SMLIB 0.9 BETA (266 Function Stocks)
Quote:
The issue i could see with just calling it that (i know its the same) is that he HAS functions for targetnames. I realize he is just extending the Valve confusion about this, but while he's writing wrappers, could he not add one that loops all entities AND the non-ent edicts for a "name" without classname. Also he should name the function i quoted Entity_FindByClassName |
Re: SMLIB 0.9 BETA (266 Function Stocks)
No, you got it wrong.
Entity_FindByName searches for a name, not classname, but it needs the classname to be specified, otherwise it has no way of finding none-edicts (serverside, logical or brush entities). But I would say if you want to get an entity by it's name, you know its classname mostly too, otherwise use Edict_FindByName(). I don't extend Valve's confusion, I escape it by naming it correctly. |
Re: SMLIB 0.9 BETA (266 Function Stocks)
What? It's simple to iterate all entities to find the matching targetname.
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
This is great, just read over the entire list. I am going to start using this on the very next plugin I make!
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
This function must not be correct :?
I would think that "connectspectate.phrases" should be replaced with path and "translations/connectspectate.phrases.txt" with szTranslationsPath. PHP Code:
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
This function really should have and use the maxlen parameter mentioned in the comment, that is not present in the actual function, instead of the literal 2147483647!
PHP Code:
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
Quote:
Thanks we just fixed that and will release a new smlib version shortly. Quote:
the function is actually right, the comment is just wrong. A size parameter isn't needed, since we we would never make the string bigger, it can only get shorter, that's why we take the max value of an unsigned integer. |
Re: SMLIB 0.9 BETA (266 Function Stocks)
I noticed that when using:
Client_SetActiveWeapon(client, weapon); if you set it to knife you do not see it until you fire. |
Re: SMLIB 0.9 BETA (266 Function Stocks)
I'll try to reproduce this on my testserver, but I think I know already know what is wrong, thx.
|
Re: SMLIB 0.9 BETA (266 Function Stocks)
When using
PHP Code:
I'm testing in CS:S. I also often use psychonic's improved GetURandomIntRange(min, max) stock you may want to include? |
Re: SMLIB 0.9 BETA (266 Function Stocks)
New smlib update available: smlib 0.9.2 beta
Compatibility breaks: none Changes: Quote:
Quote:
Can you post some example code ? thanks. |
Re: SMLIB 0.9 BETA (266 Function Stocks)
Quote:
|
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
It would be a lot better if "#include <smlib>" was omitted from the includes, especially since most of them don't require anything from the others. It would also be better if those that do require other includes included only the one they specifically need.
That was you could include only those headers that you want to actually use without having to include all 266+ stocks. Even if they don't get used they will still increase compile times. |
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
Quote:
Quote:
|
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
New smlib update available: smlib 0.9.3 beta
Compatibility breaks: none Changes: Quote:
|
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
Quote:
Why are you concerned about syntax-highlighting function that are not referenced in the file? Including all of the includes in all of the files is an extremely bad practice. I would never allow anything that does that into our production systems at VW and neither would any of my co-workers. |
Re: SMLIB 0.9.2 BETA (274 Function Stocks) | updated 28.01.2011
Reminds me of windows.h.
|
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
Quote:
I just tried it out for you: Compile time with includes: 1.00 seconds Compile time without: 1.00 seconds It doesn't really read all files in every include, it just reads smlib.inc and cancels at the second line: PHP Code:
Quote:
Again, they aren't really included for the compiler as it will cancel before in smlib.inc. Quote:
Believe me, I wouldn't do it if there would be a more beautiful way, but SourcePawn just isn't C++, so we have to take what we get. And Syntax Highlighting and Autocompletion makes the Development of smlib just way easier. |
Re: SMLIB 0.9.2 BETA (274 Function Stocks) | updated 28.01.2011
Woops, I think I'm already too long awake lol.
I'll rethink this tomorrow when I'm well-rested again. Actually it could work when we only include the headers when we are working on the include file. |
Re: SMLIB 0.9.2 BETA (274 Function Stocks) | updated 28.01.2011
PHP Code:
|
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
So I am guessing these new random value functions are more random than stock ones like: GetRandomInt() or GetRandomFloat()
Also the math_clamp does actually redefine the value to min or max if it is out of bounds right? |
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
Quote:
I tried psychonic's function first, but that wasn't completely random, so I rewrote it and made some tests to make sure each value has the same chance of being returned. Quote:
smlib 0.9.4 will be released today. |
Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
Quote:
|
Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
FaTony, your trolling slowly becomes annoying.
We all know that 100% randomness doesn't exist in the universe (chaos theory). it's as random as it can be now in a sourcemod, and from a relative point of view that's 100%, not gonna debate this further. |
Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
New smlib update available: smlib 0.9.4 beta
Compatibility breaks: Removed argument of Effect_FadeIn() Changes: Quote:
|
Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
Quote:
|
Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
If it is random enough to give equal chance to all values in a few thousand runs that is a lot better than what we had before.
Also he said "random as it can be now" in that it is as random as it can be given the time. In order to achieve true randomness you will need to wait for an infinite duration for the now to apply for infinite randomness. So after infinite time is spent creating an infinity random random generator you can then evaluate if it is truly random. (I will try to be placed in suspended animation prior to death to await your results) On another note I was wondering about effectiveness of the float version when used with decimal percentage values. For example: Math_GetRandomFloat(0.0,1.0)<=0.23 Is this fine, totally wrong or should I be saying 0.00,1.00 or something to improve accuracy? |
Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
Infinite pseudo randomness =/= true randomness to me.
|
Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
Quote:
I don't know what exactly you mean, it will always have the same effectiveness. |
All times are GMT -4. The time now is 20:16. |
Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.