Git Product home page Git Product logo

Comments (51)

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024 6

I got a solution at server.lua add this
`ESX = nil

TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)

ESX.RegisterServerCallback('rp-radio:getItemamount', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local qtty = xPlayer.getInventoryItem(item).count
cb(qtty)
end)
`

At the client.lua add this
`Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)

Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsControlJustPressed(1, 170) then
ESX.TriggerServerCallback('rp-radio:getItemamount', function(qtty)
if qtty > 0 then
SetRadio(true)
else
SetRadio(false)
ClearPedTasks(GetPlayerPed(-1))
TriggerEvent("pNotify:SendNotification", {
text = "Sul puudub raadio",
type = "error",
timeout = math.random(1000, 1000),
layout = "centerRight",
queue = "right"
})
end
end, 'radio')
end
end
end)`

from rp-radio.

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024 5

Tomorrow i can upload whole radio script. So u can just download it

from rp-radio.

pablordgez avatar pablordgez commented on July 18, 2024 4

Add this to the top of client.lua
ESX = nil

Then below the local radio part add this:

Citizen.CreateThread(function()
    while true do
        TriggerServerEvent("checkradio")
        Citizen.Wait(200)
    end
end)

RegisterNetEvent("doeshaveradio")
AddEventHandler("doeshaveradio",function()
    Radio.Has = true
end)

RegisterNetEvent("doesnthaveradio")
AddEventHandler("doesnthaveradio",function()
    
	Radio.Has = false
end)

Add this to server.lua (you can create a server.lua file in rp-radio and it will work right away)

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

RegisterNetEvent("checkradio")
AddEventHandler("checkradio", function()
	local xPlayer = ESX.GetPlayerFromId(source)
	if xPlayer ~= nil then
		local item_radio = xPlayer.getInventoryItem('radio').count
		if item_radio > 0 then
			xPlayer.triggerEvent("doeshaveradio")
		else
			xPlayer.triggerEvent("doesnthaveradio")
		end
	end
end)

I coded this and it worked. This was using ESX v1 Final, so you should use that

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024 1

Does anyone have a pre written script for it?

here u go

https://github.com/DNDdjay/RP_radio

from rp-radio.

Mellorx2 avatar Mellorx2 commented on July 18, 2024 1

Just use this code. Add this in the server.lua:

ESX.RegisterUsableItem('radio', function(source)

	local xPlayer = ESX.GetPlayerFromId(source)
      xPlayer.removeInventoryItem('radio', 1)
       TriggerClientEvent('Radio.Set', source, true)
	TriggerClientEvent('Radio.Toggle', source)

end)

from rp-radio.

mindiw01 avatar mindiw01 commented on July 18, 2024

Hey! You can create the item with this form:
server-side:

ESX.RegisterUsableItem('radio', function(source)
	local xPlayer = ESX.GetPlayerFromId(source)
	TriggerClientEvent('Radio.Set', source, true)
end)

from rp-radio.

T4K33N avatar T4K33N commented on July 18, 2024

But rp-radio doesn't have a server file. Where should i put the code ?

from rp-radio.

mindiw01 avatar mindiw01 commented on July 18, 2024

You can register on esx_basicneeds, or another scripts with server-side!

Or you can create one script apart with this (you can call with the name like you want):

fxmanifest.lua:

fx_version 'adamant'
game 'gta5'

server_script 'server.lua'

server.lua:

ESX.RegisterUsableItem('radio', function(source)
	local xPlayer = ESX.GetPlayerFromId(source)
	TriggerClientEvent('Radio.Set', source, true)
end)

from rp-radio.

Bonzaii99 avatar Bonzaii99 commented on July 18, 2024

when i remove the radio item in my inventory i can still use radio

from rp-radio.

Stevekovix avatar Stevekovix commented on July 18, 2024

@mindiw01 it's clearly not like that, your exemple it's for make the item radio usable and your exemple it's wrong.
If u want make the item usable use that in server.lua from esx_basicneeds :

local statusradio = false ESX.RegisterUsableItem('rp-radio', function(source) local xPlayer = ESX.GetPlayerFromId(source) if statusradio == false then TriggerClientEvent('Radio.Toggle', source) print('open') statusradio = true else TriggerClientEvent('Radio.Toggle', source) print('off') statusradio = false end end)

from rp-radio.

FBFezz avatar FBFezz commented on July 18, 2024

Figured it out. (New user to Mumble)

In Client.lua put this at the top

ESX = nil

Citizen.CreateThread(function()
	while ESX == nil do
		TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
		Citizen.Wait(0)
	end
end)

