Raised This Month: $ Target: $400
 0% 

How do I check if plugin is loaded / command is available?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
FlyveHest
Member
Join Date: Nov 2010
Location: Denmark
Old 11-05-2012 , 08:15   How do I check if plugin is loaded / command is available?
Reply With Quote #1

Hi,

I need to be able to check if another plugin (not mine, and not a library), is available, so I can issue a command that this plugin offers.

How is this possible? I'm looking at GetPluginIterator or FindFirstConCommand, but both seem to be to "advanced", for lack of a better word, I just need to know if a plugin is loaded (I have the name), or if command is available.
__________________
FlyveHest
-
GB.CritVote - Let people vote to en/disable random crits each round

Visit Gladblad Gamers
FlyveHest is offline
mcpan313
Senior Member
Join Date: Mar 2010
Old 11-05-2012 , 09:12   Re: How do I check if plugin is loaded / command is available?
Reply With Quote #2

check another plugin unique convar if exist.

Example CSSDM
PHP Code:
public OnAllPluginsLoaded()
{
    if (
FindConVar("cssdm_version") != INVALID_HANDLE)
    {
        
// do someting.
    
}

__________________
sorry, for my poor english.
mcpan313 is offline
Send a message via MSN to mcpan313
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 11-05-2012 , 09:23   Re: How do I check if plugin is loaded / command is available?
Reply With Quote #3

You might want to give a look to :

http://docs.sourcemod.net/api/index....d=show&id=589&

Which gives you exactly what you ask; but you need a plugin's handle.

However, I personally use GetFeatureStatus with a Native name as second arg. For example (taken from my plugin Kill Assist) :

Code:
g_bUseRankMe = GetFeatureStatus( FeatureType_Native, "RankMe_GivePoint" ) == FeatureStatus_Available;
This check if the function RankMe_GivePoint is available. I take for granted that if such a function exist, than RankMe is present. Pretty neat, however the function itself (GetFeatureStatus) doesn't help if you don't know its existence (should be named "GetNativeStatus" which would be more helpful <.< for new coders). I write too much I'm tired zzzzzzzzzzzzzz.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 11-05-2012 at 09:25.
RedSword is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 11-05-2012 , 09:24   Re: How do I check if plugin is loaded / command is available?
Reply With Quote #4

Well, just check if the command exists.
PHP Code:
if(GetCommandFlags("sm_command") != INVALID_FCVAR_FLAGS)
{
    
// sm_command exists

Yours sincerely
Impact
__________________

Last edited by Impact123; 11-05-2012 at 09:29.
Impact123 is offline
FlyveHest
Member
Join Date: Nov 2010
Location: Denmark
Old 11-05-2012 , 12:25   Re: How do I check if plugin is loaded / command is available?
Reply With Quote #5

Fantastic advice all, thanks a lot, after looking at the options, I went with the convar detection, as it made sense to use the convar value in the script as well.

So now my idle-server-change-map plugin works like a charm.
__________________
FlyveHest
-
GB.CritVote - Let people vote to en/disable random crits each round

Visit Gladblad Gamers
FlyveHest is offline
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 11-05-2012 , 13:15   Re: How do I check if plugin is loaded / command is available?
Reply With Quote #6

Note that convars aren't cleared till the next restart once they have been created.
Thus, if a plugin creates a cvar and then bugs out or is unloaded the check still returns true.

Yours sincerely
Impact
__________________
Impact123 is offline
FlyveHest
Member
Join Date: Nov 2010
Location: Denmark
Old 11-05-2012 , 14:49   Re: How do I check if plugin is loaded / command is available?
Reply With Quote #7

Good to know, then it makes sense to check for the function as well, i'll incorporate that too.
__________________
FlyveHest
-
GB.CritVote - Let people vote to en/disable random crits each round

Visit Gladblad Gamers
FlyveHest is offline
Reply



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 04:52.


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