ziggi / FCNPC

FCNPC - Fully Controllable NPC
Apache License 2.0
131 stars 30 forks source link

Crash FCNPC_EnterVehicle #227

Closed iMarllun closed 3 years ago

iMarllun commented 3 years ago

Plugins: crashdetect- last version FCNPC - last version streamer- last version sscanf - last version pawncmd - last version mysql - last version

pawncc version 3.10.10

when i use this function the server shuts down. in FCNPC 1.8.2 this crash doesn't happen

FCNPC_EnterVehicle(npcid, vehicleid, seatid, type = MOVE_TYPE_WALK)
=========================== FCNPC Exception Handler ============================
Address: 0x171

Registers:
EAX: 0x1 - EBX: 0x1 - ECX: 0x19fe8c - EDX: 0x64
ESI: 0x9233864 - EDI: 0x7b9210 - EBP: 0x19fdac - ESP: 0x19fdb0

Stack:
0x0: 0x6351b9dd - 0x4: 0x2f7e168 - 0x8: 0x171 - 0xC: 0x1 - 0x10: 0x0 - 0x14: 0x5cb9b20
0x18: 0x44e50f7b - 0x1C: 0xc4da47f0 - 0x20: 0x41595df3

Information:
  System: Windows
  SA-MP: 0.3.7 R2
  FCNPC: 2.0.0 //Is 2.0.0 or 2.0.1?

Functions:
  FUNC_CPlayerPool__DeletePlayer: 0x466570
  FUNC_CPlayer__Kill: 0x484620
  FUNC_CPlayer__EnterVehicle: 0x484c72
  FUNC_CPlayer__ExitVehicle: 0x484f52
  FUNC_CPlayer__SpawnForWorld: 0x486d30
  FUNC_GetVehicleModelInfo: 0x488240
  FUNC_CConsole__GetIntVariable: 0x48b5b0
  FUNC_ClientJoin_RPC: 0x4918f0

Pointers:
  VAR_ServerAuthentication: 0x4f5fe8
  VAR_NetVersion: 0xfd9

Offsets:
  OFFSET_RemoteSystemManager: 0x33c
  OFFSET_RemoteSystemSize: 0xcb8
  OFFSET_RemoteSystem__ConnectMode: 0xcb0
  OFFSET_RemoteSystem__Unknown: 0xcb5

Callbacks:
  FUNC_CGameMode__OnPlayerGiveDamage: 0x46ed70
  FUNC_CGameMode__OnPlayerTakeDamage: 0x46ecf0
  FUNC_CGameMode__OnPlayerWeaponShot: 0x46f360
  FUNC_CGameMode__OnPlayerStreamIn: 0x46e8e0
  FUNC_CGameMode__OnPlayerStreamOut: 0x46e950
  FUNC_CGameMode__OnGameModeExit: 0x46d7b0
=========================== FCNPC Exception Handler ============================

also, with the latest version of the plugin is returning this warning

[FCNPC] Info: A newer version (v2.0.1) is available at https://github.com/ziggi/FCNPC/releases

ziggi commented 3 years ago

Can you provide a minimal Pawn script to reproduce the issue?

iMarllun commented 3 years ago

Sure, more informations.

SAMP Server 0.3.7-R2. Windows 10 Pro 19042.450 In the profession can only these vehicles listed.


