Raised This Month: $19 Target: $400
 4% 

ConVar Halp - TF2


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Nikey646
Member
Join Date: Apr 2011
Old 04-03-2012 , 22:24   ConVar Halp - TF2
Reply With Quote #1

So pretty much both me and all the admins in my server thought it would be better to create our own plugin for displaying the rules, since we could customize it to our likings.

But none of us have Source Pawn Experience (Derp).

I've gotten it so it will work when typing /rules !rules, but i was hoping to add the ability of a cvar so if the url changes i dnt have to edit the .sp and recompile then reupload, just have to edit a .cfg file with the updated url...

but i cant for the life of me find a way to read the String data on a ConVar....

Heres the current code (Theres nothing disclosing, as because of the default url in the ConVar is google )

Be warn, there are probley more errors then letters within this code (:

PHP Code:
#include <sourcemod>

new Handle:rulesurl

public OnPluginStart()
{
    
RegConsoleCmd("rules"Command_Test)
    
rulesurl CreateConVar("sm_rulesurl""http://google.com""The location of a .txt file with your rules in it (:")
}
 
public 
Action:Command_Test(clientarg)
{
    
    new 
Handle:setup CreateKeyValues("data");
    new 
Handle:cvar GetConVarString(rulesurl)
    
    
KvSetString(setup"title""UnknownAU Music");
    
KvSetNum(setup"type"MOTDPANEL_TYPE_URL);
    
KvSetString(setup"msg"cvar);
    
    
ShowVGUIPanel(client"info"setuptrue);
    
CloseHandle(setup);
    return 
Plugin_Handled;
    

__________________
ğUnAUĞ UnknownAU ğUnAUĞ
A Proud Australian TFDodgeball Server!




Nikey646 is offline
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 04-03-2012 , 22:46   Re: ConVar Halp - TF2
Reply With Quote #2

Change new Handle:cvar = GetConVarString(rulesurl) to:

Code:
decl String:cvar[128];
GetConVarString(rulesurl, cvar, sizeof(cvar));
Also add KvSetNum(setup, "customsvr", 1); if you want a fullscreen window, and decide whether you want semicolons in your code or not since, as of yet, you've used them on some lines and omitted them elsewhere. (If you want to use them, have #pragma semicolon 1 at the very top, so the compiler kicks up a warning if you leave them out.)

Also, you might already know this, but you don't need to link to a text file, your URL could be a full-blown HTML file if you want. Looks much prettier!

Last edited by 11530; 04-03-2012 at 23:00.
11530 is offline
Nikey646
Member
Join Date: Apr 2011
Old 04-03-2012 , 23:09   Re: ConVar Halp - TF2
Reply With Quote #3

Quote:
Originally Posted by 11530 View Post
Change new Handle:cvar = GetConVarString(rulesurl) to:

Code:
decl String:cvar[128];
GetConVarString(rulesurl, cvar, sizeof(cvar));
Also add KvSetNum(setup, "customsvr", 1); if you want a fullscreen window, and decide whether you want semicolons in your code or not since, as of yet, you've used them on some lines and omitted them elsewhere. (If you want to use them, have #pragma semicolon 1 at the very top, so the compiler kicks up a warning if you leave them out.)

Also, you might already know this, but you don't need to link to a text file, your URL could be a full-blown HTML file if you want. Looks much prettier!
Thanks for the huge help!, and derp i always do that while coding .php, then i get an error while trying to view the page xD

Also, .txt is a bad habbit, i ment .html or .php <3
__________________
ğUnAUĞ UnknownAU ğUnAUĞ
A Proud Australian TFDodgeball Server!




Nikey646 is offline
Reply


Thread Tools
Display Modes

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 21:55.


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