Log in to reply
 

[TUTORIAL | C#.NET] Interaction Markers [w/ Teleport, Ring Marker, DisplayName & Blips]



  • So i made a little script only with teleports that i wanted, just to fill in a little my SPgame, so i just wanted to share the code i used, so more of you can customize your gta to your own way, this can easily be adapted to restore life, give money, etc, u only need to replace the teleport command for wahttever u waaaanttt ! have fun.
    alt text

      //so first we will create 2 Vectors for our teleports
    
     /* This is located in Franklins Rich House, on the right door of the garage ,
      go inside, you will find it at your left   */
      Vector3 marker1 = new Vector3(29.0000f, 538.6783f, 175f); 
     
       /* This is located at Groove Street facing the end of the street,
      it is at your right, in front of some garage door*/
      Vector3 marker2 = new Vector3(47.8523f, -1912.992f, 20.8000f);
    
     /*then we create some blips for our Teleports*/
        Blip bl = World.CreateBlip(marker1, 3f);
        bl.Color = BlipColor.Green;
        bl.Name = "Teleport to: Groove Street";
    
        Blip bl2 = World.CreateBlip(marker2, 3f);
        bl2.Color = BlipColor.Green;
        bl2.Name = "Teleport to: Franklins House";
    

    #/ on your OnTickEvent /#

    Tick += (o, e) =>
        {
           if (playerPed.IsAlive && playerPed.IsVisible && !playerPed.IsDead)
            {
                 //Draw the Yellow Ring Marker with Name at Groove Street
                World.DrawMarker(MarkerType.VerticalCylinder, marker2, Vector3.Zero, Vector3.Zero, new Vector3(1f, 1f, 2f), Color.Yellow);
                //Draw the 3D DisplayName for this marker
                 var tmpSFs = new Scaleform("PLAYER_NAME_02");
                 tmpSFs.CallFunction("SET_PLAYER_NAME", "Casa do Franklin");
                 tmpSFs.Render3D(marker2 + new Vector3(0f, 0f, 2f), new Vector3(1f, -141f, 1f), new Vector3(12, 6, 2));
    
                //Draw the Yellow Ring Marker at Franklins House
                 World.DrawMarker(MarkerType.VerticalCylinder, marker1, Vector3.Zero, Vector3.Zero, new Vector3(1f, 1f, 2f), Color.Yellow);
                 //Draw the 3D DisplayName for this marker
                 var tmpSF = new Scaleform("PLAYER_NAME_01");
                 tmpSF.CallFunction("SET_PLAYER_NAME", "Groove Street");
                 tmpSF.Render3D(marker1 + new Vector3(0f, 0f, 2f), new Vector3(1f, 66f, 1f), new Vector3(12, 6, 2));
              }
        }
    

    #/ Interaction with Marker in OnTickEvent for Controller/#

        /*if the player ped is in range of marker1 location display tooltip and waits for keyinput*/
        if (World.GetDistance(playerPed.Position, marker1) < 1.5000f)
                {
                    toolTip("Pressione ~INPUT_DETONATE~ para ir para 'Groove Street'");
                  
                        if (Game.IsControlPressed(2, GTA.Control.FrontendLeft))
                        {
                          try
                           {
                            //teleport to location
                             playerPed.Position = marker2 + new Vector3(1.5f, 1.5f, 0f);
                            }
                            catch { UI.Notify("ERRO! H"); }
                        }
                }
               
        /*if the player ped is in range of marker2 location display tooltip and waits for keyinput*/
                if (World.GetDistance(playerPed.Position, marker2) < 1.5000f)
                {
                    toolTip("Pressione ~INPUT_DETONATE~ para ir para 'Casa do Franklin'");
                      
                        if (Game.IsControlPressed(2, GTA.Control.FrontendLeft))
                        {
                            try
                            {
                               //teleport to location
                                playerPed.Position = marker1 - new Vector3(1.5f, 1.5f, 0f);
                             }
                                catch { UI.Notify("ERRO! H"); }
                          }
                 }
    

    #/ Interaction with Marker in OnKeyDown for KeyBoard/#

        /*if the player ped is in range of marker1 location display tooltip and waits for keyinput*/
        if (World.GetDistance(playerPed.Position, marker1) < 1.5000f)
                {
                    toolTip("Pressione ~INPUT_DETONATE~ para ir para 'Groove Street'");
                  
                        if (e.KeyCode == Keys.Z)
                        {
                          try
                           {
                            //teleport to location
                             playerPed.Position = marker2 + new Vector3(1.5f, 1.5f, 0f);
                            }
                            catch { UI.Notify("ERRO! H"); }
                        }
                }
               
        /*if the player ped is in range of marker2 location display tooltip and waits for keyinput*/
                if (World.GetDistance(playerPed.Position, marker2) < 1.5000f)
                {
                    toolTip("Pressione ~INPUT_DETONATE~ para ir para 'Casa do Franklin'");
                      
                        if (e.KeyCode == Keys.Z)
                        {
                            try
                            {
                               //teleport to location
                                playerPed.Position = marker1 - new Vector3(1.5f, 1.5f, 0f);
                             }
                                catch { UI.Notify("ERRO! H"); }
                          }
                 }          
    

    #/ for ToolTip // OPTIONAL/#

    void toolTip(string text)
    {
        Function.Call(Hash._SET_TEXT_COMPONENT_FORMAT, "STRING");
        Function.Call(Hash._ADD_TEXT_COMPONENT_STRING, text);
        Function.Call(Hash._0x238FFE5C7B0498A6, 0, 0, 1, -1);
    }


  • Is there a way to remove the Markers?



  • @Reazer Just don't call them when you don't want them to appear.

    if(showMarkers == true)
    {
    World.DrawMarker(......)
    }
    

    When the showMarkers bool is not true, the markers will not be drawn.



  • Can someone explain to me how the code builds up, since it's kinda confusing to me at least, as I am quite new to this. If Anyone can that is?



  • This post is deleted!

  • MODERATOR

    @preto89 said in [TUTORIAL | C#.NET] Interaction Markers [w/ Teleport, Ring Marker, DisplayName & Blips]:

    Vector3 marker1 = new Vector3(29.0000f, 538.6783f, 175f);

    Can you please tell mw how these Vector3 thingies work? Iirc, looks like those are regular cartesian coordinates inside the range of Fanklin's house; but what if the f for?



  • @meimeiriver "f" just means "float".


  • MODERATOR

    @stillhere said in [TUTORIAL | C#.NET] Interaction Markers [w/ Teleport, Ring Marker, DisplayName & Blips]:

    @meimeiriver "f" just means "float".

    LOL. I'm such a moobrain. :P I thought it meant 'Feet' or something.


  • MODERATOR

    @stillhere said in [TUTORIAL | C#.NET] Interaction Markers [w/ Teleport, Ring Marker, DisplayName & Blips]:

    @Reazer Just don't call them when you don't want them to appear.

    if(showMarkers == true)
    {
    World.DrawMarker(......)
    }
    

    When the showMarkers bool is not true, the markers will not be drawn.

    I don't like visible markers (like the MapEditor cones). And instead of having to figure suitable coordinates 1.5 Fee.. err, meters adjacent from the markers (to prevent 'bobbing'), I just slightly changed things to add a bool, so you can TP directly to the markers, with 'bobbing' protection (aka, you won't get teleported again until you have stepped out of the target marker range first; like MapEditor does).

            if (playerPed.IsAlive && playerPed.IsVisible && !playerPed.IsDead)
            {
                if (World.GetDistance(playerPed.Position, down_marker) < 1.5f)
                {
                    if (bobbing == false)
                    {
                        try
                        {
                             bobbing = true;
                             playerPed.Position = up_marker;
                        }
                        catch { UI.Notify("ERRO! H"); }
                    }
                }
                else if (World.GetDistance(playerPed.Position, up_marker) < 1.5f)
                {
                    if (bobbing == false)
                    {
                        try
                        {
                             bobbing = true;
                             playerPed.Position = down_marker;
                        }
                        catch { UI.Notify("ERRO! H"); }
                    }
                }
                else
                {
                    bobbing = false;
                }
            }

  • MODERATOR

    @preto89 Thank you for this tutorial. btw! Now that I can set up my own TP points (thanks to you), and having figured out how to 'RemoveFromWorld' objects (studying the Map Editor code), I now don't need Map Editor for anything, ever again. :) Which means I can finally remove it from my install.


  • MODERATOR

    I slighty adapted things a bit further (from my code above), to do a more clean TP. Adds a ped heading to the destination, and sets the camera in that direction too. Like:

                    if (bobbing == false)
                    {
                        try
                        {
                             bobbing = true;
                             playerPed.Position = to_heli;
                             playerPed.Heading = 180;
                             Function.Call(Hash.SET_GAMEPLAY_CAM_RELATIVE_HEADING, 0);
                        }
                        catch { UI.Notify("ERRO! H"); }
                    }


  • I want to make a script to lock/unlock door/gate. But I dont know how to select a door in my front. And if I can do this, I think, the next step be turn objetic in static or dynamic.
    But, my problem is, how to select a door in my front to apply this changes?
    Thanks, anyway guys xD


Log in to reply
 

Looks like your connection to GTA5-Mods.com Forums was lost, please wait while we try to reconnect.