Then at the radio command Replace it with mine

		Enabled = true, -- Add a command to be able to open/close the radio
		Name = "radio", -- Command name
		Help = "Toggle hand radio", -- Command help shown in chatbox when typing the command
		Params = {},
		Handler = function(src, args, raw)
			ESX.TriggerServerCallback('rp-radio:getItemAmount', function(quantity)
				if quantity > 0 then
			local playerPed = PlayerPedId()
			local isFalling = IsPedFalling(playerPed)
			local isDead = IsEntityDead(playerPed)

			if not isFalling and Radio.Enabled and Radio.Has and not isDead then
				Radio:Toggle(not Radio.Open)
			elseif (Radio.Open or Radio.On) and ((not Radio.Enabled) or (not Radio.Has) or isDead) then
				Radio:Toggle(false)
				Radio.On = false
				Radio:Remove()
				exports["mumble-voip"]:SetMumbleProperty("radioEnabled", false)
			elseif Radio.Open and isFalling then
				Radio:Toggle(false)
			end
		else
			Radio:Toggle(false)
			Radio.On = false
			Radio:Remove()
			exports["mumble-voip"]:SetMumbleProperty("radioEnabled", false)
		end
	end, 'radio')
		end,

Server.lua put this

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj)
	ESX = obj
end)

ESX.RegisterServerCallback('rp-radio:getItemAmount', function(source, cb, item)
	local xPlayer = ESX.GetPlayerFromId(source)
	local quantity = xPlayer.getInventoryItem(item).count

	cb(quantity)
end)

from rp-radio.

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024

when i remove the radio item in my inventory i can still use radio

from rp-radio.

FBFezz avatar FBFezz commented on July 18, 2024

Did you restart the server after doing what i said?

from rp-radio.

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024

Yep

from rp-radio.

FBFezz avatar FBFezz commented on July 18, 2024

Hmm, i mean its a start im getting that as well but If anyone else can help contribute? We have it so it works if you use but if you remove radio you can still use

from rp-radio.

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024

I put server.lua one to esx_basicneeds, is that bad?

from rp-radio.

FBFezz avatar FBFezz commented on July 18, 2024

I made the server.lua in the radio file. Its already in the manifest so all you do is make the file and call it server.lua

from rp-radio.

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024

And this will fix my issue?

from rp-radio.

FBFezz avatar FBFezz commented on July 18, 2024

Possibly? I cant use the radio when i don't have it but if im on a radio channel it stays but i haven't coded that in yet as i haven't looked at mumble for long

from rp-radio.

Kahvlibanaan0 avatar Kahvlibanaan0 commented on July 18, 2024

Its not taking radio even out, but when i add radio to registable item its taking radio out but when i drop it its still usable

from rp-radio.

KacpereQ0 avatar KacpereQ0 commented on July 18, 2024

So anyone got the script?

from rp-radio.

Stevekovix avatar Stevekovix commented on July 18, 2024

i use the basic rp-radio from frazzle and works perfectly

from rp-radio.

Sylvesterb avatar Sylvesterb commented on July 18, 2024

i use the basic rp-radio from frazzle and works perfectly

Thanks for the quite pointless message. The issue is about using a radio item.

from rp-radio.

Sylvesterb avatar Sylvesterb commented on July 18, 2024

So anyone got the script?

Yes its here in the github

from rp-radio.

Stevekovix avatar Stevekovix commented on July 18, 2024

i use the basic rp-radio from frazzle and works perfectly

Thanks for the quite pointless message. The issue is about using a radio item.

In the type of message, no need you are at the top .. to criticize and give no solutions

We have already given solutions in passing;)

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

i am not sure but the solution there is showing

Figured it out. (New user to Mumble)

In Client.lua put this at the top

ESX = nil

Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
Then at the radio command Replace it with mine

	Enabled = true, -- Add a command to be able to open/close the radio
	Name = "radio", -- Command name
	Help = "Toggle hand radio", -- Command help shown in chatbox when typing the command
	Params = {},
	Handler = function(src, args, raw)
		ESX.TriggerServerCallback('rp-radio:getItemAmount', function(quantity)
			if quantity > 0 then
		local playerPed = PlayerPedId()
		local isFalling = IsPedFalling(playerPed)
		local isDead = IsEntityDead(playerPed)

		if not isFalling and Radio.Enabled and Radio.Has and not isDead then
			Radio:Toggle(not Radio.Open)
		elseif (Radio.Open or Radio.On) and ((not Radio.Enabled) or (not Radio.Has) or isDead) then
			Radio:Toggle(false)
			Radio.On = false
			Radio:Remove()
			exports["mumble-voip"]:SetMumbleProperty("radioEnabled", false)
		elseif Radio.Open and isFalling then
			Radio:Toggle(false)
		end
	else
		Radio:Toggle(false)
		Radio.On = false
		Radio:Remove()
		exports["mumble-voip"]:SetMumbleProperty("radioEnabled", false)
	end
end, 'radio')
	end,

