Giter VIP home page Giter VIP logo

Comments (6)

xwerswoodx avatar xwerswoodx commented on August 19, 2024

Honestly 1 decisecond is 100 milliseconds, so TIMERFMS ds*100 is same as TIMERFD just multiply the amount of Decisecond by 100 to make it timerfd, but if you still insist for a function;

[FUNCTION TIMERFD]
IF (<dARGV> < 2)
  TIMERFMS <ARGS> //Return default errors, if ARGS has 1 argument.
  RETURN 0
ENDIF
TIMERFMS <EVAL <STRTOKEN '<ARGS>', 1, ','> * 100>,<STRTOKEN '<ARGS>', 2-, ','>

from source-x.

AtillaG1 avatar AtillaG1 commented on August 19, 2024

The thing is not that its not possible to do otherwise, but everytime there is a topic about timerMS or timerfMS, most of the veterans suggest not using MS, because its supper heavy and hungry for sphere.

However thanks for alternative.

from source-x.

xwerswoodx avatar xwerswoodx commented on August 19, 2024

Technically using TIMERF TIMERFD or TIMERFMS has no difference, when you use TIMERF sphere tells that call me once in second*1000 milliseconds, so using TIMERFMS 1000 or TIMERF 1 doesn't have any difference, so yes I can add TIMERFD but it will do same thing with the one I gave you as a script, because I just gonna set the timeout same as the script.

You can see that the TIMERF multiplies the value you entered by 1000 to change to millisecond on;
Note: fSecond is a bool, which set to true if you use TIMERF instead of TIMERFMS

Source-X/src/game/CObjBase.cpp

Lines 2698 to 2701 in 4934125

if (fSeconds)
{
iTimeout *= MSECS_PER_SEC;
}

All code:

Source-X/src/game/CObjBase.cpp

Lines 2659 to 2706 in 4934125

case OV_TIMERF:
case OV_TIMERFMS:
{
EXC_SET_BLOCK("TIMERF(MS)");
const bool fSeconds = (index == OV_TIMERF);
lpctstr ptcArgStr = s.GetArgStr();
if ( !strnicmp(ptcArgStr, "CLEAR", 5 ) )
{
CWorldTimedFunctions::ClearUID(GetUID());
}
else if ( !strnicmp(ptcArgStr, "STOP", 4 ) )
{
lpctstr strFunction = ptcArgStr + 5;
GETNONWHITESPACE(strFunction);
CWorldTimedFunctions::Stop(GetUID(), strFunction);
}
else
{
tchar *ptcCmd = s.GetArgRaw();
// Extract the timeout and advance the string pointer to the command position
int64 iTimeout = Exp_Get64Val(ptcCmd);
if (iTimeout < 0)
{
g_Log.EventError("Timed function: invalid parameter '%" PRId64 "'.\n", iTimeout);
return false;
}
else
{
SKIP_ARGSEP(ptcCmd);
if ( !(*ptcCmd) || (strlen(ptcCmd) >= CTimedFunction::kuiCommandSize) )
{
g_Log.EventError("TimerF function name empty or args too long - total length must be less than %u characters.\n", CTimedFunction::kuiCommandSize);
return false;
}
else
{
if (fSeconds)
{
iTimeout *= MSECS_PER_SEC;
}
CWorldTimedFunctions::Add(GetUID(), iTimeout, ptcCmd);
}
}
}
}

from source-x.

xwerswoodx avatar xwerswoodx commented on August 19, 2024

If you still think TIMERFD should exists, I could add it for just as symbolically, but honestly it will have no effect on performance at all.

from source-x.

AtillaG1 avatar AtillaG1 commented on August 19, 2024

Well Im not skilled enough to understand the code you posted, but from the explanation it makes sense. I was just wondering why we have been warned to not use the MS stuff, if its basically the same.
I'll use your function then, thanks.

from source-x.

cbnolok avatar cbnolok commented on August 19, 2024

TIMERD is there for historical purposes, i guess it won't harm to have TIMERFD for consistency, even if it's not so needed.
In any case, as said timerf used timerfms and multiplies the value. We might have said to avoid using timer(f)ms too often with too small delays to avoid overload, but timer(f)ms isn't bad per se

from source-x.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.