05.08.2013, 00:49
I have a function that calculates the days hours and minutes left in a persons ban. I noticed once the time variable got above 10 integers, the function literally makes up its own number and doesnt work. Ive debugged the mess out of it and still cant get it working.
Can someone help me fix it?
Can someone help me fix it?
pawn Код:
stock CalculateBanTime(time)
{
new
iTime = gettime(),
String[50],
String2[200];
if(time > iTime)
{
new nTime = time - iTime;
new number[3];
for(new i; i< 40; i++)
{
if(nTime >= 86400)
{
nTime = nTime - 864000;
number[0]++;
}
}
for(new i; i< 40; i++)
{
if(nTime >= 3600)
{
nTime = nTime - 3600;
number[1]++;
}
}
for(new i; i< 30; i++)
{
if(nTime >= 60)
{
nTime = nTime - 60;
number[2]++;
}
}
if(number[0] >= 1)
{
format(String,sizeof(String),"%i Days ",number[0]);
strcat(String2,String,sizeof(String2));
print(String);
}
if(number[1] >= 1)
{
format(String,sizeof(String),"%i Hours ",number[0]);
strcat(String2,String,sizeof(String2));
print(String);
}
if(number[2] >= 1)
{
format(String,sizeof(String),"%i Minutes",number[0]);
strcat(String2,String,sizeof(String2));
print(String);
}
}
else
{
format(String,sizeof(String),"Not Banned");
strcat(String2,String,sizeof(String2));
}
return String2;
}