Jump to content

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


Recommended Posts

Posted

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

Posted
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

Posted

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

Posted

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?

Posted

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

Posted

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

Posted

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

Posted
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

Posted

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?

Posted

the timer function  1s = -1 

10 - 1 = 9 

every second -1

but killing function every 10 second kill Players

Posted

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

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

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