SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 03/09/2009, 12:52 PM   #1
kevin974
Big Clucker
 
Join Date: Aug 2008
Posts: 126
Reputation: 0
Default [SOLVED] For statement messes up

Code:
//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
kevin974 is offline  
Old 03/09/2009, 02:31 PM   #2
Correlli
Godfather
 
Correlli's Avatar
 
Join Date: May 2009
Location: Slovenia
Posts: 6,340
Reputation: 365
Default Re: [HELP] For statement messes up

I think the problem is here:
pawn Code:
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.
Correlli is offline  
Old 03/09/2009, 02:48 PM   #3
kevin974
Big Clucker
 
Join Date: Aug 2008
Posts: 126
Reputation: 0
Default Re: [HELP] For statement messes up

Works now, Lol thanks for the help.
kevin974 is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED]for loop statement - unknown command [zcmd] king s dm Help Archive 6 04/06/2010 10:18 AM
1 include messes up server killar456 Help Archive 12 15/09/2009 02:18 PM
Once again SAMP messes up. markprendo Client Support 3 29/08/2009 05:51 PM
The all-flawed PAWN messes up again... DMSOrg Help Archive 7 15/02/2009 01:30 PM
if and or ( || ) statement help StrickenKid Help Archive 1 08/02/2009 05:39 AM


All times are GMT. The time now is 12:23 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.