Wat is er fout? Variables gaan over elkaar heen voor geen enkele reden.
#1

Hallo freunden,

Ik ben een phone systeem aant maken waar je /sms worden opgeslagen, maar ik kwam tot ene hele rare ontdekking, ik zal jullie de code laten zien en de debug:

Code:
enum _phoneData
{
	phone_Contact[10],
	phone_Owner,
	phone_Messages[128],
	phone_TotalMessage,
	phone_text_Reciever[25],
	phone_text_Sender[25],
	phone_text_Taken,
	phone_ContactNumber,
	phone_ContactName[MAX_PLAYER_NAME],
	phone_Silenced
}
new PhoneData[MAX_PLAYERS][_phoneData];
new PhoneMessage[MAX_PLAYERS][_phoneData][MAX_STORED_TEXTS];
new PhoneContactData[MAX_PLAYERS][_phoneData][MAX_CONTACTS];
Code:
case DIALOG_PHONE_TEXT_NUMBER_INPUT:
		{
		    if (response)
		    {
		        new number = SMSPerson[playerid], target;
		        if (!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_PHONE_TEXT_NUMBER_INPUT, DIALOG_STYLE_INPUT, "Phone - Text", "Write down the message:", "Select", "Cancel");
		    
		        foreach(Player, i)
				{
				    if (CharacterData[i][pLoggedIn] && CharacterData[i][pPhoneNumber] == number)
					{
				    	target = i;
				    	break;
				    }
				    else return ErrorMessage(playerid, "You have entered an invalid number!");
				}
				new slot = -1;
				for (new t = 1; t < MAX_STORED_TEXTS; t ++)
				{
				    if (!PhoneMessage[target][phone_text_Taken][t])
				    {
						printf("Created SMS on slot: %d", t);
						slot = t;
						break;
				    }
				}

				if (slot == -1) return ErrorMessage(playerid, "That player's inbox is full!");
				if (PhoneOnline[target]) return ErrorMessage(playerid, "That player's phone is offline!");

                PhoneMessage[target][phone_text_Taken][slot] = 1;
				format(PhoneMessage[target][phone_Messages][slot], 128, "%s", inputtext);
				format(PhoneMessage[target][phone_text_Sender][slot], 25, "%s", PlayerRPName(playerid));
				format(PhoneMessage[target][phone_text_Reciever][slot], 25, "%s", PlayerRPName(target));

				TextLog(inputtext);
				PlayerPlaySound(target, 1052, 0.0, 0.0, 0.0);
				PlayerPlaySound(playerid, 1052, 0.0, 0.0, 0.0);

				PhoneData[target][phone_TotalMessage] ++;
				for (new t = 1; t < MAX_STORED_TEXTS; t ++)
				{
 					printf("%d) %s | %s | %s | %d | %d", t, PhoneMessage[target][phone_Messages][t], PhoneMessage[target][phone_text_Sender][t], PhoneMessage[target][phone_text_Reciever][t],PhoneMessage[target][phone_text_Taken][t], t);
				}
				return 1;
   			}
		    else
		    {
		        ShowPlayerDialog(playerid, DIALOG_PHONE, DIALOG_STYLE_LIST, "Phone", "Contacts\nCall\nText", "Select", "Close");
		    }
		}
Door een of andere reden past die niet alleen slot 1 aan in de enumerator maar allemaal?

Code:
09:18:53] Created SMS on slot: 1
[09:18:53] 1) Hello World! | Jayson | Jayson | 1 | 1
[09:18:53] 2) ello World! | ayson | ayson | 0 | 2
[09:18:53] 3) llo World! | yson | yson | 0 | 3
[09:18:53] 4) lo World! | son | son | 0 | 4
[09:18:53] 5) o World! | on | on | 0 | 5
[09:18:53] 6)  World! | n | n | 0 | 6
[09:18:53] 7) World! |  |  | 0 | 7
[09:18:53] 8) orld! |  |  | 0 | 8
[09:18:53] 9) rld! |  |  | 0 | 9
Reply
#2

<<<
new PhoneMessage[MAX_PLAYERS][_phoneData][MAX_STORED_TEXTS];
>>>
new PhoneMessage[MAX_PLAYERS][MAX_STORED_TEXTS][_phoneData];

Reden is dat je anders niet goed uitkomt met arrays. Nu heb je MAX_STORED_TEXTS aantal enums en anders heb je een enum als array
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)