Hello,
I have a variable in my client.lua file, the variable is RPname. Can anyone help me make it so if you type /showid it prints that varable to the whole server?
Thanks,
Scotty
Hello,
I have a variable in my client.lua file, the variable is RPname. Can anyone help me make it so if you type /showid it prints that varable to the whole server?
Thanks,
Scotty
Youd trigger a server event with that variable
Ok, you know how im retarded?
Pretty sure this will work:
memes = 10
TriggerServerEvent("FuckMe", memes)
serv
RegisterNetEvent("FuckMe")
AddEventHandler("FuckMe", function(memes)
print(memes)
end)
EDIT: How would I make it so if I type a command the variable is printed out in chat?
Trigger the chatMessage event
Could you possibly give me an example?
Thanks,
Scotty
Hehe. ok lol. I just got rekt
Just use what @sadboilogan already wrote and replace print with the chatmessage event.
Client:
memes = 10
TriggerServerEvent("FuckMe", memes)
Server:
RegisterNetEvent("FuckMe")
AddEventHandler("FuckMe", function(memes)
TriggerEvent("chatMessage", "SENDER_OF_THE_MESSAGE", { 255, 255, 255}, memes)
end)
Would this work? @Flatracer
AddEventHandler('chatMessage', function(source, name, msg)
sm = stringsplit(msg, " ");
if sm[1] == "/showid" then
CancelEvent()
TriggerClientEvent('ShowID')
end
end)
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
AddEventHandler("playerSpawned", function(spawn)
local RPname = KeyboardInput("Roleplay Name:", "", 20)
end)
function KeyboardInput(TextEntry, ExampleText, MaxStringLenght)
-- TextEntry --> The Text above the typing field in the black square
-- ExampleText --> An Example Text, what it should say in the typing field
-- MaxStringLenght --> Maximum String Lenght
AddTextEntry('FMMC_KEY_TIP1', TextEntry .. ':') --Sets the Text above the typing field in the black square
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP1", "", ExampleText, "", "", "", MaxStringLenght) --Actually calls the Keyboard Input
blockinput = true --Blocks new input while typing if **blockinput** is used
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do --While typing is not aborted and not finished, this loop waits
Citizen.Wait(0)
end
if UpdateOnscreenKeyboard() ~= 2 then
local result = GetOnscreenKeyboardResult() --Gets the result of the typing
Citizen.Wait(500) --Little Time Delay, so the Keyboard won't open again if you press enter to finish the typing
blockinput = false --This unblocks new Input when typing is done
return result --Returns the result
else
Citizen.Wait(500) --Little Time Delay, so the Keyboard won't open again if you press enter to finish the typing
blockinput = false --This unblocks new Input when typing is done
return nil --Returns nil if the typing got aborted
end
end
RegisterNetEvent("ShowID")
AddEventHandler("ShowID", function(RPname)
TriggerEvent("chatMessage", "SENDER_OF_THE_MESSAGE", { 255, 255, 255}, RPname)
end)
Change this part a bit, that it looks like this:
local RPname
AddEventHandler("playerSpawned", function(spawn)
RPname = KeyboardInput("Roleplay Name:", "", 20)
end)
Edit:
Also you should change SENDER_OF_THE_MESSAGE
to something else, otherwise the name of the sender of the message is “SENDER_OF_THE_MESSAGE”
I see, thanks. So other than that it should work? I just don’t want to restart the server until I have confidence will work lol. The server has 15 people on.
Hmmm does not seem to be working, I used restart resourcename
It should work.
Btw. you don’t have to restart the whole server. You can start, stop and restart resources through the RCON Console.
Commands:
start <Resourcename>
stop <Resourcename>
restart <Resourcename>
I posted that while you were typing I think hehe
Oh yeah, just saw it
What exactly did you type in the chat?
I know the problem, I am an idiot. Forgot to upload new files to filezilla lol.
Mixed yours and IllusiveTeas response together and it works perfectly, Thank you