Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static void AcceipFriendRequest(Player player, int id)
- {
- FriendsVar FR = null;
- foreach(FriendsVar F in PLAYER_FIREND_LIST)
- {
- if(F.FOwner == Fun.GetPlayerSqlID(player))
- {
- if(F.FFriend == id)
- {
- FR = F;
- break;
- }
- }
- }
- if(FR != null)
- {
- FR.FriendStatus = 1;
- using (var conns = Database.FriendsConn)
- {
- conns.Open();
- string Query = "UPDATE friends SET friendstatus = @friendstatus WHERE id = @id";
- using (MySqlCommand command = new MySqlCommand(Query, conns))
- {
- command.Parameters.AddWithValue("@friendstatus", FR.FriendStatus);
- command.Parameters.AddWithValue("@id", FR.FID);
- command.ExecuteNonQuery();
- }
- conns.Close();
- }
- Player Target = null;
- foreach(Player P in NAPI.Pools.GetAllPlayers())
- {
- if(id == Fun.GetPlayerSqlID(P))
- {
- if (Fun.IsPlayerLoggedIn(P))
- {
- Target = P;
- break;
- }
- }
- }
- if(Target != null)
- {
- using (var conns = Database.FriendsConn)
- {
- conns.Open();
- string Query = $"INSERT INTO `frends` (`owner`, `friend`, `friendstatus`, `mute`) VALUES(@owner, @friend, @friendstatus, @mute)";
- using (MySqlCommand command = new MySqlCommand(Query, conns))
- {
- command.Parameters.AddWithValue("@owner", Fun.GetPlayerSqlID(Target));
- command.Parameters.AddWithValue("@friend", Fun.GetPlayerSqlID(player));
- command.Parameters.AddWithValue("@friendstatus", 1);
- command.Parameters.AddWithValue("@mute", 0);
- command.ExecuteNonQuery();
- FriendsVar Friend = new FriendsVar();
- Friend.FFriend = Fun.GetPlayerSqlID(player);
- Friend.FOwner = Fun.GetPlayerSqlID(Target);
- Friend.FriendStatus = 1;
- Friend.FMute = 0;
- Friend.FID = (int)command.LastInsertedId;
- PLAYER_FIREND_LIST.Add(Friend);
- Fun.SendNotification(Target, $"~y~{player.Name} ~w~has accept your friend request.");
- }
- conns.Close();
- }
- }
- else
- {
- using (var conns = Database.FriendsConn)
- {
- conns.Open();
- string Query = $"INSERT INTO `frends` (`owner`, `friend`, `friendstatus`, `mute`) VALUES(@owner, @friend, @friendstatus, @mute)";
- using (MySqlCommand command = new MySqlCommand(Query, conns))
- {
- command.Parameters.AddWithValue("@owner", id);
- command.Parameters.AddWithValue("@friend", Fun.GetPlayerSqlID(player));
- command.Parameters.AddWithValue("@friendstatus", 1);
- command.Parameters.AddWithValue("@mute", 0);
- command.ExecuteNonQuery();
- }
- conns.Close();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment