1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. GTA Network forum is now in archive mode.

SAMP like ProxDetector

Discussion in 'Tutorials/Documentations' started by ZiiM, Dec 31, 2016.

  1. ZiiM

    ZiiM Member

    Messages:
    27
    Likes Received:
    5
    Joined:
    Dec 28, 2016
    Hello this is my first tutorial on GTA Network, anyways I am going to be showing how to make a samp like proxdetector, including fading text and all, going to be very easy to use and understand.


    Firstly you are going to need the proxdetector its self


    Code:
    public void ProxDetector(float radius, Client player, string message, string col1, string col2, string col3, string col4, string col5)
        {
            var players = API.getPlayersInRadiusOfPlayer(radius, player);
            foreach(Client c in players)
            {
                if(player.position.DistanceTo(c.position) <= radius / 16)
                {
                    API.sendChatMessageToPlayer(c, col1, message);
                }
                else if(player.position.DistanceTo(c.position) <= radius / 8)
                {
                    API.sendChatMessageToPlayer(c, col2, message);
                }
                else if (player.position.DistanceTo(c.position) <= radius / 4)
                {
                    API.sendChatMessageToPlayer(c, col3, message);
                }
                else if (player.position.DistanceTo(c.position) <= radius / 2)
                {
                    API.sendChatMessageToPlayer(c, col4, message);
                }
                else if (player.position.DistanceTo(c.position) <= radius)
                {
                    API.sendChatMessageToPlayer(c, col5, message);
                }
            }
        }
    
    Col1, is the color of text for the closest group of people and col5 is the color of text for the group of people farthest away from you.

    The proxdetector will send a fading style message to people within the specified radius.
    How to use the ProxDetector

    Code:
    ProxDetector(float radius, Client player, string message, string col1, string col2, string col3, string col4, string col5)
    To apply this to a use in a server would be like:


    Code:
        [Command("me", GreedyArg = true)]
        public void MeCommand(Client sender, string text)
        {
            ProxDetector(30, sender, "* " + sender.name + " " + text, "~#C2A2DA~", "~#C2A2DA~", "~#C2A2DA~", "~#C2A2DA~", "~#C2A2DA~");
        }
    But the above command would not include fading text. For a more practicul use of this would be for every chat line someone says, it fades the text for people and limits how many people can hear it. In order to do this we first must get the event. We can do that by inputting this:

    Code:
    public MainScript()
        {
            API.onChatMessage += onSentMessage;
        }
    The above could would now let us edit the event. We can get the event by now creating a method for onSentMessage.


    Code:
    public void onSentMessage(Client player, string message, CancelEventArgs e)
    {
    
    }
    Now that we have that out of the way, we can now change what will show up for players.


    Code:
        public void onSentMessage(Client player, string message, CancelEventArgs e)
        {
            ProxDetector(30, player, player.name.Replace("_", " ")+ " says: " + message, "~#FFFFFF~", "~#C8C8C8~", "~#AAAAAA~", "~#8C8C8C~", "~#6E6E6E~");
            e.Cancel = true;
            return;
        }
    The above code will send a fading style of local message to each player within 30f of the player. It will replace an _ in there name and replace it with a " ", then will send the message.

    Hope you enjoyed, please share your feedback. :=D

    P.S I was going to make this tutorial earlier but went to grab the proxdetector from code and found out my entire desktop, downloads and all where deleted. Fuck like I know how, just happened while I was watching a video, had my server on my desktop so that fucked me right off, anyways hope you enjoyed :=D.
     
    Last edited: Jan 12, 2017
  2. Jack

    Jack Member Donator

    Messages:
    31
    Likes Received:
    15
    Joined:
    Jan 3, 2017
    Looks good!
     
  3. Theory

    Theory aka Austin Global Moderator Wiki Moderator Developer

    Messages:
    59
    Likes Received:
    25
    Joined:
    Aug 6, 2016
    Vector3 has a function called DistanceTo that takes in another Vector3. That would simplify your code.
     
  4. ZiiM

    ZiiM Member

    Messages:
    27
    Likes Received:
    5
    Joined:
    Dec 28, 2016
    Oh shit, alright I will update this when I get around to it, thanks :=D
     
  5. ZiiM

    ZiiM Member

    Messages:
    27
    Likes Received:
    5
    Joined:
    Dec 28, 2016
    Updated with DistanceTo instead of isinrangeof
     
    Theory likes this.
  6. Jorge Santamaria

    Jorge Santamaria Member

    Messages:
    38
    Likes Received:
    7
    Joined:
    Dec 8, 2016
    With the last update of the client / server, this system no longer works.
     
  7. Theory

    Theory aka Austin Global Moderator Wiki Moderator Developer

    Messages:
    59
    Likes Received:
    25
    Joined:
    Aug 6, 2016
    What? None of the functionality in this was removed.
     
  8. ZiiM

    ZiiM Member

    Messages:
    27
    Likes Received:
    5
    Joined:
    Dec 28, 2016
    Tested it yesterday and was still working...
     
  9. Jorge Santamaria

    Jorge Santamaria Member

    Messages:
    38
    Likes Received:
    7
    Joined:
    Dec 8, 2016
    [Quote = "ZiiM, mensaje: 9536, miembro de 2212"] Probado ayer y todavĂ­a estaba trabajando ... [/ quote]
    Then I think the problem is just mine ... :S

    PS:
    You're not going to believe it, but I just logged into my server and it suddenly magically works. I have not fixed ANYTHING ...

    Life things...
     
    Last edited: Jan 27, 2017
  10. xpeedo

    xpeedo Member

    Messages:
    7
    Likes Received:
    2
    Joined:
    Jan 14, 2017

Share This Page