Hi dudes
well I saw the plugin from Hell Phoenix the Timeleft Hostname Plugin.
now I took his script (I hope this is okey) and rewrite a bit of it.
but now I got no clue how to solve my problem.
This plugin should replace certain strings within the hostname as example:
Half-Life 2 Server nextmap:%nextmap%
the %nextmap% tag should be replaced by the sm_nextmap var.
right now it supports (or should support) %tl% for timeleft and %nm% which stands for nextmap.
Code:
/*
Dynamic Hostname
GitS2125 aka Chanz
Description:
This plugin is a modification from Hell Phoenix's "Timeleft Hostname" plugin. With Dynamic Hostname
you can replace variables within your hostname such things like timeleft or friendlyfire...
Thanks To:
Hell Phoenix for the orginal plugin
and all @ #sourcemod. :P
Versions:
1.0
* First Public Release!
Cvars:
sm_dh_frequency 2.0 - How often in seconds to update the hostname with variables.
*/
#include <sourcemod>
#include <string>
#pragma semicolon 1
#define PLUGIN_VERSION "1.0"
new Handle:cvarTLHNfrequency;
new Handle:TLHNhandle;
new Handle:Hostname;
new String:oldHN[30];
new String:newHN[30];
new String:realHN[30];
new bool:getHN = false;
public Plugin:myinfo =
{
name = "Dynamic Hostname",
author = "GitS2125",
description = "Lets you replace variables within your hostname",
version = PLUGIN_VERSION,
url = "http://www.sourcemod.net/"
};
public OnPluginStart(){
CreateConVar("sm_dh_version", PLUGIN_VERSION, "Dynamic Hostname Version", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
cvarTLHNfrequency = CreateConVar("sm_dh_frequency","5.0","How often in seconds to update the hostname with variables",FCVAR_PLUGIN);
Hostname = FindConVar("hostname");
}
public OnMapStart(){
TLHNhandle = CreateTimer(GetConVarFloat(cvarTLHNfrequency), Update_Hostname, INVALID_HANDLE, TIMER_REPEAT);
}
public Action:Update_Hostname(Handle:timer){
if(getHN == false){
GetConVarString(Hostname, realHN, sizeof(realHN));
getHN = true;
}
newHN = realHN;
//timeleft################
new timeleft;
decl String: time[30];
GetMapTimeLeft(timeleft);
Format(time, sizeof(time),"%d:%02d",(timeleft / 60),(timeleft % 60));
//nextmap############
decl String:nextmap[30];
decl String:next[30];
GetConVarString(FindConVar("sm_nextmap"), nextmap, sizeof(nextmap));
Format(next, sizeof(next),"%s",nextmap);
//replace################################
ReplaceString(newHN, sizeof(newHN), "%tl%", time);
ReplaceString(newHN, sizeof(newHN), "%nm%", next);
SetConVarString(Hostname, newHN);
return Plugin_Continue;
}
public OnMapEnd(){
CloseHandle(TLHNhandle);
SetConVarString(Hostname, oldHN);
}
public OnPluginEnd(){
CloseHandle(TLHNhandle);
SetConVarString(Hostname, oldHN);
}
well please help me.
thank you
Chanz