Player Location via Chat Command

Trying to display a players last location via chat command. (Displays Server Side)

AddEventHandler('chatMessage', function(source, name, msg)
	if msg == "/location" then
		local street = nil
		local intersection = nil
		GetStreetNameAtCoord(x, y, z, street, intersection)
		local result = GetStreetNameFromHashKey(street)
		if intersection ~= nil then
    	result = result .. " " .. GetStreetNameFromHashKey(intersection)
		end
        CancelEvent()
		TriggerClientEvent("chatMessage", -1, "^1Testing: ", {255, 255, 255}, result)
	end
end)

Note that you can’t call natives from the server. You have to trigger a client event which will then display this information.

1 Like