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)

Peace-Maker 01-28-2011 03:49

Re: SMLIB 0.9 BETA (266 Function Stocks)
 
When using
PHP Code:

stock bool:Effect_DissolvePlayerRagDoll(client

on player_death i get an error pointing out, that the netprop "dissolvetype" doesn't extist on that entity. You may change it to "m_nDissolveType" or use AcceptEntityInput.
I'm testing in CS:S.

I also often use psychonic's improved GetURandomIntRange(min, max) stock you may want to include?

berni 01-28-2011 11:34

Re: SMLIB 0.9 BETA (266 Function Stocks)
 
New smlib update available: smlib 0.9.2 beta

Compatibility breaks: none

Changes:

Quote:

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.
Download here.

Quote:

Originally Posted by zeroibis (Post 1401345)
I noticed that when using:
Client_SetActiveWeapon(client, weapon);
if you set it to knife you do not see it until you fire.

I couldn't reproduce this behavior, it's working fine for me.
Can you post some example code ? thanks.

naris 01-28-2011 13:28

Re: SMLIB 0.9 BETA (266 Function Stocks)
 
Quote:

Originally Posted by berni (Post 1401243)
hehe, not that easy to understand :wink:
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.

Oh, I understand it, but it still makes me cringe. It is a bit of a bad practice. However I do see the point of not having another parameter that isn't really needed.

naris 01-28-2011 13:39

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.

berni 01-28-2011 15:55

Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
 
Quote:

Originally Posted by naris (Post 1401742)
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.

They are there because otherwise the IDE / Pawnstudio wouldn't be aware of the other functions and not syntax-highlight them. This does not increase compile time since we are using #define checks to make sure every include file gets only compiled one time.

Quote:

Originally Posted by Peace-Maker (Post 1401424)
I also often use psychonic's improved GetURandomIntRange(min, max) stock you may want to include?

Thanks, will include this, but a rewritten version, since this one doesn't work 100%.

berni 01-28-2011 16:39

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:

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

Download here.

naris 01-28-2011 22:31

Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
 
Quote:

Originally Posted by berni (Post 1401834)
They are there because otherwise the IDE / Pawnstudio wouldn't be aware of the other functions and not syntax-highlight them. This does not increase compile time since we are using #define checks to make sure every include file gets only compiled one time.

Actually it DOES increase compile time as it take longer to open, read and compile 274+ stocks in 18 files than it would to compile say, 10 of them in 1 single file, especially if you are compiling a large system. The #define checking just ensure that it does compile and prevents it from parsing and compiling, but not reading, the file multiple times and causing duplicate definition errors.

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.

FaTony 01-29-2011 00:11

Re: SMLIB 0.9.2 BETA (274 Function Stocks) | updated 28.01.2011
 
Reminds me of windows.h.

berni 01-29-2011 00:41

Re: SMLIB 0.9.2 BETA (269 Function Stocks) | updated 28.01.2011
 
Quote:

Originally Posted by naris (Post 1401999)
Actually it DOES increase compile time as it take longer to open, read and compile 274+ stocks in 18 files than it would to compile say, 10 of them in 1 single file, especially if you are compiling a large system. The #define checking just ensure that it does compile and prevents it from parsing and compiling, but not reading, the file multiple times and causing duplicate definition errors.

Did you actually test it or do you just think so ?

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:

#if defined _smlib_included
    #endinput
#endif 

Quote:

Why are you concerned about syntax-highlighting function that are not referenced in the file?
Also wrong, Functions of <sourcemod> and <sdktools> (fake included in smlib.inc) are used in almost every include file.
Again, they aren't really included for the compiler as it will cancel before in smlib.inc.

Quote:

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.
Oh, does VW also use SourcePawn & Pawnstudio ? lol

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.

berni 01-29-2011 01:06

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.


All times are GMT -4. The time now is 13:14.

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