FCNPC AimAt problem
#1

My problem is the following: I use the FCNPC plugin, and I made a script which makes the NPC attack the player if he comes close. But it doesn't quite work, because when I go near the NPC he immidiately attacks me, the server just stops, and I get a crash report into the FCNPC folder.

Код:
public OnPlayerUpdate(playerid)
{
    new Float:npcPos[3], Float:playerPos[3];
    if(Logged[playerid] == 1)
    {
        for(new j = 0; j != MAX_NPC; j++)
        {
            FCNPC_GetPosition(NPCInfo[j][nID], npcPos[0], npcPos[1], npcPos[2]);
            if(IsPlayerInRangeOfPoint(playerid, 20.0, npcPos[0], npcPos[1], npcPos[2]))
            {
                GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
                NPCInfo[j][nTimer] = SetTimerEx("NPCTamad", 3000, false, "ifff", j, playerPos[0], playerPos[1], playerPos[2]);
            }
        }
    }
    return 1;
}

forward NPCTamad(npcid, Float:x, Float:y, Float:z);
public NPCTamad(npcid, Float:x, Float:y, Float:z)
{
	FCNPC_Stop(NPCInfo[npcid][nID]);
	FCNPC_AimAt(NPCInfo[npcid][nID], x, y, z, true);
	KillTimer(NPCInfo[npcid][nTimer]);
	return 1;
}
Crash report:
Код:
======================== FCNPC Exception Handler ===============================
Address: 0x64656F17

Registers:
EAX: 0x000001F3 - EBX: 0x00000000 - ECX: 0x00000000 - EDX: 0x00000000
ESI: 0x74AA110C - EDI: 0x679248 - EBP: 0x0018FE10 - ESP: 0x0018FDD8

Stack:
0x0: 0x0067E400 - 0x4: 0x00020061 - 0x8: 0x00000000 - 0xC: 0x00CF47CD - 0x10: 0x000001F3 - 0x14: 0x00000000
0x18: 0x00000000 - 0x1C: 0x00000000 - 0x20: 0x00000000

Functions:
FUNC_CPlayerPool__DeletePlayer: 0x466570
FUNC_CPlayer__Kill: 0x484620
FUNC_CPlayer__EnterVehicle: 0x484c70
FUNC_CPlayer__ExitVehicle: 0x484f50
FUNC_CPlayer__SpawnForWorld: 0x486d30
FUNC_GetVehicleModelInfo: 0x488240
FUNC_CConfig__GetValueAsInteger: 0x48b5b0
FUNC_CreateNPC_RPC: 0x4918f0
FUNC_RakServer__Send: 0x45a260


Pointers:
VAR_ServerAuthentication: 0x4f5fe8
VAR_ServerPtr: 0x25b3f0
VAR_ConfigPtr: 0x2549b8
VAR_RakPeerPtr: 0x25edd0


Offsets:
OFFSET_NetVersion: 0xfd9
OFFSET_RemoteSystemManager: 0x33c
OFFSET_RemoteSystemSize: 0xcb8
OFFSET_RemoteSystem__ConnectMode: 0xcb0
OFFSET_RemoteSystem__Unknown: 0xcb5
OFFSET_SendBullet_RPC: 0x33
======================== FCNPC Exception Handler ===============================
Reply
#2

If I were you, I'd use the crash detect plugin. It could help to show where exactly the crash appears.

I've heard about SetTimerEx crashing with Float args, although I'm not really sure.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)