ilovegirls = true
Citizen.CreateThread(function()
while ilovegirls do
Citizen.Wait(1000)
local x = 461.59
local y = -979.88
local z = 30.69
local player = source
local ped = GetPlayerPed(player)
local playerCoords = GetEntityCoords(ped, false)
if playerCoords.x == x and playerCoords.y == y and playerCoords.z == z then
DisplayHelpText()
if IsControlJustPressed(1, 38) then -- E
exports['mythic_progbar']:Progress({
name = "ilovearmor",
duration = 6000,
label = 'Putting Armor',
useWhileDead = false,
canCancel = false,
controlDisables = {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = false,
},
}, function(cancelled)
if not cancelled then
SetPedArmour(ped, 100)
end
end)
end
end
end
end)
function DisplayHelpText()
SetTextComponentFormat("STRING")
AddTextComponentString("~g~Green Text.")
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
This will only evaluate to true if the player is on those exact coordinates, which is incredibly unlikely.
What you want to do is to calculate the distance between the trigger point and the current location of the player and continue the script in case the player is close enough.
--top of file
local myVector = vector3(461.59,-979.88,30.69)
-- then later in your game loop
if #(playerCoords - myVector) < 2.0 then -- if you're closer than 2m
-- do stuff
end
Don’t skip ticks when you want to check for a key being pressed. If you do this then you need to press Eexactly every 1000 ticks, which is close to impossible and will most definitely impact user experience. Just use Wait(0)
While this is true it is also bad to run 0 tick all the time. It is better to set a sleep so it can wait 1000 if your not within the 2.0 you set… and if you are within the 2.0 it sets sleep to 0 and then at the end Wait(sleep)
This will save your server alot of ms usage per script if formatted right.
The documentation states that it evaluates to true if the key was pressed between the last check and the current one, so it shouldn’t require running on each tick. Is the documentation wrong?
You are right in it states that it will return true if the key was pressed … but the big part of that is ‘between the last check and current one’. When running a script that is checking for key press you want it to respond and do the function as soon as the key is pressed… the only way for the script to know that is if it is checking every tick to see if the key is pressed. You can test this easy enough by just putting a simple loop in any client script and have it print to the console when i knows you pressed the key… to see what happens when you put in 1000 wait… and a 0 wait.