AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [TF2] Addcond (https://forums.alliedmods.net/showthread.php?t=98542)

devicenull 07-27-2009 21:35

Re: [TF2] Addcond
 
No, please remove all the sv_cheats handling. That is unnecessary once you have removed the FCVAR_CHEATS flag, and opens the server up to a number of security issues. I see many servers a day exploited because they had cheats on.. plugins should never toggle it to use various features.

pheadxdll 07-28-2009 01:44

Re: [TF2] Addcond
 
Can't get this working without blacking out my server. (Works, just induces darkness)

I've tried removing the cheat flags on addcond with no luck. Anybody get this working?

MikeJS 07-28-2009 04:33

Re: [TF2] Addcond
 
Quote:

Originally Posted by devicenull (Post 883499)
No, please remove all the sv_cheats handling. That is unnecessary once you have removed the FCVAR_CHEATS flag, and opens the server up to a number of security issues. I see many servers a day exploited because they had cheats on.. plugins should never toggle it to use various features.

FindConVar won't find addcond (it's similar to nextmap/timeleft etc) so you can't remove the flag how you would for other commands.

bl4nk 07-28-2009 15:58

Re: [TF2] Addcond
 
Try something like this:
PHP Code:

stock bool:AddCond(clientcond)
{
    
    
decl String:name[64];
    new 
Handle:cvarbool:isCommandflagsHandle:convar;
    
    
cvar FindFirstConCommand(namesizeof(name), isCommandflags);
    if (
cvar == INVALID_HANDLE)
    {
        return 
false;
    }

    do
    {
        if (!
isCommand)
        {
            continue;
        }

        if (
strcmp(name"addcond") == 0)
        {
            
SetConVarFlags(cvarflags|~FCVAR_CHEAT);
            
FakeClientCommand(client"addcond %i"cond);
            
SetConVarFlags(cvarflags);
            return 
true;
        }
    } while (
FindNextConCommand(cvarnamesizeof(name), isCommandflags));

    return 
false;
}

stock bool:RemoveCond(clientcond)
{
    
    
decl String:name[64];
    new 
Handle:cvarbool:isCommandflagsHandle:convar;
    
    
cvar FindFirstConCommand(namesizeof(name), isCommandflags);
    if (
cvar == INVALID_HANDLE)
    {
        return 
false;
    }

    do
    {
        if (!
isCommand)
        {
            continue;
        }

        if (
strcmp(name"removecond") == 0)
        {
            
SetConVarFlags(cvarflags|~FCVAR_CHEAT);
            
FakeClientCommand(client"removecond %i"cond);
            
SetConVarFlags(cvarflags);
            return 
true;
        }
    } while (
FindNextConCommand(cvarnamesizeof(name), isCommandflags));

    return 
false;


They should return true on success, false on failure (couldn't find cvar list or couldn't find cmd).

pheadxdll 07-28-2009 16:06

Re: [TF2] Addcond
 
Did not work blank. :( No fail states occurred.

I haven't had any success calling CTFPlayerShared::AddCond(int, float) either. Lots of server crashes. So I would be happy if someone got this working. :3

CrimsonGT 07-28-2009 23:56

Re: [TF2] Addcond
 
The CTFPlayerShared::AddCond works fine from a MMS plugin. If your trying to do it with an SDKCall thats your problem, you cant make SDKCalls with CTFPlayerShared functions.

pheadxdll 07-29-2009 00:16

Re: [TF2] Addcond
 
Quote:

Originally Posted by CrimsonGT (Post 884529)
The CTFPlayerShared::AddCond works fine from a MMS plugin. If your trying to do it with an SDKCall thats your problem, you cant make SDKCalls with CTFPlayerShared functions.

Orly. Well, now I know, thanks Crimson! :grrr:

DontWannaName 07-29-2009 02:10

Re: [TF2] Addcond
 
and knowing is half the battle!

pheadxdll 07-29-2009 04:51

Re: [TF2] Addcond
 
Much to my surprise, I got it working via an MM:S plugin. :D The float value is the toggle between on and off. 0 is off and any thing greater turns on a condition.

A lot of neat stuff you can do with this. That said, I'm surprised a native for AddCond hasn't been introduced into the tf2 extension. I had to make my own. :mrgreen:

Chris-_- 07-29-2009 17:18

Re: [TF2] Addcond
 
Care to post an extension providing the native for plugins? *anyone*


All times are GMT -4. The time now is 18:44.

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