SA-MP Forums Archive
for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - 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: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 (/showthread.php?tid=638504)



for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - Lirbo - 01.08.2017

PHP код:
for(new iMAX_PLAYERSi++) Message(iTYPE_SERVER"FWEKOGE"); 
is working only for id 0 to me for some reason, any ideas?


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - OneDay - 01.08.2017

What is Message?


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - Omirrow - 01.08.2017

Quote:
Originally Posted by Lirbo
Посмотреть сообщение
PHP код:
for(new iMAX_PLAYERSi++) Message(iTYPE_SERVER"FWEKOGE"); 
is working only for id 0 to me for some reason, any ideas?
I'm a hundred percent sure; the issue is about your "Message" function.
Can we see it?


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - Lirbo - 01.08.2017

Quote:
Originally Posted by OneDay
Посмотреть сообщение
What is Message?
Quote:
Originally Posted by Omirrow
Посмотреть сообщение
I'm a hundred percent sure; the issue is about your "Message" function.
Can we see it?
There is no problem with Message, I did the same for SendClientMessage(i, -1 , "j");

Message works perfectly..


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - HoussamMaroc - 01.08.2017

i have fixed it
PHP код:
foreach(new iPlayer) if(IsPlayerConnected(i)) Message(iTYPE_SERVER"FWEKOGE"); 
the message send to all connected players

Note: you will get a Error(indefined symbol "foreach") if you don't add #include foreach


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - Xeon™ - 02.08.2017

Quote:
Originally Posted by HoussamMaroc
Посмотреть сообщение
i have fixed it
PHP код:
foreach(new iPlayer) if(IsPlayerConnected(i)) Message(iTYPE_SERVER"FWEKOGE"); 
the message send to all connected players

Note: you will get a Error(indefined symbol "foreach") if you don't add #include foreach
No, just no. foreach is outdated and unstable. you must use the one in YSI.


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - HoussamMaroc - 02.08.2017

Quote:
Originally Posted by XeonMaster
Посмотреть сообщение
No, just no. foreach is outdated and unstable. you must use the one in YSI.
#include YSI/?


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - oMa37 - 02.08.2017

Quote:
Originally Posted by XeonMaster
Посмотреть сообщение
No, just no. foreach is outdated and unstable. you must use the one in YSI.
Wait what? Foreach/y_Iterate is the fastest and the most stable loop to use.

OT: Just use GetPlayerPoolSize() loop if you don't want to use foreach.
if this didn't work, the issue must be from your function.


Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - OneDay - 02.08.2017

Quote:
Originally Posted by HoussamMaroc
Посмотреть сообщение
i have fixed it
PHP код:
foreach(new iPlayer) if(IsPlayerConnected(i)) Message(iTYPE_SERVER"FWEKOGE"); 
the message send to all connected players

Note: you will get a Error(indefined symbol "foreach") if you don't add #include foreach
no IsPlayerConnected just

PHP код:
foreach(new PlayerMessage(iTYPE_SERVER"FWEKOGE"); 



Re: for(new i; i< MAX_PLAYERS; i++) goes only for id 0 - Arbico - 02.08.2017

Guys guys guys, i'm sure this guy is in the server alone, the first id is 0, and it works with 0 only, because he is the only one in the server, i'm pretty sure if you add more people it would work