AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   general Problem with Sourcemod (https://forums.alliedmods.net/showthread.php?t=277277)

UeberDaniel 01-05-2016 23:48

general Problem with Sourcemod
 
Hi,
ive a simple Problem on my first!! plugin....
The Goal is to get a plugin that gets the sv_tags cvar and compare it to a given Server config cvar-tag; for example: "sm_tct_0" = "hallo" and loads the specifig config for that sm_tct_0 cvar f. e. ServerConfig0.cfg.

here is my first Version(you can ignore the new strings on start, theyre for later using)

The first versin of the Plugin will be built up to 20 configs which you can load 20 configs @ 20 tags u give.

sry for my english im german and not proud for my school grades in english.

Code:

/*
 *  Server Tags
 * Written by dany666 ([email protected])
 *
 * Licensed under the GPL version 2 or above
 */

#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION "0.1"

// CVars
new Handle:g_cvarConf = INVALID_HANDLE;
new Handle:g_cvarTag0 = INVALID_HANDLE;
new Handle:g_cvarTag0f = INVALID_HANDLE;
new Handle:g_cvarTag0T = INVALID_HANDLE;

new String:Tag0[128];
new String:Tag1[128];
new String:Tag2[128];
new String:Tag3[128];
new String:Tag4[128];
new String:Tag5[128];
new String:Tag6[128];
new String:Tag7[128];
new String:Tag8[128];
new String:Tag9[128];
new String:Tag10[128];
new String:Tag11[128];
new String:Tag12[128];
new String:Tag13[128];
new String:Tag14[128];
new String:Tag15[128];
new String:Tag16[128];
new String:Tag17[128];
new String:Tag18[128];
new String:Tag19[128];


public Plugin:myinfo =
{
        name = "TagConfig",
        author = "Dany666",
        description = "Tags TEST",
        version = PLUGIN_VERSION,
       
}

public OnPluginStart() {
        g_cvarConf = CreateConVar("sm_tc_on", "1", "Enables TagConfig Plugin."); /* Activate the Plugin */
                       
        g_cvarTag0 = CreateConVar("sm_tct_0", "hallo", "get Alias for: Tag0Alias"); /*get the cvar for sm_tct_0 config" */
        g_cvarTag0T = CreateConVar("sm_tct_0T", "test", "Tag0test");

/*-------------------------------------Configs--------------------------------------------------*/                       
        g_cvarTag0f = CreateConVar("sm_tcf_h", "ServerConfig0.cfg", "exec the config:Tag0 Config"); /* exec ServerConfig0.cfg if "sm_tct_0" = "hallo" */


        AutoExecConfig(true, "plugin.TagConfig");
                    PrintToServer("halloa1");

        if (GetConVarBool(g_cvarConf))
                        {
                PrintToServer("halloa2");

/*--------------------------------------Get Tags------------------------------------------------*/
                new Handle:cvTag = FindConVar("sv_tags"); //sv_tags -> cvTag
            new String:sTag[255];
            new String:sTag2[255];
 GetConVarString(cvTag, sTag[255], 255);

 GetConVarString(g_cvarTag0, sTag2[255], 255);
 PrintToServer(sTag);
 PrintToServer(sTag2); 
            if (StrContains(sTag, sTag2, true))
            {
                PrintToServer("halloa3");
            new String:sGeht[255];
            sGeht = "geht";
  SetConVarString(g_cvarTag0T, sGeht);
      ServerCommand("exec halo.cfg");
                        }
                                       
                        }

                        }

its allready a test and im new in programming so dont judge me now :D

for Tests ive the "PrintToServer("halloa1");", "PrintToServer("halloa2");" and "PrintToServer("halloa3");"

The first Problem is that the plugin is not working....^^
The second is thats the
"PrintToServer(sTag);"
"PrintToServer(sTag2);"
are not working.

but what im allready not get is how; if i make
Code:

g_cvarTag0 = CreateConVar("sm_tct_0", "hallo", "get Alias for: Tag0Alias");
and
Code:

new String:sTag2[255];
and
Code:

GetConVarString(g_cvarTag0, sTag2[255], 255);
and
Code:

PrintToServer(sTag2);
it prints "allo"
and
Code:

PrintToServer(sTag);
prints nothing....
soooo, why it prints allo and not hallo?
Thats my first Problem.

pls help me to learn Pawn:D
maybe i can help someone else if he has Problems...

my test Server is running Contagion with sourcemod.

Greetings,

Dany666

WildCard65 01-06-2016 08:12

Re: general Problem with Sourcemod
 
Quote:

Originally Posted by Dany666 (Post 2380455)
Code:

GetConVarString(g_cvarTag0, sTag2[255], 255);

That should be:
PHP Code:

GetConVarString(g_cvarTag0sTag2sizeof(sTag2)); 

Edit: Also your code in unreadable(spaces are not in sync)

UeberDaniel 01-07-2016 11:29

Re: general Problem with Sourcemod
 
okay, now i changed it to
Code:

GetConVarString(g_cvarTag0, sTag2, sizeof(sTag2));
and its working :)

But there is still the Problem with Printing the vs_tags in the console:
Code:

            new Handle:cvTag = FindConVar("sv_tags"); //sv_tags -> cvTag
            new String:sTag[255];
            GetConVarString(cvTag, sTag, sizeof(sTag));
            PrintToServer(sTag);

