I believe this would work. I have not tried it though. @Xnitro67
-- SERVER --
RegisterServerEvent("welcomeMessage")
AddEventHandler("welcomeMessage", function(id)
local name = GetPlayerName(id)
TriggerClientEvent("chatMessage", -1, "WELCOME", {255,0,0}, name .. " to the server!")
end)
-- CLIENT --
AddEventHandler("onClientMapStart", function()
local serverId = GetPlayerServerId(PlayerId())
TriggerServerEvent("welcomeMessage", serverId)
end)
Could someone private message me and help me with the following, I am quite new to learning Lua, but I’ve picked it up quickly and I’m learning well.
I’ve started to learn Lua purely for GTA V use ONLY. I’ve gone to the Natives DB (http://www.dev-c.com/nativedb/) and I am unsure how I should use these natives in a working script. I am wanting to make a script that does the following, this is for learning purposes and I understand a script like this may have been done before, however I am doing it for my own benefit.
Script checks to make sure player is alive
Script checks to make sure player is not cuffed.
Script checks to make sure player is near a vehicle.
Script makes sure the target vehicle is stopped.
Script then checks to make sure target vehicle is upside down/on roof
Script then sets vehicle on ground properly.
However when I go to create this, I get confused, as I feel the natives located on that DB are for C language.
Could someone give me a basic idea of how the natives work, the syntax and how they should be structured for Lua only.
https://wiki.fivem.net/wiki/Client_functions
has all information you might need.
In short, a C++ NATIVE_NAME_GOES_HERE is invoked in Lua with NativeNameGoesHere.
Also pointers ( the * thingies) in C++ are generally returned values in Lua.
example:
GET_SCREEN_RESOLUTION(int* x, int* y)
is done in Lua with:
x, y = GetScreenResolution()
I just wrote this real quick based on what you told me, this is the FIRST TIME i’ve applied Lua to GTA so please tell me where I am fucking up, if I am.
RegisterNetEvent('lupo:unflip')
AddEventHandler('lupo:unflip', function()
local playerPed = GetPlayerped(-1)
local targetVehicle = GetVehiclePedIsIn(playerPed, true)
local checkCuffs = IsPedCuffed(playerPed)
local checkHeartbeat = IsPedDead(playerPed)
local checkBrakes = IsVehicleStopped(targetVehicle)
-- Act on the information
if(checkCuffs(0)) then
if(checkHeartbeat(0)) then
if(checkBrakes(1)) then
SetVehicleOnGroundProperly(targetVehicle)
TriggerEvent("chatMessage", "[lupoFlipping:]", {255, 255, 0}, "The vehicle has been put on the ground properly.")
else
TriggerEvent("chatMessage", "[lupoFlipping:]", {255, 255, 0}, "You are either dead, handcuffed or the vehicle is moving, try again!")
end
end
end
end)
local targetVehicle = nil
RegisterNetEvent('lupo:unflip')
AddEventHandler('lupo:unflip', function()
local playerPed = GetPlayerped(-1)
local targetVehicle = GetVehiclePedIsIn(playerPed, true)
local checkCuffs = IsPedCuffed(playerPed)
local checkHeartbeat = IsPedDead(playerPed)
local checkBrakes = IsVehicleStopped(targetVehicle)
-- Act on the information
if checkCuffs = 0 then
if checkHeartbeat = 0 then
if checkBrakes = 1 then
SetVehicleOnGroundProperly(targetVehicle)
TriggerEvent("chatMessage", "[lupoFlipping:]", {255, 255, 0}, "The vehicle has been put on the ground properly.")
else
TriggerEvent("chatMessage", "[lupoFlipping:]", {255, 255, 0}, "You are either dead, handcuffed or the vehicle is moving, try again!")
end
end
end
end)
local targetVehicle = nil
Boolean comparison is done with double equals sign and true/false.
checkCuffs == false for example.
For conciseness you can just omit the ==false or ==true really.
If anyone could help, how would I trigger a message by someone typing a command. Like if someone typed “/discord” it would say my discord, if that makes sense