Game Time Help -
JacobSanchez - 15.02.2014
Ok so I want to be able to set my game time so lets say it's 18h:10m:20s, I would want to be able to set it to lets say 19h:20m:0s, How would I do this? I use zcmd and i want it to be set to /tod for the command.
My clock timer
pawn Код:
forward Clock();
public Clock()
{
new string[128];
gettime(thour, tmin, tsec);
new Day, Month, Year;
getdate(Year, Month, Day);
//clock fixes-Fox
new clockfix[4];
if(tsec < 10) format(clockfix, sizeof(clockfix), "0%d", tsec);
else if(tsec >= 10) format(clockfix, sizeof(clockfix), "%d", tsec);
new minfix[4];
if(tmin < 10) format(minfix, sizeof(minfix), "0%d", tmin);
else if(tmin >= 10) format(minfix, sizeof(minfix), "%d", tmin);
new hourfix[4];
if(thour < 10) format(hourfix, sizeof(hourfix), "0%d", thour);
else if(thour >= 10) format(hourfix, sizeof(hourfix), "%d", thour);
format(string, sizeof(string), "~r~~r~Game Time: ~w~%s:%s:%s", hourfix, minfix, clockfix);
TextDrawSetString(TimeTD, string);
foreach(Player, i)
{
if(IsPlayerLoggedIn(i))
{
if(!IsAFK[i])
{
PlayerInfo[i][pDay] = Day;
Seconds[i] ++;
if(Seconds[i] == 60)
{
Seconds[i] = 0;
PlayerInfo[i][pMinutes] ++;
PlayerInfo[i][pTMinutes] ++;
if(PlayerInfo[i][pVIPTemp])
{
PlayerInfo[i][pVIPTemp] --;
if(PlayerInfo[i][pVIPTemp] <= 0)
{
PlayerInfo[i][pVIP] = 0;
PlayerInfo[i][pVIPDay] = 0;
PlayerInfo[i][pVIPMonth] = 0;
PlayerInfo[i][pVIPHour] = 0;
PlayerInfo[i][pVIPTemp] = 0;
format(string, sizeof(string), "AdmWarn: %s's temporary Bronze VIP package has expired.", RPN(i));
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/makevip.log", string);
SendClientMessage(i, COLOR_LIGHTBLUE, " Your temporary Bronze VIP package has expired.");
}
}
}
if(PlayerInfo[i][pVIP])
{
if(Day >= PlayerInfo[i][pVIPDay] && Month >= PlayerInfo[i][pVIPMonth] && !PlayerInfo[i][pVIPTemp])
{
format(string, sizeof(string), "AdmWarn: %s's %s VIP package has expired.", RPN(i), RPVIPN(i));
SendAdminMessage(COLOR_DARKRED, 1, string);
Log("logs/makevip.log", string);
format(string, sizeof(string), " Your %s VIP package has expired.", RPVIPN(i));
SendClientMessage(i, COLOR_LIGHTBLUE, string);
PlayerInfo[i][pVIP] = 0;
PlayerInfo[i][pVIPDay] = 0;
PlayerInfo[i][pVIPMonth] = 0;
PlayerInfo[i][pVIPHour] = 0;
PlayerInfo[i][pVIPTemp] = 0;
}
}
}
}
}
// Paycheck
if(tmin == 0 && tsec <= 4 && PayChecks == 0)
{
SetWorldTime(thour);
Paycheck();
/* Points
for(new idx = 0; idx<MAX_POINTS; idx++)
{
PointBC[idx] = 0;
}
for(new idx = 0; idx < MAX_POINTS; idx++)
{
if(PointInfo[idx][pTime]) PointInfo[idx][pTime] --;
if(!PointInfo[idx][pTime] && !PointBC[idx])
{
PointInfo[idx][pOwner] = 0;
PointInfo[idx][pProfit] = 0;
format(string, sizeof(string), "The {00FF00}%s {FF6347}is available to be captured.", PointInfo[idx][pName]);
SendClientMessageToAll(COLOR_LIGHTRED, string);
DestroyDynamicPickup(PointInfo[idx][pPickup]);
DestroyDynamic3DTextLabel(PointInfo[idx][pText]);
PointInfo[idx][pText] = CreateDynamic3DTextLabel("Point\n/capture", COLOR_WHITE, PointInfo[idx][pX], PointInfo[idx][pY], PointInfo[idx][pZ]+0.3, 15);
}
} */
}
return 1;
}
Re: Game Time Help -
JacobSanchez - 15.02.2014
Ok I have this so far, now when it changes the time/textdraw the time goes back to the old time not the new time set
Please help me! i will rep
pawn Код:
CMD:tod(playerid, params[])
{
new string[128], input1, input2, input3;
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You are not allowed to use command.");
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
if(sscanf(params, "iii", input1, input2, input3)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /tod [hour] [min] [sec]");
if(input1 > 23) return SendClientMessage(playerid, COLOR_GREY, "Hours are between 0 and 23.");
if(input2 > 60) return SendClientMessage(playerid, COLOR_GREY, "Minutes are between 0 and 60.");
if(input3 > 60) return SendClientMessage(playerid, COLOR_GREY, "secounds are between 0 and 60.");
gettime(thour, tmin, tsec);
thour = input1;
tmin = input2;
tsec = input3;
SetWorldTime(input1);
//ServerTime=input1 + input2 + input3;
format(string, sizeof(string), "~r~~r~Game Time: ~w~%d:%d:%d", input1, input2, input3);
TextDrawSetString(TimeTD, string);
format(string, sizeof(string), "AdmWarn: %s has set the time to %d:%d:%d.", RPN(playerid), input1, input2, input3);
SendAdminMessage(COLOR_DARKRED, 1, string);
return 1;
}
Re: Game Time Help -
JacobSanchez - 15.02.2014
BUMP please help me
Re: Game Time Help -
CuervO - 15.02.2014
Kill the Clock timer before using the command and call it again after using the command.
By the way, you can use "%02d" and that will automatically add a 0 if the number is below 10.
Re: Game Time Help -
JacobSanchez - 15.02.2014
How would I kill the timer? Could you give me a example please?
Re: Game Time Help -
CuervO - 15.02.2014
https://sampwiki.blast.hk/wiki/KillTimer
https://sampwiki.blast.hk/wiki/SetTimer
One thing I noticed: the clock is based on a real time clock calculation. Unless you scrap that system, it'll always return to the previous time, unless you change your system time (which wouldn't work in a host)