How to substract one integer value from other one -
IgrexolonO - 26.01.2013
Hai! I've got two integers:
#1 playerInfo[playerid][oTime] = 1359206440;
#2 time = 1359206445.
Now I want to substract playerInfo's value from time. How can I do this??
Re: How to substract one integer value from other one -
Vince - 26.01.2013
Don't they teach you this in primary school? Seriously ...
Re: How to substract one integer value from other one -
IgrexolonO - 26.01.2013
Quote:
Originally Posted by Vince
Don't they teach you this in primary school? Seriously ...
|
Your seriously is not seriously for me. Maybe something is fucked up, but I'm trying to substract it for 2 days.
When player logs in I'm setting his onlineTime using gettime():
Код:
playerInfo[pid][onlineTime] = gettime();
printf("Time logged in: %i", playerInfo[pid][onlineTime]);
It's fine until I won't compare it with real time later.
Код:
new time = gettime();
printf("%i %i", playerInfo[id][onlineTime], time);
format(formats, sizeof(formats), "Czas gry: %i m", (playerInfo[id][onlineTime] - time));
TextDrawSetString(specShowInfo[id][1], formats);
[14:20:40] Time logged in: 1359206440
[14:20:44] 0 1359206444
Re: How to substract one integer value from other one -
SmithR - 26.01.2013
Instead of talking like real people you keep complaining about one's knowledge.
Re: How to substract one integer value from other one -
Babul - 26.01.2013
nvm, delete please.
or not: the [id] parameter when getting the players time - are you SURE it has to be playerid? not id, playerid or pid?
is the cell called within the same callback? i dont assume so, since there are 3 playerid-representations...
Re: How to substract one integer value from other one -
Threshold - 26.01.2013
Maybe you would want to change:
pawn Код:
(playerInfo[id][onlineTime] - time)
to:
pawn Код:
(time - playerInfo[id][onlineTime])
?? :S
Re: How to substract one integer value from other one -
IgrexolonO - 26.01.2013
Quote:
Originally Posted by BenzoAMG
Maybe you would want to change:
pawn Код:
(playerInfo[id][onlineTime] - time)
to:
pawn Код:
(time - playerInfo[id][onlineTime])
?? :S
|
Thank you. I did it before you posted it. The problem is playerInfo[id][onlineTime] always gives 0. I don't know why.
Re: How to substract one integer value from other one -
SchurmanCQC - 26.01.2013
Quote:
Originally Posted by IgrexolonO
Thank you. I did it before you posted it. The problem is playerInfo[id][onlineTime] always gives 0. I don't know why.
|
Very simple math. Like seriously...grade school.
Re: How to substract one integer value from other one -
IgrexolonO - 26.01.2013
Idiot. ^
playerInfo[pid][onlineTime] = gettime();
printf("Time logged in: %i", playerInfo[pid][onlineTime]);
[14:20:40] Time logged in: 1359206440 < -- (Server log)
new time = gettime();
printf("%i %i", playerInfo[id][onlineTime], time);
format(formats, sizeof(formats), "Czas gry: %i m", (time - playerInfo[id][onlineTime]));
TextDrawSetString(specShowInfo[id][1], formats);
prints; [14:20:44] 0 1359206444
When I use playerInfo[playerid][onlineTime] then it works. Da fak?
http://pastebin.com/bFDDLMpE Here's the command.