Please help with time
#1

I have a small FS that should show you how long are you on server, but it works only for id 0...
Please HELP

Pastebin: http://pastebin.com/f69a1797d


Код:
#include <a_samp>

#define FILTERSCRIPT

#if defined FILTERSCRIPT

forward Time(playerid);
new StartHour[MAX_PLAYERS];
new StartMinute[MAX_PLAYERS];
new StartSecond[MAX_PLAYERS];
new StartTime[MAX_PLAYERS];
new TimeInSeconds[MAX_PLAYERS];

public OnFilterScriptInit()
{
	print("FS 'helpbot' loaded...");
	return 1;
}

#endif

public Time(playerid)
{
	new Hour, Minute, Second, Aktualni;
	gettime(Hour, Minute, Second);
	Aktualni = Hour*3600 + Minute*60 + Second;
	TimeInSeconds[playerid] = Aktualni - StartTime[playerid];
	return 1;
}

public OnPlayerConnect(playerid)
{
	SetTimer("Time", 1000, true);
	gettime(StartHour[playerid], StartMinute[playerid], StartSecond[playerid]);
	StartTime[playerid] = StartHour[playerid]*3600 + StartMinute[playerid]*60 + StartSecond[playerid];
	return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
	if(!strcmp(cmdtext, "/time"))
		{
		new Hour, Minute, Second, string[256], string2[256];
		gettime(Hour, Minute, Second);
		format(string, sizeof(string), "Current time: %d:%d:%d CET / %d:%d:%d GMT", Hour, Minute, Second, Hour - 1, Minute, Second);
		format(string2, sizeof(string), "You are here: 0 hours, 0 minutes and %d seconds", TimeInSeconds[playerid]);
		SendClientMessage(playerid, 0xFFFF00FF, string);
		SendClientMessage(playerid, 0xFFFF00FF, string2);
		return 1;
		}
	return 0;
}
Reply
#2

Instead of using 'SetTimer', try using 'SetTimerEx', check the wiki for the syntax.
Reply
#3

Thank you very much!
Reply
#4

But it's still not working!
Reply
#5

Did you changed:
pawn Код:
SetTimer("Time", 1000, true);
to:
pawn Код:
SetTimerEx("Time", 1000, true, "i", playerid);
?
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)