timer() in client-side helpme

Started by Luis_Labarca, Jun 22, 2017, 08:13 PM

Previous topic - Next topic

Luis_Labarca

How can I make a time system as function
GetTimer ()
{
Local a = time () - Start_time;
Return a;
}
Function onScriptLoad ()
{
Start_time <- time ();
}
On the client side

Try it on the side of the client-side replacing a little things but does not work gives the time in large numbers
Start_time <-0;
GetSeconds ()
{
Local a = Script.GetTicks()- Start_time;
Return a;
}
function Script::ScriptProcess()
{
Start_time = Script.GetTicks();
Console.Print(GetSeconds())
}
function Script::ScriptLoad()
{
Start_time <- Script.GetTicks();
}
My server RP
IP: 51.222.28.159:8194

EK.IceFlake

What are you trying to do here?

Luis_Labarca

Quote from: EK.IceFlake on Jun 22, 2017, 08:18 PMWhat are you trying to do here?
A time function such as server side
My server RP
IP: 51.222.28.159:8194

Luis_Labarca

I want something like this function

Time1000Sec <-50;
Min <-4;
Sec <-59;

function Script::ScriptProcess()
{
if(::Time1000Sec>=1)::Time1000Sec-=1;
if(::Time1000Sec==0)
{
::Sec -=1;
if(::Sec < 1 )
{
::Min -=1
::Sec= 59;
}
Console.Print(Min+" "+Sec)
::Time1000Sec = 50;
}
}
My server RP
IP: 51.222.28.159:8194

EK.IceFlake

You mean time()? In that case, you'll want to use Script.GetTicks(). If you want a routine (SqRoutine or CreateTimer), you can use this.

kennedyarz

Recommendation, use the previous function you had then send streams to a case client side and everything will work perfect.

    function SendTimeToClient( )
{
local Hour = bla bla
local Min = bla bla
local Secs = bla bla
local TimeData = Hou +|" + Min + "|" + Secs;

local data = Stream();
    data.StartWrite( );
    data.WriteInt(1);
data.WriteString( TimeData  );
}

function Server::ServerData(stream)
    {
    local strint = stream.ReadInt();

    switch (strint.tointeger())
    {
        case 1: local data = stream.ReadString(); Times(data); break;
}
}

Times(data)
{
    local separator = split(data "|"), Hour = separator[0], Mins = separator[1], Secs = separator[2];
    Console.Print(Hour+" / "+Mins+" / "+Secs)
}

It's just an idea. Does not work "I think so" but it's only a good idea, you know what to do and what I mean

EK.IceFlake

In addition, if you want to get a formatted version of the current time, use this:
local time = System.GetTimeStamp();
local date = System.GetDate(time, 'l'); //change 'l' to 'u' if you want to use UTC

Console.Print(date.hour + "|" + date.min + "|" + date.sec);

EK.IceFlake

Quote from: kennedyarz on Jun 22, 2017, 09:09 PMRecommendation, use the previous function you had then send streams to a case client side and everything will work perfect.

    function SendTimeToClient( )
{
local Hour = bla bla
local Min = bla bla
local Secs = bla bla
local TimeData = Hou +|" + Min + "|" + Secs;

local data = Stream();
    data.StartWrite( );
    data.WriteInt(1);
data.WriteString( TimeData  );
}

function Server::ServerData(stream)
    {
    local strint = stream.ReadInt();

    switch (strint.tointeger())
    {
        case 1: local data = stream.ReadString(); Times(data); break;
}
}

Times(data)
{
    local separator = split(data "|"), Hour = separator[0], Mins = separator[1], Secs = separator[2];
    Console.Print(Hour+" / "+Mins+" / "+Secs)
}

It's just an idea. Does not work "I think so" but it's only a good idea, you know what to do and what I mean
Strings are incredibly wasteful for this task.

player.StartStream();
player.StreamInt(1);
player.StreamInt(2);
player.StreamInt(3);
player.FlushStream(true);

Console.Print(stream.ReadInt());
Console.Print(stream.ReadInt());
Console.Print(stream.ReadInt());

will output:
1
2
3
on the console.

Luis_Labarca

My server RP
IP: 51.222.28.159:8194