[SOLVED] For statement messes up
#1

Код:
//in a command
SendClientMessage(playerid, COLOR_LIME, "----- CONTACTS -----");
for(new c = 0; c <= 8; c++)
{
   SendFormattedMessage(playerid, COLOR_WHITE, "%d] %s - %d", c++, GetPlayerNameByPhone(Contacts[playerid][c]), GetPlayerPhoneByName(playerid));
}

//functions

stock GetPlayerNameByPhone(phonenumb)
{
  new phone[64], pname[MAX_PLAYER_NAME]="Nobody";
  for(new i = 0; i <= MAX_PLAYERS; i++){
		format(phone, sizeof(phone), "/Phones/%s.dini.save", GetName(i));
	  if(dini_Exists(phone)){
			if(Phone[i][pPhoneNumber] == phonenumb) return GetName(i);
		} }
	return pname;
}

stock GetPlayerPhoneByName(name[MAX_PLAYER_NAME])
{
	new phone[64];
	format(phone, sizeof(phone), "/Phones/%s.dini.save", name);
	if(strcmp(name,"Nobody", false ) != 0){
	  if(dini_Exists(phone)){
		  return dini_Int(phone, "Number");
		} }
	return 255;
}
Well i want this command to loop 0 - 8 and tell me the info. It does that somewhat.
But instead it goes 0, 2, 3, 4, 8. Instead of 0, 1, 2, 3, 4, 5, 6, 7, 8
Reply
#2

I think the problem is here:
pawn Код:
for(new c = 0; c <= 8; c++)
{
   SendFormattedMessage(playerid, COLOR_WHITE, "%d] %s - %d", c++, GetPlayerNameByPhone(Contacts[playerid][c]), GetPlayerPhoneByName(playerid));
}
You do c++ in for loop, that's good, but there is c++ once again in SendFormattedMessage function. Just remove the ++, leave the c.
Reply
#3

Works now, Lol thanks for the help.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)