SA-MP Gamemodes with PHP

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
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
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);
}
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?
I get what you mean, but as a programmer, this is wrong and we should not even discuss using variables in a wrong way, if it doesn't work, we should not use the framework/plugin anymore...
Reply


Messages In This Thread
SA-MP Gamemodes with PHP - by lapayo - 06.06.2013, 20:24
Re: SA-MP Gamemodes with PHP - by Dr.Einstein - 06.06.2013, 20:32
Re: SA-MP Gamemodes with PHP - by CrazyChoco - 06.06.2013, 20:49
Re: SA-MP Gamemodes with PHP - by OrMisicL - 06.06.2013, 20:53
Re: SA-MP Gamemodes with PHP - by Rsmiley - 06.06.2013, 21:26
Re: SA-MP Gamemodes with PHP - by Memoryz - 06.06.2013, 21:31
AW: SA-MP Gamemodes with PHP - by lapayo - 06.06.2013, 21:49
Re: AW: SA-MP Gamemodes with PHP - by Rsmiley - 06.06.2013, 21:53
Re: SA-MP Gamemodes with PHP - by Red_Dragon. - 06.06.2013, 21:53
AW: SA-MP Gamemodes with PHP - by lapayo - 06.06.2013, 22:16
Re: AW: SA-MP Gamemodes with PHP - by Rsmiley - 06.06.2013, 22:28
Re: SA-MP Gamemodes with PHP - by [DOG]irinel1996 - 06.06.2013, 22:37
Re: SA-MP Gamemodes with PHP - by Emmet_ - 06.06.2013, 22:48
Re: SA-MP Gamemodes with PHP - by Whiteagle - 06.06.2013, 23:06
AW: SA-MP Gamemodes with PHP - by lapayo - 07.06.2013, 00:05
Re: SA-MP Gamemodes with PHP - by Rsmiley - 07.06.2013, 01:53
AW: Re: SA-MP Gamemodes with PHP - by lapayo - 07.06.2013, 02:17
Re: SA-MP Gamemodes with PHP - by [CG]Milito - 07.06.2013, 02:48
Re: AW: Re: SA-MP Gamemodes with PHP - by Rsmiley - 07.06.2013, 02:57
Re: SA-MP Gamemodes with PHP - by Hanger - 07.06.2013, 09:32
Re: SA-MP Gamemodes with PHP - by Memoryz - 07.06.2013, 22:49
Re: SA-MP Gamemodes with PHP - by Rsmiley - 08.06.2013, 00:16
Re: SA-MP Gamemodes with PHP - by Kalladel - 08.06.2013, 00:49
AW: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 01:27
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 08.06.2013, 02:37
Re: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 10:51
Re: SA-MP Gamemodes with PHP - by Whiteagle - 08.06.2013, 12:43
Re: AW: SA-MP Gamemodes with PHP - by steki. - 08.06.2013, 12:55
Re: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 14:28
AW: SA-MP Gamemodes with PHP - by Ditti - 08.06.2013, 18:16
Re: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 18:45
AW: SA-MP Gamemodes with PHP - by Ditti - 08.06.2013, 18:59
Re: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 19:11
Re: SA-MP Gamemodes with PHP - by ToFFiK - 08.06.2013, 19:26
Re: SA-MP Gamemodes with PHP - by Dan.. - 08.06.2013, 19:59
Re: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 20:40
Re: SA-MP Gamemodes with PHP - by lapayo - 08.06.2013, 21:26
Re: SA-MP Gamemodes with PHP - by Dan.. - 09.06.2013, 06:47
Re: SA-MP Gamemodes with PHP - by GWMPT - 09.06.2013, 14:30
Re: SA-MP Gamemodes with PHP - by lapayo - 09.06.2013, 14:40
Re: SA-MP Gamemodes with PHP - by GWMPT - 09.06.2013, 14:42
Re: SA-MP Gamemodes with PHP - by steki. - 09.06.2013, 22:41
Re: SA-MP Gamemodes with PHP - by carloLT - 09.06.2013, 22:53
Re: SA-MP Gamemodes with PHP - by carloLT - 10.06.2013, 03:22
Re: SA-MP Gamemodes with PHP - by InfiniTy. - 10.06.2013, 06:57
Re: SA-MP Gamemodes with PHP - by Lorenc_ - 10.06.2013, 08:21
Re: SA-MP Gamemodes with PHP - by Whiteagle - 10.06.2013, 08:38
Re: SA-MP Gamemodes with PHP - by steki. - 10.06.2013, 10:26
AW: SA-MP Gamemodes with PHP - by Phцnix - 11.12.2013, 14:40
Re: AW: SA-MP Gamemodes with PHP - by GWMPT - 11.12.2013, 15:00
Re: SA-MP Gamemodes with PHP - by Denisucoz - 10.01.2014, 10:12
Re: SA-MP Gamemodes with PHP - by [TC]XxJuggaloxX - 16.01.2014, 02:30
Re: SA-MP Gamemodes with PHP - by Excelize - 16.01.2014, 04:57
Re: SA-MP Gamemodes with PHP - by QuaTTrO - 16.01.2014, 13:51
Re: SA-MP Gamemodes with PHP - by Nazaret - 24.01.2014, 14:09
Re: SA-MP Gamemodes with PHP - by [WA]iRonan - 24.01.2014, 14:15
Re: SA-MP Gamemodes with PHP - by Walnut - 24.01.2014, 15:02
Re: SA-MP Gamemodes with PHP - by [WA]iRonan - 24.01.2014, 15:06
Re: SA-MP Gamemodes with PHP - by Rsmiley - 31.01.2014, 22:24
Re: SA-MP Gamemodes with PHP - by SeV_ - 31.01.2014, 22:28
Re: SA-MP Gamemodes with PHP - by GWMPT - 01.02.2014, 16:44
Re: SA-MP Gamemodes with PHP - by Mauzen - 01.02.2014, 17:24
Re: SA-MP Gamemodes with PHP - by QuaTTrO - 01.02.2014, 20:04
Re: SA-MP Gamemodes with PHP - by GWMPT - 01.02.2014, 20:42
Re: SA-MP Gamemodes with PHP - by Rsmiley - 16.02.2014, 05:53
Re: SA-MP Gamemodes with PHP - by kN1GhT - 16.02.2014, 14:10
Re: SA-MP Gamemodes with PHP - by cniry - 16.02.2014, 18:05
Re: SA-MP Gamemodes with PHP - by cniry - 22.02.2014, 20:19
Re : SA-MP Gamemodes with PHP - by FosterK - 23.02.2014, 10:27
Re: SA-MP Gamemodes with PHP - by [ESC]Walter_Wolf - 11.03.2014, 16:00
Re: SA-MP Gamemodes with PHP - by GWMPT - 15.03.2014, 14:34
Re: SA-MP Gamemodes with PHP - by [ESC]Walter_Wolf - 15.03.2014, 19:54
Re: SA-MP Gamemodes with PHP - by IceShock - 15.03.2014, 19:58
Re: SA-MP Gamemodes with PHP - by GWMPT - 15.03.2014, 20:33
Re: SA-MP Gamemodes with PHP - by No Fear - 17.03.2014, 12:36
Re: SA-MP Gamemodes with PHP - by therainycat - 10.05.2014, 21:20
Re: SA-MP Gamemodes with PHP - by erorcun - 11.05.2014, 11:19
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 11.05.2014, 11:23
Re: SA-MP Gamemodes with PHP - by erorcun - 11.05.2014, 23:23
Re: SA-MP Gamemodes with PHP - by GWMPT - 12.05.2014, 18:08
Re: SA-MP Gamemodes with PHP - by erorcun - 12.05.2014, 19:37
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 12.05.2014, 20:36
Re: SA-MP Gamemodes with PHP - by erorcun - 13.05.2014, 00:02
Re: SA-MP Gamemodes with PHP - by therainycat - 13.05.2014, 09:45
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 13.05.2014, 16:17
Re: SA-MP Gamemodes with PHP - by erorcun - 13.05.2014, 19:23
Re: SA-MP Gamemodes with PHP - by GWMPT - 13.05.2014, 19:48
Re: SA-MP Gamemodes with PHP - by erorcun - 13.05.2014, 19:54
Re: SA-MP Gamemodes with PHP - by GWMPT - 13.05.2014, 19:57
Re: SA-MP Gamemodes with PHP - by erorcun - 14.05.2014, 12:12
Re: SA-MP Gamemodes with PHP - by erorcun - 15.05.2014, 00:10
Re: SA-MP Gamemodes with PHP - by Nazaret - 15.05.2014, 15:27
SAMPHP Released - by erorcun - 15.05.2014, 18:25
Re: SAMPHP Released - by therainycat - 15.05.2014, 18:30
Re: SA-MP Gamemodes with PHP - by therainycat - 15.05.2014, 21:00
Re: SA-MP Gamemodes with PHP - by erorcun - 15.05.2014, 21:56
Re: SA-MP Gamemodes with PHP - by crs0r - 16.05.2014, 22:20
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 22.05.2014, 12:17
Re: SA-MP Gamemodes with PHP - by erorcun - 15.06.2014, 18:40
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 16.06.2014, 13:45
Re: SA-MP Gamemodes with PHP - by RenovanZ - 17.06.2014, 06:12
Re: SA-MP Gamemodes with PHP - by lapayo - 28.06.2014, 13:31
Re: SA-MP Gamemodes with PHP - by erorcun - 29.06.2014, 09:49
Re: SA-MP Gamemodes with PHP - by lapayo - 29.06.2014, 13:05
Re: SA-MP Gamemodes with PHP - by Players - 07.07.2014, 02:44
Re: SA-MP Gamemodes with PHP - by ikkentim - 07.07.2014, 20:28
Re: SA-MP Gamemodes with PHP - by Players - 11.07.2014, 00:31
Re: SA-MP Gamemodes with PHP - by Players - 11.07.2014, 18:57
Re: SA-MP Gamemodes with PHP - by GWMPT - 20.07.2014, 21:44
Re: SA-MP Gamemodes with PHP - by Kaperstone - 20.07.2014, 22:59
Re: SA-MP Gamemodes with PHP - by GWMPT - 21.07.2014, 10:29
Re: SA-MP Gamemodes with PHP - by Kaperstone - 22.07.2014, 02:35
Re: SA-MP Gamemodes with PHP - by GWMPT - 22.07.2014, 10:05
Re: SA-MP Gamemodes with PHP - by harsimarriar96 - 23.07.2014, 10:29
Re: SA-MP Gamemodes with PHP - by Kaperstone - 27.07.2014, 02:14
Re : SA-MP Gamemodes with PHP - by S4t3K - 27.07.2014, 02:32
Re: SA-MP Gamemodes with PHP - by Kaperstone - 11.09.2014, 08:48
Re: SA-MP Gamemodes with PHP - by GWMPT - 18.11.2014, 11:33
Re : Re: SA-MP Gamemodes with PHP - by Enchancer - 18.11.2014, 12:14
Re: SA-MP Gamemodes with PHP - by GWMPT - 18.11.2014, 12:58
Re : SA-MP Gamemodes with PHP - by Enchancer - 18.11.2014, 13:00
Re: Re : SA-MP Gamemodes with PHP - by GWMPT - 18.11.2014, 13:18
AW: SA-MP Gamemodes with PHP - by Bubelbub - 23.11.2014, 11:58
Re: SA-MP Gamemodes with PHP - by GWMPT - 23.11.2014, 12:18
Re: SA-MP Gamemodes with PHP - by katumas - 27.08.2015, 06:31
Re: SA-MP Gamemodes with PHP - by !damo!spiderman - 27.08.2015, 07:53
Re: SA-MP Gamemodes with PHP - by GWMPT - 27.08.2015, 21:03
Re: SA-MP Gamemodes with PHP - by katumas - 24.10.2015, 01:57
Re: SA-MP Gamemodes with PHP - by thanhlongcongtu - 11.12.2015, 13:41
Re: SA-MP Gamemodes with PHP - by t1ran - 21.12.2015, 11:52
Re: SA-MP Gamemodes with PHP - by katumas - 17.02.2016, 12:37
Re: SA-MP Gamemodes with PHP - by TutNichts - 18.02.2016, 15:37
Re: SA-MP Gamemodes with PHP - by CoaPsyFactor - 19.02.2016, 01:13
Re: SA-MP Gamemodes with PHP - by GWMPT - 19.02.2016, 08:48
Re: SA-MP Gamemodes with PHP - by katumas - 22.02.2016, 19:35
Re: SA-MP Gamemodes with PHP - by GWMPT - 23.02.2016, 15:22
Re: SA-MP Gamemodes with PHP - by BonhommeG - 23.02.2016, 16:14
Re: SA-MP Gamemodes with PHP - by BlackBank - 16.11.2016, 23:42
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 17.11.2016, 08:05
Re: SA-MP Gamemodes with PHP - by GWMPT - 17.11.2016, 10:04
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 17.11.2016, 11:38
Re: SA-MP Gamemodes with PHP - by BlackBank - 17.11.2016, 12:43
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 17.11.2016, 14:46
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 17.11.2016, 23:20
Re: SA-MP Gamemodes with PHP - by GWMPT - 18.11.2016, 08:45
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 10:23
Re: SA-MP Gamemodes with PHP - by GWMPT - 18.11.2016, 15:22
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 16:52
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 18.11.2016, 17:13
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 17:22
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 18.11.2016, 17:30
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 17:43
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 18.11.2016, 18:02
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 18:08
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 18:13
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 18.11.2016, 18:18
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 18:34
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 18.11.2016, 20:30
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 21:14
Re: SA-MP Gamemodes with PHP - by BlackBank - 18.11.2016, 21:15
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 18.11.2016, 21:18
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 18.11.2016, 23:10
Re: SA-MP Gamemodes with PHP - by BlackBank - 18.11.2016, 23:56
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 19.11.2016, 00:07
Re: SA-MP Gamemodes with PHP - by BlackBank - 19.11.2016, 00:52
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 19.11.2016, 00:59
Re: SA-MP Gamemodes with PHP - by BlackBank - 19.11.2016, 01:15
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 19.11.2016, 01:19
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 19.11.2016, 10:08
Re: SA-MP Gamemodes with PHP - by BlackBank - 19.11.2016, 14:33
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 19.11.2016, 15:37
Re: SA-MP Gamemodes with PHP - by BlackBank - 19.11.2016, 23:09
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 20.11.2016, 03:28
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 20.11.2016, 08:57
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 20.11.2016, 14:05
Re: SA-MP Gamemodes with PHP - by BlackBank - 20.11.2016, 18:18
Re: SA-MP Gamemodes with PHP - by TwinkiDaBoss - 20.11.2016, 20:47
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 21.11.2016, 11:29
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 22.11.2016, 21:50
Re: SA-MP Gamemodes with PHP - by thanhlongcongtu - 05.12.2016, 19:56
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 09.12.2016, 14:04
Re: SA-MP Gamemodes with PHP - by justjamie - 10.12.2016, 10:17
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 10.12.2016, 20:51
Re: SA-MP Gamemodes with PHP - by thanhlongcongtu - 13.12.2016, 23:57
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 14.12.2016, 14:02
Re: SA-MP Gamemodes with PHP - by GWMPT - 15.12.2016, 10:52
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 15.12.2016, 12:24
Re: SA-MP Gamemodes with PHP - by amirm3hdi - 25.06.2017, 12:39
Re: SA-MP Gamemodes with PHP - by DavidGravelli - 25.06.2017, 21:01
Re: SA-MP Gamemodes with PHP - by thanhlongcongtu - 04.10.2017, 22:06
Re: SA-MP Gamemodes with PHP - by Kaperstone - 04.10.2017, 23:40
Re: SA-MP Gamemodes with PHP - by thanhlongcongtu - 05.10.2017, 04:20

Forum Jump:


Users browsing this thread: 5 Guest(s)