Server.lua put this

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)

ESX.RegisterServerCallback('rp-radio:getItemAmount', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local quantity = xPlayer.getInventoryItem(item).count

cb(quantity)

end)

is it not missing the part that is telling what item there is needed ????

from rp-radio.

iSentrie avatar iSentrie commented on July 18, 2024

i am not sure but the solution there is showing

Figured it out. (New user to Mumble)

In Client.lua put this at the top

ESX = nil

Citizen.CreateThread(function()
while ESX == nil do
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
Then at the radio command Replace it with mine

	Enabled = true, -- Add a command to be able to open/close the radio
	Name = "radio", -- Command name
	Help = "Toggle hand radio", -- Command help shown in chatbox when typing the command
	Params = {},
	Handler = function(src, args, raw)
		ESX.TriggerServerCallback('rp-radio:getItemAmount', function(quantity)
			if quantity > 0 then
		local playerPed = PlayerPedId()
		local isFalling = IsPedFalling(playerPed)
		local isDead = IsEntityDead(playerPed)

		if not isFalling and Radio.Enabled and Radio.Has and not isDead then
			Radio:Toggle(not Radio.Open)
		elseif (Radio.Open or Radio.On) and ((not Radio.Enabled) or (not Radio.Has) or isDead) then
			Radio:Toggle(false)
			Radio.On = false
			Radio:Remove()
			exports["mumble-voip"]:SetMumbleProperty("radioEnabled", false)
		elseif Radio.Open and isFalling then
			Radio:Toggle(false)
		end
	else
		Radio:Toggle(false)
		Radio.On = false
		Radio:Remove()
		exports["mumble-voip"]:SetMumbleProperty("radioEnabled", false)
	end
end, 'radio')
	end,

Server.lua put this

ESX = nil

TriggerEvent('esx:getSharedObject', function(obj)
ESX = obj
end)

ESX.RegisterServerCallback('rp-radio:getItemAmount', function(source, cb, item)
local xPlayer = ESX.GetPlayerFromId(source)
local quantity = xPlayer.getInventoryItem(item).count

cb(quantity)

end)

is it not missing the part that is telling what item there is needed ????

no its here
image

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

okay is just it dont works for me

i have too set it, so u can use radio without having the radio

and there is no errors in the console or F8 menu

from rp-radio.

TsShoyu avatar TsShoyu commented on July 18, 2024

Tomorrow i can upload whole radio script. So u can just download it

I would be very grateful

from rp-radio.

Phantomymous avatar Phantomymous commented on July 18, 2024

i want the radio as a item too :/

from rp-radio.

Phantomymous avatar Phantomymous commented on July 18, 2024

@Kahvlibanaan0

from rp-radio.

ericb160 avatar ericb160 commented on July 18, 2024

Tomorrow i can upload whole radio script. So u can just download it

I would be very grateful

that would help a lot :) thanks

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

Tomorrow i can upload whole radio script. So u can just download it

when will u uploade the script ???

from rp-radio.

iiAlphaWolf avatar iiAlphaWolf commented on July 18, 2024

If you have the item stuff fixed and you guys want to solve the issue players can still hear you even they dont have an radio add this: (in client)
AddEventHandler('nkrp:loadingScreenOff', function() exports["mumble-voip"]:SetRadioChannel(0) end)

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

If you have the item stuff fixed and you guys want to solve the issue players can still hear you even they dont have an radio add this: (in client)
AddEventHandler('nkrp:loadingScreenOff', function() exports["mumble-voip"]:SetRadioChannel(0) end)

what do u mean this event do ???

cuz for me its dont sound like the problem we are having

can be me there is wrong

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

I found a way too make it work

ESX.RegisterUsableItem('radio', function(source) local xPlayer = ESX.GetPlayerFromId(source) TriggerClientEvent('Radio.Set', source, true) TriggerClientEvent('Radio.Toggle', source) end)

past that in ur server.lua

from rp-radio.

GamenHaaDee avatar GamenHaaDee commented on July 18, 2024

Does anyone have a pre written script for it?

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

Does anyone have a pre written script for it?

i have show the script part there is need right over ur comment

from rp-radio.

GamenHaaDee avatar GamenHaaDee commented on July 18, 2024

Doesnt work normaly cuz i have the item i can use it but when i drop it i can still open it with Shift + F3

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

its not working as toko voip for that u need u rewhite the whole item system in the script

from rp-radio.

beauflexx avatar beauflexx commented on July 18, 2024

Does anyone have a pre written script for it?

here u go

https://github.com/DNDdjay/RP_radio