It Prints still nothing...so whats the Problem in this part of the Code?^^

WildCard65 01-07-2016 14:19

Re: general Problem with Sourcemod
 
Any errors in the console?

UeberDaniel 01-07-2016 16:09

Re: general Problem with Sourcemod
 
1 Attachment(s)
nope, just an empty line:

This Part is also working i think

Code:

            if (StrContains(sTag, sTag2, true))
            {
                PrintToServer("halloa3");
            }


Powerlord 01-07-2016 16:22

Re: general Problem with Sourcemod
 
Don't use OnPluginStart to check cvars. You can't guarantee that they're set until OnConfigsExecuted is called (which is called after every map change).

UeberDaniel 01-08-2016 11:54

Re: general Problem with Sourcemod
 
I Edited it again with "public OnConfigsExecuted()" but now nothing is working, no single print in the Console or any feedback :/ so what im doing wrong? :cry:
Heres my new Code:
PHP Code:

/*
 *  Server Tags
 * Written by dany666 ([email protected])
 *
 * Licensed under the GPL version 2 or above
 */

#pragma semicolon 1

#include <sourcemod>

#define PLUGIN_VERSION "1.0"

// CVars
new Handle:g_cvarConf INVALID_HANDLE;
new 
Handle:g_cvarTag0 INVALID_HANDLE;
new 
Handle:g_cvarTag0f INVALID_HANDLE;
new 
Handle:g_cvarTag0T INVALID_HANDLE;

new 
String:Tag0[128];

public 
Plugin:myinfo =
{
    
name "TagConfig",
    
author "Dany666",
    
description "Tags TEST",
    
version PLUGIN_VERSION,
    
}

public 
OnPluginStart()     
{
    
g_cvarConf CreateConVar("sm_tc_on""1""Enables TagConfig Plugin.");
            
    
g_cvarTag0 CreateConVar("sm_tct_0""hallo""Tag0Alias");
    
g_cvarTag0T CreateConVar("sm_tct_0T""test""Tag0test");

/*-------------------------------------Configs--------------------------------------------------*/            
    
g_cvarTag0f CreateConVar("sm_tcf_h""ServerConfig2.cfg""Tag0 Config");
    
AutoExecConfig(true"plugin.TagConfig");
}

public 
OnConfigsExecuted()
{

        
PrintToServer("halloa1");
    if (
GetConVarBool(g_cvarConf))
    {
        
PrintToServer("halloa2");
/*--------------------------------------Get Tags------------------------------------------------*/
    
new Handle:cvTag FindConVar("sv_tags"); //sv_tags -> cvTag
        
new String:sTag[255];
        new 
String:sTag2[255];
     
GetConVarString(cvTagsTagsizeof(sTag));
    
GetConVarString(g_cvarTag0sTag2sizeof(sTag2));
     
PrintToServer(sTag);
     
PrintToServer(sTag2);  
        if (
StrContains(sTagsTag2true))
                {
                
PrintToServer("halloa3");
                new 
String:sGeht[255];
                
sGeht "geht";
          
SetConVarString(g_cvarTag0TsGeht);
             
ServerCommand("exec halo.cfg");
        }
    }



UeberDaniel 01-10-2016 15:55

Re: general Problem with Sourcemod
 
hey guys ive a update,
It seems like the "OnConfigsExecuted" is not working in Contagion...This would also explain why some plugins dont work with this game.

Ive tried it now with a Timer:
PHP Code:

public OnPluginStart()     
{
    
g_cvarConf CreateConVar("sm_tc_on""1""Enables TagConfig Plugin.");
            
    
g_cvarTag0 CreateConVar("sm_tct_0""hallo""Tag0Alias");
    
g_cvarTag0T CreateConVar("sm_tct_0T""test""Tag0test");

/*-------------------------------------Configs--------------------------------------------------*/            
    
g_cvarTag0f CreateConVar("sm_tcf_h""ServerConfig2.cfg""Tag0 Config");
    
AutoExecConfig(true"plugin.TagConfig");
    
CreateTimer(10.0Timer_GetTags);
}

public 
Action Timer_GetTags(Handle timer)
{

    
PrintToServer("halloa1");
    if (
GetConVarBool(g_cvarConf))
    {
    
PrintToServer("halloa2");
/*--------------------------------------Get Tags------------------------------------------------*/
    
new Handle:cvTag FindConVar("sv_tags"); //sv_tags -> cvTag
        
new String:sTag[255];
        new 
String:sTag2[255];
     
GetConVarString(cvTagsTagsizeof(sTag));
    
GetConVarString(g_cvarTag0sTag2sizeof(sTag2));
     
PrintToServer(sTag);
     
PrintToServer(sTag2);  
        if (
StrContains(sTagsTag2true))
            {
                
PrintToServer("halloa3");
                new 
String:sGeht[255];
                
sGeht "geht";
          
SetConVarString(g_cvarTag0TsGeht);
             
ServerCommand("exec halo.cfg");
        }
    }


And...its Working :D:D
But now the Problem is: The Server is Hibernating at Startup and so the timer will start running only if a Player is joining the Server.

My question is: Is there a similar call to "OnConfigsExecuted" or any way to delay the Hibernating Status of the Server?


All times are GMT -4. The time now is 16:41.

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