bencskrisz Posted May 31, 2019 Posted May 31, 2019 Hi guys! Im kindda new at scripting, I ask your help! I want to set a timer what counts somewhere on the screen and when its up then I'll be killed. I also want it to be restarted after respawning. Thank you for your help in advance! :(
MrKAREEM Posted May 31, 2019 Posted May 31, 2019 3 hours ago, bencskrisz said: Hi guys! Im kindda new at scripting, I ask your help! I want to set a timer what counts somewhere on the screen and when its up then I'll be killed. I also want it to be restarted after respawning. Thank you for your help in advance! you want to count from 3 to 1 as example then if the count up kill player? if u want that u will use OnPlayerSpawn and SetTimer using number more than spawn time and for the count number and the Main Event OnPlayerWasted that you will work in it
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 Can you do a quick example in script? Im not lazy or anything to do it cause if I would be able to do, I would do it on my own but I just started to deal with this scripting only from yesterday.
salh Posted June 1, 2019 Posted June 1, 2019 you want when player die create timer for like 5s when 5s end respawn player?
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 No no, I want a countdown (for example counting from 10 minutes) and if its up, then player dies. After respawning the timer restarts from 10 min. Is it possible?
salh Posted June 1, 2019 Posted June 1, 2019 (edited) players = getElementsByType ( "player" ) for playerKey, playerValue in ipairs(players) do setTimer ( function() killPlayer(playerValue) end, 10000, 0 ) end this code for 10s you can change the time Edited June 1, 2019 by salh
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 I tried it and it indeed killed me first after 10 sec (as I set it to 10) but after that it respawned me only in the blueberry farm after everry 10 sec.. WARNING: Time\time.lua:7: Bad argument @ 'killPed' [Expected element at argument 1, got table] As it said I needed to change killPlayer to killPed AFter that I got that warning
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 No no. I dont want it to change spawn place.
salh Posted June 1, 2019 Posted June 1, 2019 the code is runing what the problem use the code players = getElementsByType ( "player" ) for playerKey, playerValue in ipairs(players) do setTimer ( function() killPlayer(playerValue) end, 10000, 0 ) end oh the debug use this players = getElementsByType ( "player" ) for playerKey, playerValue in ipairs(players) do setTimer ( function() killPed ( playerValue, playerValue ) end, 10000, 0 ) end the code is serverside not Clientside
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 Now its not working at all.... ERROR: Loading script failed: Time\time.lua:6: unexpected symbol near '10000' oh sorry, its working now And can you make it visible, I mean the counter? That"d be awesome!!
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 Yes yes,, Something like this: Timeleft: *the time*
salh Posted June 1, 2019 Posted June 1, 2019 function GuiSetTextCountDown ( guiElement , Text, count ) if not guiElement or not Text or not count then outputDebugString("Bad arugment @ GuiSetTextCountDown ",0,255,0,0) return end guiSetText ( guiElement ,Text..' '..tonumber( count ) ) setTimer( function ( ) if not tonumber ( count ) then return false end count = count -1 guiSetText ( guiElement ,Text..' '..tonumber( count ) ) end , 1000 , count ) end times = guiCreateLabel(4, 255, 250, 53, "", false) GuiSetTextCountDown(times, "Timer", 10) this is Client Side
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 Thank you so much! It appears and counts but doesnt restart after respawning. It remains 0
salh Posted June 1, 2019 Posted June 1, 2019 this is Useful Functions player make this code not me i can't edit make it restart the timer
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 But you cant do the same what you did at the killing function? There you made it to restart the counter. Same or similar script for visible countdown is not possible?
salh Posted June 1, 2019 Posted June 1, 2019 the timer function 1s = -1 10 - 1 = 9 every second -1 but killing function every 10 second kill Players
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 Oh okay. Thank you so much for your help! For last thing, can u tell me how to change the colour of the visible counter? Cause I wrote the color code before the "Timer" but it just made only appear the color code too and didnt change its colour
bencskrisz Posted June 1, 2019 Author Posted June 1, 2019 Nah, im talking about the changing of colour of the counter. Not the visibility
salh Posted June 1, 2019 Posted June 1, 2019 (edited) > guiLabelSetColor(times, 255, 0, 0) -- 255,0,0 the code color Add this under times = guiCreateLabel(4, 255, 250, 53, "", false) --here GuiSetTextCountDown(times, "Timer", 10) Edited June 1, 2019 by salh
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now