How to convert from C# to Lua


i wrote this in c# and i know it works… I am wondering how to write in lua

            Vector3 ply = Game.Player.Character.Position + (Game.Player.Character.ForwardVector * 5);

much appreciated


These natives will help you out


I know how get the natives i was wondering in lua how to add to the forward vector by 5


exactly the same way


this doesnt work

local ply = GetEntityCoords(GetPlayerPed(-1)+(GetEntityForwardVector(-1)*30f);

  1. No need to use the API. class like in C# (You don’t use it for GetEntityCoords, so why should you for GetPlayerPed?)
  2. You use GetPlayerPed(-1) for the coords, but not the forward vector. Why?
  3. You are missing a closing parentheses for the coords.
  4. You don’t add an f to represent a float in LUA. LUA has no static typing. Use decimal notation instead 30.0

Please read your code more carefully

local player = GetEntityCoords(GetPlayerPed(PlayerId()), false) + GetEntityForwardVector(GetPlayerPed(PlayerId())) * 30.0

??? Like that?


thank you xander1998 and thank you d0p3t i will let you know the out come


You may have to target a certain point like X, Y, Z but I am not 100% sure. I would think that would work though.


this is what i am trying to convert

 public Forwarvec()
            Tick += onTick;
        private async Task onTick()
            Vector3 playerped = Game.Player.Character.CurrentVehicle.Position + (Game.Player.Character.CurrentVehicle.ForwardVector * 10);
            await Delay(0);
            if (Game.Player.Character.IsInVehicle())
                World.DrawMarker(MarkerType.VerticalCylinder, playerped, Vector3.Zero, Vector3.Zero, new Vector3(1f, 1f, 1.5f), Color.FromArgb(7, 17, 237));
                if (Game.IsControlJustReleased(-1, Control.SelectCharacterFranklin))
                    Screen.ShowSubtitle("~b~X = ~y~" + (object)Math.Round((double)playerped.X, 2) + "~b~, Y = ~y~" + (object)Math.Round((double)playerped.Y, 2) + "~b~, Z = ~y~" + (object)Math.Round((double)playerped.Z, 2));

if it helps seeing what i am trying to do


I didn’t do the whole thing but here is what I have as I am playing a game with some friends. Just found some time in the lobby.

    while true do

        if IsPedInAnyVehicle(GetPlayerPed(PlayerId()), false) then
            local playerped = GetEntityCoords(GetPlayerPed(PlayerId()), false) + GetEntityForwardVector(GetPlayerPed(PlayerId())) * 10

            -- Draw Marker Here

            if IsControlJustReleased(index, control) then -- IDK THE CONTROL

                -- Show Text Here


Thank you very much that work i figured it out right before you did