I tried using this, using my hotkeys to bring it up. shift and f10
however nothing happens.

  • do have radio in inventory
  • restart script in game, unsure if i need a server restart
  • item is in inventory.

anything else i would need to do?

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

u have to go in ur inventory and say use radio before u can use it

from rp-radio.

beauflexx avatar beauflexx commented on July 18, 2024

if i open my inventory i cant open the chat box
also dragging item over to use doesnt show its a useable item
also tried commands /radio /useradio /radiouse, also reverted back to original commands
wonder if i should restart server.. thank you for quick reply been trying to do this

from rp-radio.

DNDdjay avatar DNDdjay commented on July 18, 2024

okay what framework are u using ???

from rp-radio.

beauflexx avatar beauflexx commented on July 18, 2024

esx 1.1 up to date

from rp-radio.

beauflexx avatar beauflexx commented on July 18, 2024

ty ty

from rp-radio.

heavenlygamer04 avatar heavenlygamer04 commented on July 18, 2024

Does anyone have a pre written script for it?

here u go

https://github.com/DNDdjay/RP_radio

Hi! so i installed this remade script and it is loaded and i even have the radio in my inventory, but for some reason i cannot get it to work, ive tried the keybind and the command

thanks in advance

from rp-radio.

FuriousLeech avatar FuriousLeech commented on July 18, 2024

Does anyone have a pre written script for it?

here u go

https://github.com/DNDdjay/RP_radio

hey, would you be able to fix an issue where you need to restart the script every time you load into the server? i know the issue, just not how to fix it. its calling the radio or something before the character is even loaded in, so it needs a restart to work. i had the same issue with my dispatch. i had to TriggerEvent in my multichar script after the character has fully loaded. but im not sure what to trigger in this radio script.

from rp-radio.

pablordgez avatar pablordgez commented on July 18, 2024

Does anyone have a pre written script for it?

here u go
https://github.com/DNDdjay/RP_radio

hey, would you be able to fix an issue where you need to restart the script every time you load into the server? i know the issue, just not how to fix it. its calling the radio or something before the character is even loaded in, so it needs a restart to work. i had the same issue with my dispatch. i had to TriggerEvent in my multichar script after the character has fully loaded. but im not sure what to trigger in this radio script.

Try mine https://github.com/pablordgez/rp-radio and tell me if it works

from rp-radio.

timonation avatar timonation commented on July 18, 2024

Add this to the top of client.lua
ESX = nil

Then below the local radio part add this:

Citizen.CreateThread(function()
    while true do
        TriggerServerEvent("checkradio")
        Citizen.Wait(200)
    end
end)

RegisterNetEvent("doeshaveradio")
AddEventHandler("doeshaveradio",function()
    Radio.Has = true
end)

RegisterNetEvent("doesnthaveradio")
AddEventHandler("doesnthaveradio",function()
    
	Radio.Has = false
end)

Add this to server.lua (you can create a server.lua file in rp-radio and it will work right away)

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

RegisterNetEvent("checkradio")
AddEventHandler("checkradio", function()
	local xPlayer = ESX.GetPlayerFromId(source)
	if xPlayer ~= nil then
		local item_radio = xPlayer.getInventoryItem('radio').count
		if item_radio > 0 then
			xPlayer.triggerEvent("doeshaveradio")
		else
			xPlayer.triggerEvent("doesnthaveradio")
		end
	end
end)

I coded this and it worked. This was using ESX v1 Final, so you should use that

this works very well :) TY

from rp-radio.

Mat40 avatar Mat40 commented on July 18, 2024

Add this to the top of client.lua
ESX = nil
Then below the local radio part add this:

Citizen.CreateThread(function()
    while true do
        TriggerServerEvent("checkradio")
        Citizen.Wait(200)
    end
end)

RegisterNetEvent("doeshaveradio")
AddEventHandler("doeshaveradio",function()
    Radio.Has = true
end)

RegisterNetEvent("doesnthaveradio")
AddEventHandler("doesnthaveradio",function()
    
	Radio.Has = false
end)

Add this to server.lua (you can create a server.lua file in rp-radio and it will work right away)

ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)

RegisterNetEvent("checkradio")
AddEventHandler("checkradio", function()
	local xPlayer = ESX.GetPlayerFromId(source)
	if xPlayer ~= nil then
		local item_radio = xPlayer.getInventoryItem('radio').count
		if item_radio > 0 then
			xPlayer.triggerEvent("doeshaveradio")
		else
			xPlayer.triggerEvent("doesnthaveradio")
		end
	end
end)

I coded this and it worked. This was using ESX v1 Final, so you should use that

this works very well :) TY

Hi i have this error : SCRIPT ERROR: @rp-radio/server.lua:10: attempt to call a nil value (field 'triggerEvent')

from rp-radio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.