openmultiplayer / open.mp

Open Multiplayer, a multiplayer mod fully backwards compatible with SA-MP
https://open.mp
Mozilla Public License 2.0
450 stars 90 forks source link

Vehicle respawn immediately after the explosion with SAMP Addon #964

Open ghost opened 1 month ago

ghost commented 1 month ago

Client: SAMP0.3DL + SAMP Addon 2.7 R12 Server: open.mp v1.2.0.2670

When entering the game with the SAMP Addon and testing the following code, the vehicle will respawn immediately after the explosion,when without SAMP Addon, it seems to work fine, the vehicle respawns after 16 seconds

but this doesn't happen with samp server, the code works as expected with or without the SAMP Addon

#include <open.mp>

new testVehicleID;
new testVehicleTimer = -1;

public OnGameModeInit()
{
    testVehicleID = CreateVehicle(411, 2025.7511,-1420.9379,16.9922, 0.0, -1, -1, 300);
    return 1;
}

public OnPlayerSpawn(playerid)
{
    SetPlayerPos(playerid, 2028.7511,-1422.9379,16.9922);

    if(testVehicleTimer != -1)
        KillTimer(testVehicleTimer);

    testVehicleTimer = SetTimer("KillVehicle", 2000, false);
    return 1;
}

forward KillVehicle();
public KillVehicle()
{
    SetVehicleHealth(testVehicleID, 249.0);
    SendClientMessageToAll(-1, "SetVehicleHealth | vehicleid %d | health 249.0", testVehicleID);

    if(testVehicleTimer != -1)
        KillTimer(testVehicleTimer);
    testVehicleTimer = SetTimer("RespawnVehicle", 16*1000, false);
    return 1;
}

forward RespawnVehicle();
public RespawnVehicle()
{
    if(testVehicleTimer != -1) {
        KillTimer(testVehicleTimer);
        testVehicleTimer = -1;
    }
    SetVehicleToRespawn(testVehicleID);
    SendClientMessageToAll(-1, "SetVehicleToRespawn | vehicleid %d", testVehicleID);
    return 1;
}

public OnVehicleSpawn(vehicleid)
{
    if(testVehicleTimer != -1) {
        SendClientMessageToAll(-1, "OnVehicleSpawn | KillTimer %d", testVehicleTimer);

        KillTimer(testVehicleTimer);
        testVehicleTimer = -1;
    }
    SendClientMessageToAll(-1, "OnVehicleSpawn | vehicleid %d", vehicleid);
    return 1;
}
AmyrAhmady commented 1 month ago

Can you record a video with the same script and samp addon?

ghost commented 1 month ago

Can you record a video with the same script and samp addon?

https://discord.com/channels/1272941658010550274/1272941660086735020/1272942237566763008

AmyrAhmady commented 1 month ago

This is a link to a message and it's unknown to anyone who is mot in that server just upload the video here, you can drag and drop the file

ghost commented 1 month ago

This is a link to a message and it's unknown to anyone who is mot in that server just upload the video here, you can drag and drop the file

https://youtu.be/fmBA5JNfiPE

I can't upload files larger than 10m