04.06.2014, 15:04
I personally don't see the point in editing scripts, it'll take you more time to understand the script you're editing than it'll take you making one from scratch. Also, you could've simplified above code easily.
Here's an example, I made this in five minutes using an array instead of 50 variables determining what day/time it is.
time[0] = hours
time[1] = minutes
time[2] = AM/PM
time[3] = day
The above compiles but hasn't been tested. It's just an example though.
Here's an example, I made this in five minutes using an array instead of 50 variables determining what day/time it is.
time[0] = hours
time[1] = minutes
time[2] = AM/PM
time[3] = day
pawn Код:
#include <a_samp>
#include <sscanf2>
#include <zcmd>
new time[4];
public OnPlayerConnect(playerid)
{
SetTimerEx("worldtime", 60000, true, "i", playerid); // 60 sec; realtime
return true;
}
CMD:settime(playerid, params[])
{
new input[7], value, string[20];
if(sscanf(params, "s[7]i", input, value)) return SendClientMessage(playerid, -1, "/settime [hour/minutes] [value]");
if(strcmp(input, "hour", true)) time[0] = value;
else if(strcmp(input, "minutes", true)) time[1] = value;
format(string, sizeof(string), "%s set to %d", input, value);
SendClientMessage(playerid, -1, string);
SetWorldTime(hour);
return true;
}
forward worldtime(playerid);
public worldtime(playerid)
{
new formatx[7];
if(time[1] < 60) // minutes
{
format(formatx, sizeof(formatx), "%d/%d", time[0], time[1]);
// textdraw changes
time[1] += 1;
SetWorldTime(time[0]);
}
else if(time[0] >= 12 || time[1] >= 60) // hours/min changing
{
if(time[0] < 12) time[0] += 1;
else if(time[0] == 12) time[0] = 0;
if(time[2] == 0) time[2] += 1;
else if(time[2] == 1)
{
time[2] = 0;
if(time[3] < 7) time[3] += 1;
else if(time[3] >= 7) time[3] = 1;
}
if(time[2] == 0) format(formatx, sizeof(formatx), "%d/%d AM", time[0], time[1]);
else if(time[2] == 1) format(formatx, sizeof(formatx), "%d/%d PM", time[0], time[1]);
// textdraw changes
time[1] = 0;
SetWorldTime(time[0]);
}
return true;
}