samp-streamer-plugin icon indicating copy to clipboard operation
samp-streamer-plugin copied to clipboard

Pickup does not update when it's created immediately after destroying

Open xunder-matth opened this issue 3 years ago • 3 comments

There's problem when you call DestroyDynamicPickup than immediately CreateDynamicPickup (for example if you want to change pickup model id, position...) pickup is not being "reloaded".

I created simple way to reproduce this bug:

new DynamicPickup: pickupid;

public OnPlayerCommandText(playerid, cmdtext[]) {
    if (!strcmp(cmdtext, "/createpickup", true)) {
        new Float: x, Float: y, Float: z, string[128];

        GetPlayerPos(playerid, x, y, z);

        pickupid = CreateDynamicPickup(19522, 1, x, y, z);

        format(string, sizeof string, "Create pickup id %d", _: pickupid);
        SendClientMessage(playerid, -1, string);
    } else if (!strcmp(cmdtext, "/setnewmodel", true)) {
        new Float: x, Float: y, Float: z, string[128];

        GetPlayerPos(playerid, x, y, z);

        DestroyDynamicPickup(pickupid);
        pickupid = CreateDynamicPickup(19524, 1, x, y, z);

        format(string, sizeof string, "New model: 19524, id: %d", _: pickupid);
        SendClientMessage(playerid, -1, string);
    } else if (!strcmp(cmdtext, "/destroypickup", true)) {
        new ret = DestroyDynamicPickup(pickupid);

        SendClientMessage(playerid, -1, ret ? "Destroyed" : "Error");
    }
    return 1;
}

When you type /setnewmodel (after creating pickup) you must manually restream pickup by going away from it (Streamer_Update(playerid, STREAMER_TYPE_PICKUP) does not work).

xunder-matth avatar May 04 '21 01:05 xunder-matth

actual

Fragrus avatar Mar 22 '22 23:03 Fragrus

I managed to get around this problem by adding a timer to delay the pickup creation by 500ms

lucasgama335 avatar Sep 22 '22 04:09 lucasgama335

Just ran into this, wasted over an hour of my time trying to work out wtf I was doing wrong.....

Only thing I seem to be able to do to fix it is to disable the newly-created pickups and re-enable them on a timer.

mikecnr avatar Mar 04 '23 19:03 mikecnr