Sign in to follow this  
DerStr1k3r

Command is not executed

Recommended Posts

Hello community,
I have a little problem there.

I am in the process of writing a command that you can teleports via Map Marker.

The function seems to be correct, but it does not work.

 

My Code is:

C#:

        [Command("port")]
        public void Teleport(Client client)
        {
            if (!client.HasData("player"))
                return;
                GTANetworkMethods.Player player = client.GetData("player");

                NAPI.ClientEvent.TriggerClientEvent(client, "mapmarker_getposition");
        }

 

Js:

const player = mp.players.local;

mp.events.add('mapmarker_getposition', () => {
        var player = mp.players.local.position;
        var coords = NAPI.ClientEvent.GetWaypointPosition();
        coords.Z = 2000;
        NAPI.ClientEvent.SetEntityPosition(player, coords);
		descent();
});

function descent() {
    var player = mp.players.local.position;
    var pos = NAPI.ClientEvent.GetEntityPosition(player);
    var ground = NAPI.ClientEvent.GetGroundHeight(pos);
    pos.Z = pos.Z - 100;
    if (ground == 0) {
        NAPI.ClientEvent.SetEntityPosition(player, pos);
        NAPI.after(1, "descent");
    }
    else {
        pos.Z = ground;
        NAPI.ClientEvent.SetEntityPosition(player, pos);
    }
}

Does any one of you know a tip?

Edited by DerStr1k3r

Share this post


Link to post
Share on other sites

What are those NAPI.ClientEvent client-side? Also, where do you set that "player" data to the player with something like client.SetData("player", YourData);?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.