probelm with foreach +Repp
#1

sry guys but why this happeing for me ?

Код:
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 017: undefined symbol "foreach"
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 029: invalid expression, assumed zero
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 017: undefined symbol "i"
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : fatal error 107: too many error messages on one line
And This Is The Line's :

PHP код:
//This Is Line 2812  if(listitem == 0) {foreach(new i : Player)if(IsPlayerConnected(i))SetPlayerTime(i,7,0);}
               
if(listitem == 1) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,12,0);}
               if(
listitem == 2) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,16,0);}
               if(
listitem == 3) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,20,0);}
               if(
listitem == 4) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,0,0); } 
Reply
#2

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
sry guys but why this happeing for me ?

Код:
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 017: undefined symbol "foreach"
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 029: invalid expression, assumed zero
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 017: undefined symbol "i"
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : fatal error 107: too many error messages on one line
And This Is The Line's :

PHP код:
//This Is Line 2812  if(listitem == 0) {foreach(new i : Player)if(IsPlayerConnected(i))SetPlayerTime(i,7,0);}
               
if(listitem == 1) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,12,0);}
               if(
listitem == 2) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,16,0);}
               if(
listitem == 3) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,20,0);}
               if(
listitem == 4) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,0,0); } 
You don't have to do IsPlayerConnected.. foreach does that for you..
And also try making ur code more readable, Like:
PHP код:
new time;
switch(
listitem)
{
    case 
0time 7;
    case 
1time 12;
    case 
2time 16;
    case 
3time 20;
    case 
4time 0;
}
foreach(new 
PlayerSetPlayerTime(playeridtime0); 
Reply
#3

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
sry guys but why this happeing for me ?

Код:
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 017: undefined symbol "foreach"
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 029: invalid expression, assumed zero
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : error 017: undefined symbol "i"
C:\Users\KaTA\Desktop\samp training\Test\gamemodes\Test.pwn(2812) : fatal error 107: too many error messages on one line
And This Is The Line's :

PHP код:
//This Is Line 2812  if(listitem == 0) {foreach(new i : Player)if(IsPlayerConnected(i))SetPlayerTime(i,7,0);}
               
if(listitem == 1) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,12,0);}
               if(
listitem == 2) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,16,0);}
               if(
listitem == 3) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,20,0);}
               if(
listitem == 4) {foreach(new Player)if(IsPlayerConnected(i))SetPlayerTime(i,0,0); } 
PHP код:
 if(listitem == 1) {
      foreach(new 
Player) { // <- Add it {
         
if(IsPlayerConnected(i)) SetPlayerTime(i,12,0);
      }

Note: In cycles "for, while" it is always better to put {. Example: for () { ... }
Reply
#4

Thanks Both For Your Fast Help's But Still Giving That Error's
Reply
#5

PHP код:
#include a_samp
#include foreach
#define mydialog 6935
  
  
public OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
     if(
dialogid == mydialog)
        {
        if(
response)
                {
          new 
time;
          switch(
listitem)
          {
          case 
0time 7;
          case 
1time 12;
          case 
2time 16;
          case 
3time 20;
          case 
4time 0;
          }
          foreach(new 
PlayerSetPlayerTime(playeridtime0);
        }
     }
     return 
1;
 } 
Reply
#6

Do you have y_iterate installed ?
Reply
#7

If you have YSI then just add the following line in your includes:
pawn Код:
#include <YSI\y_iterate>
If you don't have YSI, get it then add the line above.
Reply
#8

i just download that foreach and it worked :S

Thanks all for help
Reply
#9

Quote:
Originally Posted by khRamin78
Посмотреть сообщение
i just download that foreach and it worked :S

Thanks all for help
Which one? If you chose the standalone you should really look into YSI. The latest y_iterate (which is the better version of foreach) is a lot better and contains a lot of new features.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)