18.11.2016, 18:18
We could use 1 NPC as our global handler? All global variables hooked to a NPC therefore we can always manipulate them
If we can use global variable on NPC's then we could eventually connect 1 NPC at the start and then use his connection to manipulate the stuff.
This is just an example to show you what I mean, the code will not work
Since if we connect the NPC when the server connects, he will be always online, so we can use his variables as the global ones. Or something like that.
Altho the problem is then using this inside callbacks that dont have any sort of Players inside of them such as GameModeInit. But yeah, what do you think?
If we can use global variable on NPC's then we could eventually connect 1 NPC at the start and then use his connection to manipulate the stuff.
This is just an example to show you what I mean, the code will not work
pawn Код:
Event::on('PlayerConnect', function($player) { //of course, all $player should be replaced with NPC
$found = 0;
for($i = 0; i < MAX_NPC; $i++) {
if($NPC->IsConnected($NPC)) {
$found += 1;
}
}
if($found == 0) $NPC->connect = mysqli_connect(....); //if he is the first NPC connected, we will use him as our offical global variable handler
}
Event::on(SomethingElse, function($something) {
mysqli_close($NPC->connect);
}
Altho the problem is then using this inside callbacks that dont have any sort of Players inside of them such as GameModeInit. But yeah, what do you think?