but I did not understand how it would fit into my script ...
Printable View
try
PHP Code:
/*
*/
//precache this somewhere
precacheString(&"tech_date"); //tech_date very long, better "t_d" or "td"
/*
*/
PlayerConnect() //make thread after player connected or logged
{
self.time_hud = newHudElem();
self.time_hud.x = 70;
self.time_hud.y = 460;
self.time_hud.alignX = "left";
self.time_hud.alignY = "top";
self.time_hud.fontScale = 0.8;
self.time_hud.color = (1, 0, 0);
self.time_hud.label = &"tech_date";
index = G_FindConfigstringIndex("tech_date", 1310, 256);
while (1)
{
sendGameServerCommand(self getEntityNumber(), "d " + index + " " + getlocaltime());
wait 5; //rate of update date hud
}
}
Change newHudElem to NewClientHudElem(self);
Make sure you self endon("disconnect") or there will be a lot of threads running after a client disconnects.
do you think this can affect server performance?
--
i made a small change and recompile voron00 libcod
PHP Code:
void gsc_utils_getlocaltime()
{
time_t timer;
struct tm *timeinfo;
time(&timer);
timeinfo = localtime(&timer);
char timestring[256];
strftime(timestring, sizeof(timestring), "%d/%m/%Y %H:%M", timeinfo);
char stripped_time[128];
strncpy(stripped_time, timestring, sizeof(stripped_time));
stripped_time[strlen(timestring) - 1] = '\0';
stackPushString( stripped_time );
}
Why would you copy the output over to a new stringbuffer and return that? Just return the original var...
how can i do this? i have not mastered much yet
stackPushString(timestring);
And drop the stripped_time thing.