How to substract one integer value from other one
#1

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??
Reply
#2

Don't they teach you this in primary school? Seriously ...
Reply
#3

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
Reply
#4

Instead of talking like real people you keep complaining about one's knowledge.
Reply
#5

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...
Reply
#6

Maybe you would want to change:
pawn Код:
(playerInfo[id][onlineTime] - time)
to:
pawn Код:
(time - playerInfo[id][onlineTime])
?? :S
Reply
#7

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.
Reply
#8

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.
Reply
#9

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)