Closed CantBeKarma closed 10 months ago
One thing I can say is the following, which is also mentioned on the wiki:
You also don't need to load the ColAndreas separately in server.cfg, since FCNPC loads this automatically!
Is it only FCNPC_OnCreate, or also other FCNPC callbacks?
Just tested on my own.
It seems like FCNPC_OnCreate doesn't get called when you use FCNPC_Create under OnGameModeInit. I also tested FCNPC_Spawn and FCNPC_OnSpawn isn't getting called either. When I delay the creation of the NPC with a timer, the callback does get called. I also tested this on non-DL and the result is exactly the same.
It seems that it has something to do with when the server is starting.
EDIT: I did some further testing, to see if other plugins had the same problem. Turns out it's only FCNPC. I used the following minimal server.cfg:
maxnpc 10
rcon_password 1234
gamemode0 bare 1
plugins streamer FCNPC
and the following minimal gamemode:
#include <a_samp>
#include <streamer>
#include <FCNPC>
main() {}
public OnGameModeInit()
{
new obj = CreateObject(1271, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
MoveObject(obj, 0.1, 0.1, 0.1, 1);
new obj2 = CreateDynamicObject(1271, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
MoveDynamicObject(obj2, 0.1, 0.1, 0.1, 1);
new npc = FCNPC_Create("testNPC");
FCNPC_Spawn(npc, 0, 0.0, 0.0, 0.0);
return 1;
}
public OnObjectMoved(objectid)
{
print("MOVED");
return 1;
}
public OnDynamicObjectMoved(STREAMER_TAG_OBJECT:objectid)
{
print("DYN MOVED");
return 1;
}
public FCNPC_OnCreate(npcid)
{
print("NPC CREATE");
return 1;
}
This is the output:
...
[npc:join] testNPC has joined the server (49:127.0.0.1)
Number of vehicle models: 0
MOVED
DYN MOVED
As you can see, both MOVED from the regular object and DYN MOVED from the streamer object are displayed as should be, but NPC CREATE isn't.
I also encountered this problem, any fix other than using it outside gamemode or using timer?
Wait 5 ticks for each FCNPC_Create. (with PawnPlus for example)
Or (BE CAREFUL!!!) call CallbackManager::Init inside OnSpawn or OnCreate callbacks, and recompile plugin.
This can be easily fixed by moving the CCallbackManager::Init();
call inside the AmxLoad
function, but this will break compatibility with YSI (YSI breaks AMX addresses or something like that). Some people are using YSI, so I added the FCNPC_OnInit
callback, so just put yours FCNPC_Create
inside the callback and everything will work fine.
For some reason FCNPC_OnCreate isn't getting called at all after creating an NPC. I'm using the latest release as of making this (https://github.com/ziggi/FCNPC/releases/tag/v2.0.0-rc.7) specifically for 0.3.DL. I've also tried using the other 0.3.DL release and FCNPC_OnCreate isn't getting called. This is the test script:
The results (server-log):
It shows the NPC has connected, however it just doesn't call FCNPC_OnCreate, yeah. I've even tried printing within the include, specifically where it's hooking FCNPC_OnCreate and it doesn't print anything at all.