bencskrisz

Set Timer for being killed after 10 min (e.g)

Recommended Posts

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! :(

Share this post


Link to post
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

Share this post


Link to post

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. :(

Share this post


Link to post

you want when player die create timer for like 5s when 5s end respawn player?

Share this post


Link to post

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?

Share this post


Link to post

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

Share this post


Link to post

you want change spawn place?

Share this post


Link to post

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

Share this post


Link to post

Now its not working at all....

ERROR: Loading script failed: Time\time.lua:6: unexpected symbol near '10000'

oh sorry, its working now :D 

And can you make it visible, I mean the counter? That"d be awesome!!

Share this post


Link to post
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

Share this post


Link to post

Thank you so much! It appears and counts but doesnt restart after respawning. It remains 0    :| 

Share this post


Link to post

this is Useful Functions

player make this code not me i can't edit make it restart the timer

Share this post


Link to post

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?

Share this post


Link to post

the timer function  1s = -1 

10 - 1 = 9 

every second -1

but killing function every 10 second kill Players

Share this post


Link to post

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

Share this post


Link to post

if the timer end the visible = false?

Share this post


Link to post

Nah, im talking about the changing of colour of the counter. Not the visibility

Share this post


Link to post
Posted (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 by salh

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.