Jump to content

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


Recommended Posts

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

Link to comment

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

Link to comment

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

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

Link to comment

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

Link to comment

>

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

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.
×
×
  • Create New...