19.11.2015, 17:53
@mk124, maybe I misunderstood you, but I called Shoebill function in OnGameModeInit just for an example. Even if I call that function with a command, it's still said to be unregistered.
Tried your example above and it seems that AmxLoadEvent is not being occurred at all or initFunction is equals to null.
I removed code from OnGameModeInit() and added this one:
Then did some changes to Java code:
The code in OnShoebillInitialized wasnt executed (I didnt get any messages in server console).
Also, in OnPlayerConnect I called OnShoebillInitialized() and it tells me that [SHOEBILL] Function GetPlayerFactionName is not registered.
Tried your example above and it seems that AmxLoadEvent is not being occurred at all or initFunction is equals to null.
I removed code from OnGameModeInit() and added this one:
PHP Code:
forward OnShoebillInitialized();
public OnShoebillInitialized()
{
printf("OnShoebillInitialized called");
new test[32];
test = "damn";
CallShoebillFunction("GetPlayerFactionName", 0, test);
printf("test = %s", test);
}
PHP Code:
public static void initialize(EventManager rootEventManager) {
eventManagerNode = rootEventManager.createChildNode();
eventManagerNode.registerHandler(AmxLoadEvent.class, e -> {
e.getAmxInstance().registerFunction("GetPlayerFactionName", objects -> {
// Player player = Player.get((Integer) objects[0]);
//Do something to get player's faction etc.
objects[1] = "Los Santos PoPo";
//Return value for pawn (not always needed)
return 1;
}, Integer.class, String.class);
AmxCallable initFunction = e.getAmxInstance().getPublic("OnShoebillInitialized");
if (initFunction != null) {
initFunction.call();
}
});
}
Also, in OnPlayerConnect I called OnShoebillInitialized() and it tells me that [SHOEBILL] Function GetPlayerFactionName is not registered.