Raised This Month: $51 Target: $400
 12% 

general Problem with Sourcemod


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-05-2016 , 23:48   general Problem with Sourcemod
Reply With Quote #1

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

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
maybe i can help someone else if he has Problems...

my test Server is running Contagion with sourcemod.

Greetings,

Dany666
__________________


Last edited by UeberDaniel; 01-06-2016 at 00:27.
UeberDaniel is offline
Send a message via MSN to UeberDaniel
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-06-2016 , 08:12   Re: general Problem with Sourcemod
Reply With Quote #2

Quote:
Originally Posted by Dany666 View Post
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)

Last edited by WildCard65; 01-06-2016 at 08:13.
WildCard65 is offline
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-07-2016 , 11:29   Re: general Problem with Sourcemod
Reply With Quote #3

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?^^
__________________


Last edited by UeberDaniel; 01-07-2016 at 11:30.
UeberDaniel is offline
Send a message via MSN to UeberDaniel
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 01-07-2016 , 14:19   Re: general Problem with Sourcemod
Reply With Quote #4

Any errors in the console?
WildCard65 is offline
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-07-2016 , 16:09   Re: general Problem with Sourcemod
Reply With Quote #5

nope, just an empty line:

This Part is also working i think

Code:
    	if (StrContains(sTag, sTag2, true))
            {
                PrintToServer("halloa3");
            }
Attached Thumbnails
Click image for larger version

Name:	console.PNG
Views:	206
Size:	9.0 KB
ID:	151008  
__________________


Last edited by UeberDaniel; 01-07-2016 at 16:13.
UeberDaniel is offline
Send a message via MSN to UeberDaniel
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 01-07-2016 , 16:22   Re: general Problem with Sourcemod
Reply With Quote #6

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).
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-08-2016 , 11:54   Re: general Problem with Sourcemod
Reply With Quote #7

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?
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 is offline
Send a message via MSN to UeberDaniel
UeberDaniel
AlliedModders Donor
Join Date: Dec 2009
Location: Germany
Old 01-10-2016 , 15:55   Re: general Problem with Sourcemod
Reply With Quote #8

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
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?
__________________

UeberDaniel is offline
Send a message via MSN to UeberDaniel
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 09:10.


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