SA-MP Forums Archive
Global Chat ingame error - 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: Global Chat ingame error (/showthread.php?tid=676444)



Global Chat ingame error - SkyFlare - 09.06.2020

So it seems I keep having the same problems over and over in my Gamemode...
I have Sandboxie, so I am able to test if my functions are working, and majority are...
Unfortunately I keep having this specific error, I am wondering if its not actually linked to what I am doing, but more deeper issue, anyway if there is an issue in my code, can someone please help me find it.

- Player 1 Joins Server (ID 0)
- Player 2 Joins Server (ID 1)

Player 1(ID 0) Sends Message in /globalchat
-Player 1(ID 0) Can see the Message.
-Player 2(ID 1) Can see the Message.

Player 2(ID 1) Sends Message in /globalchat
-Player 1(ID 0) Can see the Message.
-Player 2(ID 1) Can NOT see the Message.

I Have had problems in the past, where the experience of ID 0, is not the same as id 1+

FIXED!
Code:
 foreach(Player, i) if(Player[i][ToggledGlobalChat] == 0) SendClientMessage(i, -1, string);



Re: Global Chat ingame error - Fairuz - 09.06.2020

You are using the deprecated method of foreach, just a heads up..


Re: Global Chat ingame error - SkyFlare - 09.06.2020

Quote:
Originally Posted by Fairuz
View Post
You are using the deprecated method of foreach, just a heads up..
How is it deprecated? can you show me a better method please?


Re: Global Chat ingame error - Adamoneoone - 09.06.2020

Code:
foreach(Player, i)
is the old way to use foreach.
Code:
foreach(new i:Player)
is how you'd want to do it.


Re: Global Chat ingame error - SkyFlare - 09.06.2020

Quote:
Originally Posted by Adamoneoone
View Post
Code:
foreach(Player, i)
is the old way to use foreach.
Code:
foreach(new i:Player)
is how you'd want to do it.
What does that do? apart from the obvious making a new integer value named i? what benefits does it reap?