Raised This Month: $130 Target: $400
 32% 

SMLIB 0.11 BETA (over 300 Function Stocks) | updated 15.07.2011


Post New Thread Reply   
 
Thread Tools Display Modes
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-26-2011 , 08:08   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #11

Quote:
Originally Posted by miniman View Post
1.
PHP Code:
stock (client,  const String:className[]); 
There has been a space between the return type and the functionname, the .inc parser doesn't seeem to like that

Quote:
Originally Posted by AtomicStryker View Post
PHP Code:
Entity_FindByName 
this one uses a classname

PHP Code:
Entity_GetName 
this one a netpropname

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)
Entity_FindByName takes classname and name. Reason is that Sourcemod currently provides no way iterating over the whole entity list (including none-edict ents) without knowing the classname (FindEntityByClassname).

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.
__________________
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; 01-26-2011 at 09:08.
berni is offline
AtomicStryker
Veteran Member
Join Date: Apr 2009
Location: Teutonia!!
Old 01-26-2011 , 08:42   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #12

Quote:
Originally Posted by asherkin View Post
targetname

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
AtomicStryker is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-26-2011 , 08:51   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #13

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).
It's not possible to write a "wrapper" that searches for ALL entities without specifying a classname, it's a Sourcemod Limit. ok nvm, psychonic forces me to use dirty haxx to iterate over all entities without classnames I will consider adding it to the next smlib version.

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.
__________________
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; 01-26-2011 at 10:25.
berni is offline
FaTony
BANNED
Join Date: Aug 2008
Old 01-26-2011 , 15:51   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #14

What? It's simple to iterate all entities to find the matching targetname.
FaTony is offline
zeroibis
Veteran Member
Join Date: Jun 2007
Old 01-27-2011 , 01:11   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #15

This is great, just read over the entire list. I am going to start using this on the very next plugin I make!
__________________
zeroibis is offline
naris
AlliedModders Donor
Join Date: Dec 2006
Old 01-27-2011 , 16:48   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #16

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:
stock File_LoadTranslations(const String:path[])
{
    new 
String:szTranslationsPath[PLATFORM_MAX_PATH];

    
Format(szTranslationsPath,sizeof(szTranslationsPath),"translations/%s",path);
    
BuildPath(Path_SMszTranslationsPathsizeof(szTranslationsPath), "translations/connectspectate.phrases.txt");
    
    if (
FileExists(szTranslationsPath)){
        
LoadTranslations("connectspectate.phrases");
    } 
    else {
        
SetFailState("[%s] Unable to locate translation file (%s).",g_sPlugin_Name,szTranslationsPath);
    } 
naris is offline
naris
AlliedModders Donor
Join Date: Dec 2006
Old 01-27-2011 , 16:56   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #17

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:
/**
 * Removes a list of strings from a string.
 *
 * @param buffer            Input/Ourput buffer.
 * @param maxlen            Max size of buffer.
 * @param removeList        A list of strings which should be removed from buffer.
 * @param size                Number of Strings in the List.
 * @noreturn
 */
stock String_RemoveList(String:buffer[], String:removeList[][], sizebool:caseSensitive=false)
{    
    for (new 
i=0sizei++) {
        
ReplaceString(buffer2147483647removeList[i], ""caseSensitive);
    }

naris is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-27-2011 , 21:12   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #18

Quote:
Originally Posted by naris View Post
This function must not be correct

I would think that "connectspectate.phrases" should be replaced with path and "translations/connectspectate.phrases.txt" with szTranslationsPath.

Thanks we just fixed that and will release a new smlib version shortly.

Quote:
Originally Posted by naris View Post
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!
hehe, not that easy to understand
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.
__________________
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
berni is offline
zeroibis
Veteran Member
Join Date: Jun 2007
Old 01-27-2011 , 23:31   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #19

I noticed that when using:
Client_SetActiveWeapon(client, weapon);
if you set it to knife you do not see it until you fire.
__________________
zeroibis is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 01-27-2011 , 23:39   Re: SMLIB 0.9 BETA (266 Function Stocks)
Reply With Quote #20

I'll try to reproduce this on my testserver, but I think I know already know what is wrong, thx.
__________________
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
berni is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:54.


Powered by vBulletin®
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Theme made by Freecode