Log in to reply
 

How to draw Marker (c++)?



  • How can I draw a Marker?

    static void DRAW_MARKER(int type, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, float rotX, float rotY, float rotZ, float scaleX, float scaleY, float scaleZ, int red, int green, int blue, int alpha, BOOL bobUpAndDown, BOOL faceCamera, int p19, BOOL rotate, char* textureDict, char* textureName, BOOL drawOnEnts) { invoke<Void>(0x28477EC23D892089, type, posX, posY, posZ, dirX, dirY, dirZ, rotX, rotY, rotZ, scaleX, scaleY, scaleZ, red, green, blue, alpha, bobUpAndDown, faceCamera, p19, rotate, textureDict, textureName, drawOnEnts); } // 0x28477EC23D892089 0x48D84A02

    0x28477ec23d892089, 0xbdd6765e5846a7de, //1.0.1365.1 (1.43)

    // loop >
    bool drawMarkerToggle = false;
    void drawMarker() {
    if (drawMarkerToggle)
    {
    GRAPHICS::DRAW_MARKER(markerType, markerPos.x, markerPos.y, markerPos.z, markerDir.x, markerDir.y, markerDir.z, markerRot.x, markerRot.y, markerRot.z, markerScale.x, markerScale.y, markerScale.z, markerRED, markerGREEN, markerBLUE, markerALPHA, 0, 1, 1, 0, 0, 0, 0);
    }
    }

    Vector3 markerPos is set to my coords.
    the other Vector3´s have I try to change with alot different Values...
    but the marker dont will show up and my game laggs if I loop these!
    I hope anyone know to help me!?
    (and please only in c++)



  • Nobody knows?


  • MODERATOR

    Have you tried checking Native DB?



  • @ikt Sure, its always open and not only that. I ve tried all things out, but idk what the problem is that i cant see a marker. Its easy to create a checkpoint, but with a simple marker I have my problems!


  • MODERATOR

    Try using whatever Guadmaz did: https://github.com/Guad/MapEditor/blob/master/MapEditor.cs#L1367

    Minimal example:

    using System;
    using GTA;
    using GTA.Native;
    using System.Collections.Generic;
    
    public class DrawMarker : Script
    {
    	public DrawMarker()
    	{
    		Tick += OnTick;
    	}
    
    	void OnTick(object sender, EventArgs e)
    	{
    		Ped player = Game.Player.Character;
    
    		if (!player.Exists())
    			return;
    
    		Vehicle v = player.CurrentVehicle;
    		
    		if (!v.Exists())
    			return;
    
    		var pos = v.Position;
    		Function.Call(Hash.DRAW_MARKER, 2, pos.X, pos.Y, pos.Z + 2, 0f, 0f, 0f, 0f, 180f, 0f, 1f, 1f, 1f, 255, 128, 0, 50, false, true, 2, false, false, false, false);
    	}
    }
    
    


  • @ikt C Sharp... I dont understand C#! How that must look then in c++?


  • MODERATOR

    @Shira-Brixx

    GRAPHICS::DRAW_MARKER(2, pos.X, pos.Y, pos.Z + 2, 0f, 0f, 0f, 0f, 180f, 0f, 1f, 1f, 1f, 255, 128, 0, 50, false, true, 2, false, false, false, false);
    

    You might need to fix the arguments (to what i just posted) as the signature might be wrong.



  • @Shira-Brixx said in How to draw Marker (c++)?:

    // loop >
    bool drawMarkerToggle = false;
    void drawMarker() {
    if (drawMarkerToggle)

    You have set drawMarkerToggle to false inside the loop and then in the if clause you tell to only draw the marker if drawMarkerToggle is true. No wonder that nothing happens!

    1. You need to declare drawMarkerToggle outside this loop.
    2. You need to have the marker rendering inside the Tick eventhandler (which I think you did).
    3. Do not set the interval so that the tick eventhandler gets called each frame.
    4. Set the drawMarkerToggle outside the tick eventhandler (I hope you know the difference between declaration and setting)
    5. IMPORTANT! Draw only markers which are nearby!
    6. Also IMPORTANT! Do only things each frame where and when necessary!

    Tip: The best approach to keep things smooth (performance friendly) is to create a Rendering class which inherits from script.
    This class is only responsible for rendering tasks! Use other classes for the rest.
    Since the Rendering class must be decoupled from any other classes in order to run parallel, you need a kind of Proxy for the communication between them (see Balking pattern). You can use a simple static class which only holds properties like for example bool ConfigLoaded. You can then set such a property in one class and query it in another without both "knowing" each other.
    This picture shows the marker optimization process in my Teleportals mod.
    alt text


Log in to reply
 

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