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)

naris 01-31-2011 12:29

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

Originally Posted by berni (Post 1402047)
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

Did you try modifying and including only 1 of the includes, such as #include <smlib/world> or are you continually including EVERYTHING by using #include <smlib>?

Did you try this using a large system where multiple source files need 1 or 2 functions from 1 or 2 files instead of everything? I do not have time to test this at the moment, especially since this is Month End, but I will get back to you when I do.

Quote:

Originally Posted by berni (Post 1402047)
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.

So, #include the files required for those functions (<sourcemod> & <sdktools> and whichever <smlib/*> files that might be required, as you almost did in smlibs/clients.inc (instead of the generic <smlib> include), it's not that difficult.

Quote:

Originally Posted by berni (Post 1402047)
SourcePawn just isn't C++, so we have to take what we get.

While it's true that SourcePawn isn't C++, the basic concepts are the same and are still applicable.

FaTony 01-31-2011 12:41

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
The preprocessor include system is almost the same in both languages.

berni 01-31-2011 12:52

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

Originally Posted by naris (Post 1403830)
Did you try modifying and including only 1 of the includes, such as #include <smlib/world> or are you continually including EVERYTHING by using #include <smlib>?

You should have read the latest update changes, this doesn't need to be discussed anymore.

Quote:

Originally Posted by berni (Post 1403567)
Redesigned the smlib includes to allow including of single smlib includes and save some milli seconds.

And no, I thought he is talking about just removing #smlib out of every include file, and still use #include <smlib> in the plugin.

naris 01-31-2011 12:59

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Doh! :oops:

Sorry about that, Indeed I should of read the last update changes

berni 01-31-2011 13:12

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
By the way, the sourcemod compiler automatically includes <sourcemod> (with all its 60 subincludes), even if you don't have it specified in your plugin.
If you want to complain, I would start there :wink:

naris 01-31-2011 16:42

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
This function needs to be fixed:

PHP Code:

/**
 * Returns whether the entity has specific Spawnflags.
 *
 * @param entity            Entity index.
 * @param flags                Flags value.
 * @return                    True if the entity has the spawnflags set, false otherwise.
 */
