isplayerinarea + timer
#1

hey so
I wanna make a text draw popup when a player is in area (cant use Checkpoints) so i was wondering if it's a good or bad idea use a timer with isPlayerinarea..

and any tips to make it as most efficient as possible. it will popup only on 3 interiors so interior 0 wont be called.. but im still afraid this can go wild
Reply
#2

that sounds good so, isplayerinrea with timer wont cause any lag or anything
Reply
#3

Not much if any unless you run it like every 100 miliseconds (10th of a second)

EDIT:

Damn you posted first, they really need to add in the error telling you if someone posted before you..
Reply
#4

You have an event for it so why the timer ?

(Not real code, the names are wrong)

pawn Код:
OnPlayerChangeInterior(.......)
{
    switch (newinteriorid)
    {
        case 3, 7, 9 :
        {
            if (IsPlayerInRangeOfPoint(...............) ShowPlayerTextDraw(.......);
        }
        default: HidePlayerTextDraw(.......);
    }
}
You only need one global textdraw also as the text won't change, example: "you are prohibited from entering this area", always show the same message then no need to update it or whatever.
Reply
#5

He's using IsPlayerInArea to what I've read, not just OnPlayerInteriorChange
Reply
#6

Quote:
Originally Posted by Grim_
Посмотреть сообщение
He's using IsPlayerInArea to what I've read, not just OnPlayerInteriorChange
Yep, I wasn't paying attention to the function names (no longer script + lazy hehe).

Or do you mean it won't work ?

I no longer script so I could be wrong but IIRC the event is called up when you swap interiors so when the event happens all you do is check for the area and show the message, it's the most efficient way of doing it.
Reply
#7

The thing is I use many little areas in the same interior so I cant use that system Donny
Reply
#8

Quote:
Originally Posted by aNdReSk
Посмотреть сообщение
The thing is I use many little areas in the same interior so I cant use that system Donny
I see well then yes ignore my replies as they won't work more than once.

Well your current method will do (timer >> show message), I think the only way you could make it more efficient would be to time the interval in the timer to the smallest area, how long it takes to get across the smallest area is the fastest the timer ever needs to be so this would reduce the bottleneck we get on sync by using timers.

If it takes you three seconds to get across the smallest area then the interval should be set to that, it's the lowest period of time the timer will never have to do any work for as you couldn't of gone from that area and out of the next area etc etc.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)