SA-MP Forums Archive
Script not working for "player 2" - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Script not working for "player 2" (/showthread.php?tid=533857)



Script works for base player only. - Aerotactics - 26.08.2014

Player 1 (ID 0): everything in the script works exactly as it should.

Player 2 (ID 1): no camera movement, when going into camera mode, camera always faced the sky.





Pastebin


Re: Script not working for "player 2" - Aerotactics - 27.08.2014

Bump (been 24 hours, no reply)


Re: Script not working for "player 2" - Aerotactics - 27.08.2014

Quote:
Originally Posted by ******
Посмотреть сообщение
Put your code on pastebin - people can't copy, modify, or test an image. Plus, they are larger.
Added


Re: Script not working for "player 2" - [XST]O_x - 27.08.2014

I believe this is the problem:
pawn Код:
new CamSet[MAX_PLAYERS];
new bool:CamEnabled[MAX_PLAYERS] = false;
new PlayerLock[MAX_PLAYERS] = -1;
new CamSpeed[MAX_PLAYERS] = 3;
new PlayerCatch[MAX_PLAYERS][6];
new FlyTimer[MAX_PLAYERS];
new BoxCount[MAX_PLAYERS] = 0;
When giving arrays a default value, you can't just put array[20] = value. It won't work.

To actually initialize an array, you have to do:
pawn Код:
new CamSet[MAX_PLAYERS];
new bool:CamEnabled[MAX_PLAYERS] = {false, ...};
new PlayerLock[MAX_PLAYERS] = {-1, ...};
new CamSpeed[MAX_PLAYERS] = {3, ...};
new PlayerCatch[MAX_PLAYERS][6];
new FlyTimer[MAX_PLAYERS];
new BoxCount[MAX_PLAYERS] = {0, ...};
Or else it'll only put the value in the first array cell, that's why only player ID 0 (first cell) works.
That's my theory, however.


Re: Script not working for "player 2" - Aerotactics - 27.08.2014

Excellent theory. Makes sense. I'll try it out when I return home. Thanks.