stock bool:Entity_HasSpawnFlags(entityflags)
{    
    return 
Entity_GetSpawnFlags flags;



naris 01-31-2011 16:48

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Quote:

Originally Posted by berni (Post 1403869)
By the way, the sourcemod compiler automatically includes <sourcemod> (with all its 60 subincludes), even if you don't have it specified in your plugin.
If you want to complain, I would start there :wink:

Yeah, that's true -- but those are mostly native declarations and not so many stocks.

Also, you usually need to use parts of most of the sourcemod includes in any given plugin while many of the smlib includes are more stand-alone without really needing the others.

naris 01-31-2011 16:58

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
The Entity_Flags look suspect, are EFL_KEEP_ON_RECREATE_ENTITIES and EFL_HAS_PLAYER_CHILD both supposed to be bit 4?

PHP Code:

enum Entity_Flags
{
    
EFL_KILLME =                            (1<<0),    // This entity is marked for death -- This allows the game to actually delete ents at a safe time
    
EFL_DORMANT    =                            (1<<1),    // Entity is dormant, no updates to client
    
EFL_NOCLIP_ACTIVE =                        (1<<2),    // Lets us know when the noclip command is active.
    
EFL_SETTING_UP_BONES =                    (1<<3),    // Set while a model is setting up its bones.
    
EFL_KEEP_ON_RECREATE_ENTITIES =         (1<<4), // This is a special entity that should not be deleted when we restart entities only

    
EFL_HAS_PLAYER_CHILD=                    (1<<4),    // One of the child entities is a player.

    
EFL_DIRTY_SHADOWUPDATE =                (1<<5),    // Client only- need shadow manager to update the shadow... 


Also, you might want to define it as

PHP Code:

enum Entity_Flags (<<= 1)
{


instead of specifying the value for each bit.

berni 01-31-2011 20:34

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Quote:

Originally Posted by naris (Post 1404064)
This function needs to be fixed:

PHP Code:

stock bool:Entity_HasSpawnFlags(entityflags


http://users.alliedmods.net/%7Esawce/crab.gif

Quote:

Originally Posted by naris (Post 1404072)
Also, you usually need to use parts of most of the sourcemod includes in any given plugin while many of the smlib includes are more stand-alone without really needing the others.

Like you say, only parts, I use ~20% of all sm includes in plugins.

Quote:

Originally Posted by naris (Post 1404082)
The Entity_Flags look suspect, are EFL_KEEP_ON_RECREATE_ENTITIES and EFL_HAS_PLAYER_CHILD both supposed to be bit 4?

Also, you might want to define it as

PHP Code:

enum Entity_Flags (<<= 1)
{


instead of specifying the value for each bit.

It looks suspect to me too, I also wondered back then, but we copied it straight from Valve's hl2sdk and it's used there widely,
so I'm quite sure it's correct :wink:
I think it's ok like it is now.

zeroibis 02-01-2011 23:56

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
I just wanted to note that using:
stock Client_GiveWeapon(client, const String:className[], bool:switchTo=true);

will override any restrictions that other mods may have on the weapon.

For example you can use this command to give a zombie weapons in a ZR server. I do not know if this was intended or not. Note however that the normal GivePlayerItem command does not allow zombies to get weapons.

Chanz 02-02-2011 08:18

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
I've never worked with ZR, but if you don't want to give a zombie a weapon, then check if the client is a zombie and don't give it to him.

It would be bad to add an automatic check only for ZR, imagine we need to do this for as example Hide and Seek and every other mod/plugin etc. even if its only for Client_GiveWeapon, its performance would drop extreamly to check these, not to mention the work to keep everything working.

berni 02-02-2011 09:21

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Quote:

Originally Posted by zeroibis (Post 1405086)
For example you can use this command to give a zombie weapons in a ZR server.

It's a Function, not a Command.
I don't know much about ZR either, but the Scripter is responsible himself who he calls this function on,
there are maybe coders who do want to give weapons to zombies, implementing a restriction would be a bad idea.

zeroibis 02-02-2011 15:05

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Oh I am not requesting it be made to work like that I am only stating that functionally it does not work the same as GivePlayerItem() and that programers should be careful which one they use depending on the situation.

Chanz 02-02-2011 16:55

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
well every author needs to be careful even with GivePlayerItem() since you can't just hope that a function is blocked by another plugin. you should always be sure and minimize function calls by filtering out unwanted clients etc.

zeroibis 02-02-2011 17:19

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Question: is Math_GetRandomInt(min, max); inclusive?

In that are min and max possible outputs for this function or only values between them. Same for the Math_GetRamdomFloat...

berni 02-02-2011 17:30

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Quote:

Originally Posted by zeroibis (Post 1405700)
Question: is Math_GetRandomInt(min, max); inclusive?

In that are min and max possible outputs for this function or only values between them. Same for the Math_GetRamdomFloat...

yes, it is inclusive, min and max are also part of the range.

Another note on GivePlayerItem(), this function is not very safe, as it spawns
a weapon or an item at the players position and hopes the player touches it.
If the player is currently inside a wall or does already have that item, the item would be dropped to the floor.

zeroibis 02-02-2011 17:57

Re: SMLIB 0.9.4 BETA (278 Function Stocks) | updated 31.01.2011
 
Cool thanks!

Also yes I know of the GivePlayerItem() issue which is why I strip weapons or check to see if they have what I am giving before use.

berni 02-02-2011 18:46

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
New smlib update available: smlib 0.9.6 beta
Important Note:
SVN folder structure has been changed.

Compatibility breaks: yes

Changes:

Quote:

  • Added Client button stock functions.
  • Created a plugin file smlib_test to compile all functions at once.
  • Fixed a shitload of compile errors / warnings.
  • Added Function Client_IsLookingAtWall()
  • Added Functions Client_GetClass() and Client_SetClass()
  • Corrected some function descriptions
  • Fixed Function Entity_HasSpawnFlags() (missing ()), thanks naris

Download here.

FeuerSturm 02-03-2011 00:36

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Berni, you might want to take a look at this stock in clients.inc:

Code:

/**
 * Gets the name of the last place (if set by the game)
 *
 * @param entity                        Entity index.
 * @param buffer                        String buffer
 * @param size                                Size of the String buffer
 * @noreturn
 */
stock Client_GetLastPlaceName(client, String:buffer[], size)
{
        SetEntPropString(client, Prop_Send, "m_szLastPlaceName", buffer);
}

:wink:

berni 02-03-2011 00:50

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
ok "S" should be "G" :) commited to svn.

FeuerSturm 02-03-2011 00:53

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
and you might want to return the result :stupid:

berni 02-03-2011 00:54

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Please download from the svn repo, thanks :3
can't make a new release for every little change.

naris 02-04-2011 13:09

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Quote:

Originally Posted by berni (Post 1405900)
ok "S" should be "G" :) commited to svn.

Code:

// clients.inc(632) : error 092: number of arguments does not match definition
You also need to add the size parameter to the call.

berni 02-04-2011 22:30

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Slap me hard *sigh* :oops:

updated.

Mitchell 02-05-2011 01:18

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Bug, when using third person you have to set the movement type back, other than that its all good!

thresh0ld 02-05-2011 02:06

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
berni, I appreciate your efforts on this. Thanks for saving me a lot of time writing code :)

berni 02-05-2011 03:10

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Quote:

Originally Posted by Mitchell (Post 1407424)
Bug, when using third person you have to set the movement type back, other than that its all good!

Yeah, changing the observermode to OBS_MODE_DEATHCAM normally
removes your movetype, I added an argument now to disallow it changing the movetype, it's on svn.

I will rewrite this stock someday anyway, to make it work for all games, atm this seems really dirty for me.

KawMAN 02-05-2011 13:41

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
Hi,
To Array_Find[Value|String] Please add search start position.

Thanks.

Benjamin1995 02-07-2011 17:51

Re: SMLIB 0.9.6 BETA (289 Function Stocks) | updated 03.02.2011
 
I found a bug:

Code:


/**
 * Enables the motion of an entity.
 *
 * @param entity                Entity index.
 * @return                                True on success, false otherwise
 */
stock bool:Entity_EnableMotion(entity)
{       
        return AcceptEntityInput(entity, "disablemotion");
}

/**
 * Disables the motion of an entity.
 *
 * @param entity                Entity index.
 * @return                                True on success, false otherwise
 */
stock bool:Entity_DisableMotion(entity)
{
        return AcceptEntityInput(entity, "enablemotion");
}



It's changed.

Regards Benni.

berni 02-08-2011 10:25

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Thanks for the great participation, bug reporting and feature suggestions folks, this really became a powerful library :)

New smlib update available:
smlib 0.9.7 beta

Compatibility breaks: yes

Changes:

Quote:

  • Added Function String_GetRandom() (A powerful random String generator)
  • Added Constant SIZE_OF_INT
  • Added Parameter "start" to all Array functions
  • Added Functions Entity_GetDistanceOrigin(), Entity_GetDistance()
  • Added Functions Convar_HasFlags(), Convar_AddFlags(), Convar_RemoveFlags()
  • Added File convars.inc
  • Added argument updateMoveType to Function Client_SetObserverMode()
  • Rewrote Function Math_GetRandomInt() (Fixed extremely rare case where the returned value could have been > max), thanks to MatthiasVance
  • Renamed Function Client_HideHud() to Client_SetHideHud()
  • Changed Client_SetThirdPersonMode() to not set the movetype
  • Fixed a bug in the Entity_ Motion functions, thanks to Benjamin1995
  • Fixed Client_GetLastPlaceName(), thanks to FeuerSturm & naris

Download here.

Monkeys 02-09-2011 04:29

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Why is Client_SetMaxSpeed part of entities.inc?

berni 02-09-2011 07:38

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

Originally Posted by Monkeys (Post 1410701)
Why is Client_SetMaxSpeed part of entities.inc?

Because we felt like it :mrgreen:

Benjamin1995 02-09-2011 16:39

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
I think that I found a new bug.

Code:


/**
 * Gets the Target name of an other entity
 *
 * @param entity                        Entity index.
 * @param buffer                        Return/Output buffer.
 * @param size                                Max size of buffer.
 * @noreturn
 */
stock GetEntityTargetName(entity, String:buffer[], size)
{
        GetEntPropString(entity, Prop_Data, "m_target", buffer, size);
}


it should be m_iName

Regards Benni.

berni 02-09-2011 17:05

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
The function GetEntityTargetName doesn't even exist in smlib.

+ You are looking for Entity_GetName().

Benjamin1995 02-09-2011 17:08

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Sorry, than it was my fault.
I didn't checked the new version of that function.

Regards Benni.

berni 02-09-2011 17:38

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
There is no new function, it has always been like that.

zeroibis 02-09-2011 23:31

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Great work! Loving this stock list!

Once request: how about a give weapon and amo function so that you can give a weapon and fill it with the default amo you would get it you bought it. This would simplify coding for many people who are just giving a weapon in place of a user buying it.

berni 02-10-2011 06:12

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
Don't weapons have default ammo when you just give them to the player ?

Unfortunately we don't have access to the weapon data in any way,
this includes default ammo, max ammo, fire rates and all that kinda things,
there are no properties for reading that and smlib doesn't do SDKCalls.
The weapon functions are already as powerful as they can be.

That means you have to do any game specific weapon stuff yourself.

Monkeys 02-10-2011 15:49

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

Originally Posted by berni (Post 1410753)
Because we felt like it :mrgreen:

It's annoying!
Here I was looking for it, in clients.inc!

berni 02-10-2011 18:01

Re: SMLIB 0.9.7 BETA (295 Function Stocks) | updated 08.02.2011
 
It's already fixed ;)

We added Entity_SetMaxSpeed also now.


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

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