19.11.2015, 14:09
Yo, I've bumped into a problem trying to use functions from Shoebill in pawn.
I've created a class with static method where all functions are registered in amx-instances:
Then, in class which extends Gamemode class I call this static method in onEnable() method:
In onDisable():
Code in pawn in OnGameModeInit():
And when I'm trying to call GetPlayerFucntion I'm getting next message in server console all the time:
[SHOEBILL] Function GetPlayerFactionName is not registered.
And of couse test is equals to "test".
Did I do something wrong?
I've created a class with static method where all functions are registered in amx-instances:
PHP код:
public class InitMethodsForPawn {
static EventManagerNode eventManagerNode;
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);
});
}
public static void uninitialize() {
eventManagerNode.registerHandler(AmxUnloadEvent.class, e -> {
e.getAmxInstance().unregisterFunction("GetPlayerFactionName");
});
}
}
PHP код:
EventManager eventManager = getEventManager();
InitMethodsForPawn.initialize(eventManager);
PHP код:
InitMethodsForPawn.uninitialize();
PHP код:
new test[32];
test = "test";
CallShoebillFunction("GetPlayerFactionName", 0, test);
printf("test = %s", test);
[SHOEBILL] Function GetPlayerFactionName is not registered.
And of couse test is equals to "test".
Did I do something wrong?