Wont apear
#1

hey guys i have this dialog but when i use it on me you should get a message like "you can't add yourself" but is not giving me that message is giving me "you can't add offline players" instead of the right message "you can't add yourself" some help ?

Код HTML:
if(dialogid == DIALOG_ADDFRIENDS)
		{
			if(response)
			{
    			new text[50];
				mysql_real_escape_string(inputtext, text);
    			if(IsNumeric(text))
				{
					new find = 0;
					foreach(Player, i)
					{
						if(IsPlayerConnected(i))
						{
							if(find == 0)
							{
								new name[30],str1[256];
								GetPlayerName(i, name, sizeof(name));
								if(strfind(name, text) != -1)
								{
									find = 1;
									if(i == playerid) return SendClientMessage(playerid, COLOR_WHITE, "Nu te poti adauga pe tine insuti.");
									format(str1, sizeof(str1), "SELECT * FROM `friends` WHERE `FriendID`='%d' AND `PlayerID`='%d'",PlayerInfo[i][pSQLID],PlayerInfo[playerid][pSQLID]);
									new Cache: membresult = mysql_query(SQL,str1);
									if(cache_get_row_count () > 0)
									{
										SendClientMessage(playerid, COLOR_WHITE, "Acel jucator este deja in lista ta de prieteni.");
										return 1;
									}
									cache_delete(membresult);
									mysql_format(SQL, str1, sizeof(str1), "INSERT INTO `friends` (`PlayerID`,`FriendID`,`FriendName`) VALUES('%d','%d','%s')",PlayerInfo[playerid][pSQLID],PlayerInfo[i][pSQLID],PlayerInfo[i][pNormalName]);
									mysql_tquery(SQL,str1,"","");
									SendClientMessage(playerid, COLOR_YELLOW, "Prieten adaugat!");
								}
							}
						}
						else return SendClientMessage(playerid, COLOR_WHITE, "ID invalid. Poti adauga doar playerii care-s online in lista de prieteni.");
					}
					if(find == 0)
					{
						SendClientMessage(playerid, COLOR_WHITE, "ID invalid. Poti adauga doar playerii care-s online in lista de prieteni.");
					}
				}
			}
		}
Reply
#2

Please convert it to english
Reply
#3

There's a lot of flaws at first sight.

- No need for a loop as you already have the player's ID
- You're sending a message if a player isn't connected, but foreach only loops through connected players
- Etc.

--------------

Fix: Change "if(i == playerid)" to "if(text == playerid)".

Remove the strfind line. I don't know, it's a mess :/. You're comparing a name with an ID, how I know it's an ID is because you use it in IsNumeric.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)