Loops under OnPlayerUpDate?
#1

Hello

Because I find the SAMP pickup system quite annoying to work with (no offence) because the types are limited and none of the spawn types fit my needs I was trying to make a new custom pickup system.

So in this system I could create pickups with custom respawn time or respawn types.

The thing is, to do that I need to check whether a player is near the pickup or not, if he is then OnPlayerPickupNewPickupType should be called.
I tried making a timer that would run every quarter of a second, however it was to slow to handle me rushing through one in a vehicle. So the only way of doing this would be using OnPlayerUpdate.
But since that callback is called so frequently would it be a good idea to loop through all my created pickups and check if the player is near one?
Reply
#2

NO! OnPlayerUpdate needs to be fast as possible adding loops can create massive lag.
Reply
#3

Just use the streamer plugin and dynamic areas.
Reply
#4

Well I would still need to check if a player is in an area too...
But I can use the areas for time zones
Reply
#5

Use streamer and use IsPlayerInDynamicArea

pawn Код:
native CreateDynamicCircle(Float:x, Float:y, Float:size, worldid = -1, interiorid = -1, playerid = -1);
native CreateDynamicRectangle(Float:minx, Float:miny, Float:maxx, Float:maxy, worldid = -1, interiorid = -1, playerid = -1);
native CreateDynamicSphere(Float:x, Float:y, Float:z, Float:size, worldid = -1, interiorid = -1, playerid = -1);
native CreateDynamicCube(Float:minx, Float:miny, Float:minz, Float:maxx, Float:maxy, Float:maxz, worldid = -1, interiorid = -1, playerid = -1);
native CreateDynamicPolygon(Float:points[], Float:minz = -FLOAT_INFINITY, Float:maxz = FLOAT_INFINITY, maxpoints = sizeof points, worldid = -1, interiorid = -1, playerid = -1);
For more information about these natives check this link out: https://sampforum.blast.hk/showthread.php?tid=102865

EDIT: also if you're using zone, it would look something like this
pawn Код:
public IsPlayerInDynamicArea(playerid, areaid);
{
    new zoneid = GetZoneName(playerid); //If you're using a_zones, this is an example
    if(areaid == 1 && zoneid == 192)
    {
        //function
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)