SA-MP Forums Archive
Gettickcount - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Gettickcount (/showthread.php?tid=383787)



Gettickcount - benalon - 08.10.2012

Hey,I Try To Do something with GetTickCount
and it's work but not how i want it's work
i want to do something like this
"%s win in the race in 4.51 secondes",GetName(playerid),(GetTickCount() - TRCount[playerid]));
but it's shows this like this 451 how can i fix this ?: P
i'm sorry for my english ...


Re: Gettickcount - park4bmx - 08.10.2012

well will not sujest to use GetTickCount() as it can get messed up
but the format your doing is in %s which is a string you need %d for integer


Re: Gettickcount - benalon - 08.10.2012

i try to do this in %d buy it dosen't work ... but %i work but not show me this with 4.42 it's shows me this in 442
so i need to know how to put a . in the first number


Re: Gettickcount - park4bmx - 08.10.2012

not really shure but
PHP код:
new Str[5]:format(Str,sizeof(Str),"%i",GetTickCount() - TRCount[playerid]);
strdel(Str23);//not sure about this one(should be right)
new Str2[5]:format(Str,sizeof(Str),"%i",GetTickCount() - TRCount[playerid]);
strdel(Str201);//will leave the last 2 numbers
new Str3[5]:format(Str3,sizeof(Str3),"%s.%s",Str,Str2);
new 
FStr[120];format(FStr,sizeof(FStr),"%s win in the race in %s secondes",GetName(playerid),Str3); 
untested as have no time but what i tried to do is split the first charected from the 3 others then insert a "." into them then split the original number again but this time remove the firs character and add all these up.

But your going to have to modify it.


Re: Gettickcount - benalon - 08.10.2012

It's Steel does this without .


Re: Gettickcount - NeverKnow - 08.10.2012

Try: %0.2f


Re: Gettickcount - benalon - 08.10.2012

the . work's but the right time it's dont work
it's shows me just 0.00


Re: Gettickcount - Skillet` - 08.10.2012

won*
and as you can see 451 = 4.51 means untill 1000 the dot will be 1 number after the first.
so maybe something like this :
Код:
new tick1 = GetTickCount() - TRCount[playerid];
new tick2 = GetTickCount() - TRCount[playerid];
if(tick1 < 1000 && tick2 < 1000 )
{
    strdel(tick1,2,3);
    strdel(tick2,1,1);
}
if(tick1 < 10000 && tick2 < 10000 )
{
    strdel(tick1,3,4);
    strdel(tick2,1,2);
}
if(tick1 < 100000 && tick2 < 100000 )
{
    strdel(tick1,4,5);
    strdel(tick2,1,3);
}
format(str,sizeof(str),"%s won the race in %d.%d seconds",GetName(playerid),tick1,tick2);



Re: Gettickcount - benalon - 08.10.2012

it's give me errors ..
error 035: argument type mismatch (argument 1)
error 035: argument type mismatch (argument 1)
strdel(tick1,2,3);
strdel(tick2,0,1);


Re: Gettickcount - ReneG - 08.10.2012

Quote:
Originally Posted by Skillet`
Посмотреть сообщение
won*
and as you can see 451 = 4.51 means untill 1000 the dot will be 1 number after the first.
so maybe something like this :
Код:
new tick1 = GetTickCount() - TRCount[playerid];
new tick2 = GetTickCount() - TRCount[playerid];
strdel(tick1,2,3);
strdel(tick2,1,2);
format(str,sizeof(str),"%s won the race in %d.%d seconds",GetName(playerid),tick1,tick2);
GetTickCount() returns an INTEGER, not a string.

PHP код:
new Float:seconds = (GetTickCount() - TRCount[playerid])/1000;
format(stringsizeof(string), "%s win in the race in %0.2f secondes"GetName(playerid), seconds);