timer() in client-side helpme

Luis_Labarca

  • Sr. Member
  • Hello :D
  • Posts: 298
timer() in client-side helpme
« on June 22nd, 2017, 09:13 PM »
How can I make a time system as function
Code: [Select]
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
Code: [Select]
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 ...:: RPG ::...
IP: 149.56.143.129:8195

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,761

Luis_Labarca

  • Sr. Member
  • Hello :D
  • Posts: 298
Re: timer() in client-side helpme
« Reply #3, on June 22nd, 2017, 09:38 PM »
I want something like this function

Code: [Select]
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 ...:: RPG ::...
IP: 149.56.143.129:8195

EK.IceFlake

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,761
Re: timer() in client-side helpme
« Reply #4, on June 22nd, 2017, 09:53 PM »
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

  • Sr. Member
  • Making American Great Again
  • Posts: 334
Re: timer() in client-side helpme
« Reply #5, on June 22nd, 2017, 10:09 PM »
Recommendation, use the previous function you had then send streams to a case client side and everything will work perfect.

   
Code: [Select]
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

  • Hero Member
  • "We are the champions my fellahs" - Sufyan/VK.SuFy
  • Posts: 1,761
Re: timer() in client-side helpme
« Reply #6, on June 22nd, 2017, 10:22 PM »
In addition, if you want to get a formatted version of the current time, use this:
Code: [Select]
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);
Re: timer() in client-side helpme
« Reply #7, on June 22nd, 2017, 10:24 PM »
Quote from kennedyarz on June 22nd, 2017, 10:09 PM
Recommendation, use the previous function you had then send streams to a case client side and everything will work perfect.

   
Code: [Select]
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.

Code: [Select]
player.StartStream();
player.StreamInt(1);
player.StreamInt(2);
player.StreamInt(3);
player.FlushStream(true);

Code: [Select]
Console.Print(stream.ReadInt());
Console.Print(stream.ReadInt());
Console.Print(stream.ReadInt());

will output:
1
2
3
on the console.

Luis_Labarca

  • Sr. Member
  • Hello :D
  • Posts: 298
My server ...:: RPG ::...
IP: 149.56.143.129:8195