Results 1 to 8 of 8
  1. #1

    Insane Limits: !join player (move to team/squad of player) command

    Quote Originally Posted by TMiland View Post
    Are there any limits for a
    Code:
    !join playername
    command?

    What i need is something like the opposite of the !recruit script, where a player with reserved slot can type the command to join a player.

    I have searched but found nothing i could use.

    I know AdKats has this function, but there's no way to automatically allow this for res. slots atm.

    Edit:
    And with unlock private squad, if thats possible.
    Note that many things can cause a move to fail, so set your expectations accordingly. At best, this gives VIPs a shot at joining a friend's squad, but it is not a guarantee.

    Also note that this limit can only unlock a squad, it can't restore a lock. So whoever does the joining will have to remind the squad leader to relock the squad, if desired.

    The playername typed into the command uses a loose match. So if the target is PapaCharlie9, any of the following would match:

    PapaCharlie9
    papacharlie9
    PAPACHARLIE9
    Papa
    Charlie
    Papac

    This also means that if there is a player called CharlieBrown, using 'Charlie' would match that as well, resulting in the "Too many matches' error. Just tell players using the command to keep trying, making the name closer to the literal target with each try. It's better to use a short prefix than a complete but misspelt name, e.g., papa is better than PapaCharlie8.

    Create a limit to evaluate OnAnyChat, call it "!join command".

    Set first_check to this Code:

    Code:
    Match m = Regex.Match(player.LastChat, @"^\s*[[email protected]]join\s+([^\s]+)", RegexOptions.IgnoreCase);
    if (!m.Success)
        return false;
    List<String> vips = plugin.GetReservedSlotsList();
    if (!vips.Contains(player.Name)) {
        plugin.SendPlayerMessage(player.Name, "You are not a VIP, you can't use the !join command!");
        return false;
    }
    // Match target player name
    String name = m.Groups[1].Value;
    List<PlayerInfoInterface> all = new List<PlayerInfoInterface>();
    all.AddRange(team1.players);
    all.AddRange(team2.players);
    all.AddRange(team3.players);
    all.AddRange(team4.players);
    PlayerInfoInterface target = null;
    int count = 0;
    foreach (PlayerInfoInterface p in all) {
        if (Regex.Match(p.Name, name, RegexOptions.IgnoreCase).Success) {
            target = p;
            ++count;
        }
    }
    if (count == 0 || target == null) {
        plugin.SendPlayerMessage(player.Name, "No player name matches '" + name + "'");
        return false;
    } else if (count > 1) {
        plugin.SendPlayerMessage(player.Name, "Too many names match '" + name + "', try again");
        return false;
    }
    
    // Force the squad to be unlocked
    plugin.ServerCommand("squad.private", target.TeamId.ToString(), target.SquadId.ToString(), "false");
    
    // Work the magic
    plugin.SendPlayerMessage(player.Name, "Killing you and sending you to " + target.Name + "'s squad!");
    plugin.MovePlayer(player.Name, target.TeamId, target.SquadId, true);
    return false;
    Last edited by PapaCharlie9; 05-01-2015 at 16:49.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  2. #2
    Hi Papa.

    I tested this limit and it's not working. Nothing happens and no messages are sent. When you look it over, please also adjust it to work with both the @join and !join commands. Thanks.

  3. #3
    Quote Originally Posted by IAF SDS View Post
    Hi Papa.

    I tested this limit and it's not working. Nothing happens and no messages are sent. When you look it over, please also adjust it to work with both the @join and !join commands. Thanks.
    I noticed that too, something with the regex maybe?

  4. #4
    Sorry about that. The regex was indeed incorrect. Try it now.

    EDIT: I added support for @join as well as !join.
    Last edited by PapaCharlie9; 05-01-2015 at 16:49.
    Don't send me private messages (PMs) unless you really need privacy, like your game server password. If you just have a question or need help, post in one of the threads. It's extra work for me to answer questions and give help in private messages and no one else gets the benefit of the answer.

  5. #5
    Quote Originally Posted by PapaCharlie9 View Post
    Sorry about that. The regex was indeed incorrect. Try it now.

    EDIT: I added support for @join as well as !join.
    No problem, Thank you, works great!

  6. #6
    Thanks for the fix Papa!

  7. #7
    thx PapaCharlie9 for code
    but can you change
    when i used @join he kill me and i moved from sq i want join
    i want he move me without kill me

  8. #8
    Quote Originally Posted by B7ackhawk View Post
    thx PapaCharlie9 for code
    but can you change
    when i used @join he kill me and i moved from sq i want join
    i want he move me without kill me
    Hi,

    long time since i have used this now, so i'm not sure, but according to the code it should move the player, and not kill.


    Code:
    plugin.MovePlayer(player.Name, target.TeamId, target.SquadId, true);
    Someone correct me if i'm wrong.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •