I’m trying to make a script where either a text field shows up or gets a message from chat as soon as they join. Anyone got any ideas on how to help me?
Do you mean as in, when they spawn it sends a message?
If so:
AddEventHandler('playerSpawned', function()
TriggerEvent('chatMessage', 'Freeroam', {255, 255, 255}, 'Welcome to Freeroam')
end)
Or if you want them to type something when they join:
AddEventHandler('playerSpawned', function()
example = KeyboardInput("Enter your name", "e.g John Smith", 5)
TriggerEvent('chatMessage', 'Freeroam', {255, 255, 255}, 'Welcome to Freeroam ' .. example)
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
Thanks, this will help majorly…
How would you be able to get the result afterwards?
EDIT : ^^ For Example a server password and I want to see the password they have typed. I can’t get what they typed.