Jump to content

[SCRIPT REG] Battlelogger


THASMOG

Recommended Posts

Hello, i am very new at mta scripting. And wanted to ask how to make scripts that autokills battleloggers.

I try to explain.

There is two players: Player 1 and Player 2.

If Player 1 shots Player 2. Player 2 gets timer at bottom of his/her screen that countdowns 60 to 0. If he logouts before 0 he dies. So that means he cant run away from kill. But if Player 1 kills Player 2 before 0 the countdown just dissapears. And if Player 2 shots Player 1 back, they both would have timer.

Maybe it's possible to make it only from other player dmg. Like if Player 1 jumps off cliff and getgs damage he wont get timer.

I tryed to find it from online and tryed to make something myself.

This is what i made from tutorials.

function battlelogger ( attacker, weapon, bodypart, loss ) 
    if ( bodypart == 9,8,7,6,5,4,3) then 
    countdown = time 
    outputChatBox(time) 
    setTimer(reduceCountdown, 1000, countdown) 
end 
addEventHandler ( "onPlayerDamage", getRootElement (), battlelogger ) 
addCommandHandler("starttimer", startTimer) 
  
function reduceCountdown() 
    countdown = countdown - 1 
    outputChatBox(countdown) 
    if (countdown == 0) then 
        outputChatBox("Start") 
    end 
end 
  
function createBattleTimer() 
        local sWidth, sHeight = guiGetScreenSize() 
        local Width,Height = 800,45 
        local X = (sWidth/2) - (Width/2) 
        local Y = sHeight - (Height/2) 
        battleGridlist = guiCreateGridList(X,Y,Width,Height,false) 
        battleLabel = guiCreateLabel(X,Y,Width,Height/2,"Test text",false,battleGridlist) 
        loadBattleTimer() 
        updateBattleItem(1) 
        currentItem = 1 
end 
  
addEventHandler("onClientResourceStart",resourceRoot,createBattleTimer) 

Thanks !

Link to comment

I readed a bit lua. Maybe the first script is too complicated for me

So i start like that:

function battlelogger ( attacker, weapon, bodypart, loss ) 
    if ( bodypart==9) or (bodypart==8) or (bodypart==7) or (bodypart==6) or (bodypart==5) or (bodypart==4) or (bodypart==3) then 

Now i need to add some timer.

Link to comment
  • Moderators
local bodyParts = { 
  [9]=true,[8]=true, 
  [7]=true,[6]=true, 
  [5]=true,[4]=true, 
  [3]=true 
}--table 
  
function battlelogger ( attacker, weapon, bodypart, loss ) 
        if  bodyParts[bodypart] then -- check if the value is 3 t/m 9. 
  
        end-- don't forget the end. 
end 

timers for every player

  
local myTimers = {} -- create a place(table) where you store the userdata from the timers. So you will be able to stop the timer for every single player. 
  
------------------------------------------------------------------------------------------------------ 
-- source is the player that got damaged when you use the event "onPlayerDamage". 
------------------------------------------------------------------------------------------------------- 
  
-- check if you haven't already a timer that is working with this player. 
if not myTimers[source] then  
  
  
-- here we set a timer the data location is the player him self also we call it the key or index value. So if you know the player you also know what timer he uses. 
  myTimers[source] = setTimer(reduceCountdown, 1000, countdown) 
  
  
-- and of course an end for every function, loop or "if" 
end  
  

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