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)

berni 01-26-2011 08:08

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

Originally Posted by miniman (Post 1399610)
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 (Post 1399624)
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.

AtomicStryker 01-26-2011 08:42

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

Originally Posted by asherkin (Post 1399682)
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

berni 01-26-2011 08:51

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).
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 :twisted: 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.

FaTony 01-26-2011 15:51

Re: SMLIB 0.9 BETA (266 Function Stocks)
 
What? It's simple to iterate all entities to find the matching targetname.

zeroibis 01-27-2011 01:11

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!

naris 01-27-2011 16:48

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:

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 01-27-2011 16:56

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:

/**
 * 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);
    }



berni 01-27-2011 21:12

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

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

zeroibis 01-27-2011 23:31

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.

berni 01-27-2011 23:39

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.


All times are GMT -4. The time now is 10:56.

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