new FazendoMissao3[MAX_PLAYERS] = INVALID_PLAYER_ID;
new totalnpcs3;
new TimerFixAssent2[MAX_PLAYERS];
CMD:test2(playerid) {

    //DeletePreciseTimer2(TimerPolice[playerid]);

    FazendoMissao3[playerid] = INVALID_PLAYER_ID;

    new String[24];

    totalnpcs3++;

    format(String,sizeof(String),"NPC_%d",totalnpcs3);

    FazendoMissao3[playerid] = FCNPC_Create(String);

    totalnpcs3++;

    FCNPC_SetInvulnerable(FazendoMissao3[playerid], true);
    FCNPC_Spawn(FazendoMissao3[playerid], 1, 1593.1672,1830.6145,10.8203);//stay close to this position for the NPC to enter the vehicle
    FCNPC_SetAngle(FazendoMissao3[playerid], 0.0);

    FCNPC_SetAnimationByName(FazendoMissao3[playerid], "CRACK:Bbalbat_Idle_01", 4.1, 1, 0, 0, 0, 1);

    FCNPC_ClearAnimations(FazendoMissao3[playerid]);
    FCNPC_SetSpecialAction(FazendoMissao3[playerid], 0);

    switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
    {

        case VehiclePoliceLVPD :  FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
        case ExercitoEnforcer : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
        case VehiclePoliceLSPD : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
        case VehiclePoliceSFPD : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
        case 522 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
        case 497 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
        case 599 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
        case 428 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
        case 430 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
        case 523 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
        case 490 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
        case 411 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
    }
    TimerFixAssent2[playerid] = SetTimerEx("FixAssent", 3000, true, "d", playerid);
    return 1;
}
forward FixAssent(playerid);
public FixAssent(playerid) {

    if(FCNPC_GetVehicleID(FazendoMissao3[playerid]) == INVALID_VEHICLE_ID) {

        switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
        {

            case VehiclePoliceLVPD :  FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case ExercitoEnforcer : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case VehiclePoliceLSPD : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case VehiclePoliceSFPD : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case 522 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
            case 497 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case 599 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
            case 428 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case 430 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
            case 523 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
            case 490 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK);
            case 411 : FCNPC_EnterVehicle(FazendoMissao3[playerid], GetPlayerVehicleID(playerid), 1, FCNPC_MOVE_TYPE_WALK);
        }   
    }
    return 1;
}
iMarllun commented 3 years ago

FCNPC_EnterVehicle is extremely buggy, the NPC does not enter the vehicle.

switch(GetVehicleModel(GetPlayerVehicleID(playerid))) { case 416 : FCNPC_EnterVehicle(FazendoMissao[playerid], GetPlayerVehicleID(playerid), 3, FCNPC_MOVE_TYPE_WALK); }

mikecnr commented 3 years ago

@ziggi I'm having problems with this too since updating. It's completely stopping me from using the plugin which is very frustrating.

Here is the most basic script to reproduce this issue, the NPC walks up to the door and as soon as they get to the door the server just crashes..

new npcid = FCNPC_Create("[NPC]Test");
FCNPC_Spawn(npcid, 125, -1306.0396,2523.0637,87.4162);
new vehicleid = CreateVehicle(517, -1312.1849, 2517.5012, 87.0529, 270.0, -1, -1, -1);
FCNPC_EnterVehicle(npcid, vehicleid, 0);

Here's a blank gamemode:

#include <a_samp>
#include <FCNPC>

main() {}

public OnGameModeInit()
{
    AddPlayerClass(0, -1306.0396,2520.0637,87.4162, 0, 0, 0, 0, 0, 0, 0);

    return 1;
}

public OnPlayerCommandText(playerid, cmdtext[])
{
    if(!strcmp(cmdtext, "/go", true))
    {
        new npcid = FCNPC_Create("[NPC]Test");
        FCNPC_Spawn(npcid, 125, -1306.0396,2523.0637,87.4162);
        new vehicleid = CreateVehicle(517, -1312.1849, 2517.5012, 87.0529, 270.0, -1, -1, -1);
        FCNPC_EnterVehicle(npcid, vehicleid, 0);

        return 1;
    }

    return 0;
}

Simply spawn and type /go.

Crash logs from FCNPC/crashdetect: https://pastebin.com/g2gwHBmQ https://pastebin.com/iCcx1VMB

Plugins loaded: FCNPC, no others. SAMP Server version 0.3.7 R2. FCNPC version 2.0.2 (latest)

I think the version I had previously was before 2.0.0, but not sure. Please let me know if you need any more information or need anything testing, happy to help.

ziggi commented 3 years ago

@mikescnr try this build: FCNPC-2.0.2.zip If everything is ok I will make a release

mikecnr commented 3 years ago

Seems to work, nice one! Thanks a lot for the quick fix.

But the NPC simply warps into the vehicle when it gets to the door. If memory serves me right, they used to actually open the door and perform an animation of entering the vehicle?

ziggi commented 3 years ago

Yes, it's an old bug on plugin for Windows, on Linux everything works fine. I have no idea how to fix this

mikecnr commented 3 years ago

Just tried it on Linux and it's the same issue, the NPC just warps into the vehicle after running on the spot for a couple of seconds after reaching the door :(