[SOLVED] For statement messes up - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [SOLVED] For statement messes up (
/showthread.php?tid=95308)
[SOLVED] For statement messes up -
kevin974 - 03.09.2009
Код:
//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
Re: [HELP] For statement messes up -
Correlli - 03.09.2009
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.
Re: [HELP] For statement messes up -
kevin974 - 03.09.2009
Works now, Lol thanks for the help.