Help with friends sistem
#1

How I can put a restriction that a player who is already in the list of friends and wants to add him and to give him a message like this: You already have that player on your list . I wrote something but do not know how to put restriction can someone help me ?

Код:
public AddFriend(playerid, friend[])
{
	if(IsPlayerConnected(playerid))
	{
		new playername[25];
		GetPlayerName(playerid,playername,sizeof(playername));
		if(strlen(friend) == strlen(playername)) return SendClientMessage(playerid,-1,"{FFB870}Erorr: You can't add you in friend list.");
		{
			new cont;
			cont = MySQLCheckAccount(friend);
			if(cont == 0) return SendClientMessage(playerid,-1,"{FFB870}Erorr: This name does not exist.");
			//SendClientMessage(playerid,-1,"{FFB870}Erorr: You already friend with that player."); 
			new playername3[MAX_PLAYER_NAME];
			GetPlayerName(playerid, playername3, sizeof(playername3));
			new Str[200];
			format(Str,sizeof(Str),"INSERT INTO `friends` (`user`,`friend`) VALUES ('%s','%s')",playername3,friend);
			mysql_query(SQL,Str);
			strmid(FriendsInfo[playerid][pFriendName], friend, 0, strlen(friend), 255);
			new string[128];
			format(string,sizeof(string),"{FFB870}You succesfully added %s on your friends list.",friend);
			SendClientMessage(playerid,-1,string);
		}	
		return 1;
	}
	return 1;
}
Reply
#2

Anyone?
Reply
#3

PHP код:
forward MySQLCheckFriend(player[], friend[]);
public 
MySQLCheckFriend(player[], friend[])
{
    new 
query[128], escstr[MAX_PLAYER_NAME], escstr2[MAX_PLAYER_NAME];    
    
    
mysql_real_escape_string(playerescstr);
    
mysql_real_escape_string(friendescstr2);
    
    
format(querysizeof(query), "SELECT * FROM friends WHERE user = '%s' and friend = '%s'"escstrescstr2);
    
mysql_query(SQLquery);
    
    
mysql_store_result();
    
    if(
mysql_num_rows())
    {
        new 
strid[32];
        
        
mysql_fetch_row(strid);
        
        new 
intid strval(strid);
        
        
mysql_free_result();
        return 
intid;
    }
    else
    {
        
mysql_free_result();
        return 
0;
    }

Incearca asta.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)