Jump to content

DM area /kill problem


Recommended Posts

HI :)

I have found this script and add many new things :)

But now i have a problem when the player use /kill for kill himself in the DM area he gets a warning when he is respawn and the server killed him after 10 sec.

That is the problem, how can i make it when the player use /kill in the DM area he die not when he is respawn??

warRadar = createRadarArea (  1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
warShape = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
 
 
function onPlayerShapeHit ( thePlayer, matchingDimension )
 
if ( getElementType ( thePlayer ) == "player" ) then
outputChatBox ( "You have entered War zone! DONT leave this ZONE or you DIE!!!", thePlayer, 0, 255, 0 )
setRadarAreaFlashing ( warRadar, true )
 
     timers = getTimers ( 9789 )
for timerKey, timerValue in ipairs(timers) do
killTimer ( timerValue )
end
 
function giveMoneyToKiller(totalAmmo,killer,killerWeapon,bodyPart)
 
if killer and source ~= killer then -- first you want to check if it's a suicide or something like that.. Don't give money then
if isElementWithinColShape(source,warShape) and isElementWithinColShape(killer,warShape) then -- if both were in colshape
givePlayerMoney(killer,5000)
end
end
end
addEventHandler("onPlayerWasted", getRootElement(), giveMoneyToKiller )
end
end
addEventHandler ( "onColShapeHit", warShape, onPlayerShapeHit )
 
function onPlayerShapeLeave ( thePlayer, matchingDimension )   
if ( getElementType ( thePlayer ) == "player" ) then
outputChatBox ( "You have leaved War zone! Go BACK IN THE RED AREA in the NEXT 10 SECOUNDS!!!", thePlayer, 255, 0, 0 )
setTimer ( killPlayer, 9789, 1, thePlayer, thePlayer )
setRadarAreaFlashing ( warRadar, false )
end
end
addEventHandler ( "onColShapeLeave", warShape, onPlayerShapeLeave )

Link to comment

He dies after 10 seconds of respawn because when you respawn him he "leaves" the col shape and so the timer starts to kill the player. Why do you addEventHandler every time players enter col shape? Make one onPlayerWasted event handler and do checks in it. You probably get an error or warning message telling you that you've attached giveMoneyToKiller when you hit the col shape more than once.

Link to comment

XetaQuake: while the differences might not be that significant with a lower number of variables, the boolean data type is there for a reason. Use it when you can.

A boolean is true (on, yes, etc.) or false (off, no, etc.) and should take around one bit or one byte (I'm not sure, it depends on how the lua guys made it,) while a string containing "yes" apparently takes 20 or 21 bytes...

Edited by Guest
Link to comment

I test many thinks grrrr And i have learn a lot in the last weeks about how i make a script but this is to hard for :(

One of my many ideas:

warRadar = createRadarArea (  1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
warShape = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
 
 
function onPlayerShapeHit ( thePlayer, matchingDimension )
 
  if ( getElementType ( thePlayer ) == "player" ) then
     outputChatBox ( "You have entered War zone! DONT leave this ZONE or you DIE!!!", thePlayer, 0, 255, 0 )
       setRadarAreaFlashing ( warRadar, true )
 
     timers = getTimers ( 9789 )
     for timerKey, timerValue in ipairs(timers) do
     killTimer ( timerValue )
 end
 
function giveMoneyToKiller(totalAmmo,killer,killerWeapon,bodyPart) -- check the parameters on wiki, first one is not killer endaddEventHandler("onPlayerWasted",getRootElement(),giveMoneyToKiller)
 
if killer and source ~= killer then -- first you want to check if it's a suicide or something like that.. Don't give money then
if isElementWithinColShape(source,warShape) and isElementWithinColShape(killer,warShape) then -- if both were in colshape
 givePlayerMoney(killer,5000) -- again, it's not giveMoney, it's givePlayerMoney, see [url=http://development.mtasa.com/index.php]http://development.mtasa.com/index.php[/url]? ... layerMoney
       end
     end
    end
     addEventHandler("onPlayerWasted", getRootElement(), giveMoneyToKiller )
  end
end
addEventHandler ( "onColShapeHit", warShape, onPlayerShapeHit )
 
 
function onPlayerShapeLeave ( thePlayer, matchingDimension )   
       if (getElementType(thePlayer) == "player") then
               if isPlayerDead ( thePlayer ) == true then
                        outputChatBox ( getClientName(thePlayer) .. " left the zone!", getRootElement(), 255, 255, 109 )
                       setRadarAreaFlashing ( warShape, false )
else
                 outputChatBox ( "You have leaved War zone! Go BACK IN THE RED AREA in the NEXT 10 SECOUNDS!!!", thePlayer, 255, 0, 0 )
                setTimer ( killPlayer, 9789, 1, thePlayer, thePlayer )
             setRadarAreaFlashing ( warShape, false )
 
               end
       end
end
addEventHandler ( "onColShapeLeave", warShape, onPlayerShapeLeave )

In the last hours i have test a lot but nothing help and i have learn a lot and found many new things for my other scripts but here i need help :roll:

This is a cool DM script, and i have many DM areas only i need this nice script :D

I hope someone can help me!

BIG BIG THX !!!!!

Link to comment

Now i need really help :(

I have test what i have found from onPlayerWasted, onPlayerSpawn, isElementWithinColShape and many more things but all the time the player die when someone killed him in the DM Zone and he respawn :(

For my test i have a easy and small script, all other things i can add later then that is easy only this stupid die after respawn make me crazy!

Can someone here help me PLZ!

Here is the simple script:

local DMArea = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
local DMRadar = createRadarArea ( 1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
 
function DM_enter (thePlayer, matchingDimension )
 if (getElementType(thePlayer) == "player") then
   outputChatBox( getClientName(thePlayer) .. "entered DM-zone", getRootElement(), 241, 166, 10 )
     timers = getTimers ( 9789 )
     for timerKey, timerValue in ipairs(timers) do
     killTimer ( timerValue )
    end
 end
end
addEventHandler ( "onColShapeHit", DMArea, DM_enter )
 
 
function DM_leave ( thePlayer, matchingDimension )
 if (getElementType(thePlayer) == "player") then
   if isPlayerDead (thePlayer ) == false then
       outputChatBox ( getClientName(thePlayer) .. " left the zone not die first in 10 sec!", getRootElement(), 255, 255, 109 )
       setTimer ( killPlayer, 9789, 1, thePlayer, thePlayer )
       end
    end
end
addEventHandler ( "onColShapeLeave", DMArea, DM_leave)

Link to comment

Yes i have read everything what the people say here... But i am not good in the script things... sorry...

I give up... :violent2:

Now i must work with 50% of my script but better than nothing, and when someone has the same problems here is my little script

local DMArea = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
local DMRadar = createRadarArea ( 1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
 
function DM_enter (thePlayer, matchingDimension )
 if (getElementType(thePlayer) == "player") then
   outputChatBox( getClientName(thePlayer) .. " entered DM-zone", getRootElement(), 241, 166, 10 )
   takeAllWeapons ( thePlayer  )
   giveWeapon (thePlayer, 38, 9999 )
 end
end
addEventHandler ( "onColShapeHit", DMArea, DM_enter )
 
function DM_exit (thePlayer, matchingDimension )
 if (getElementType(thePlayer) == "player") then
   if isPlayerDead (thePlayer ) ~= true then
      outputChatBox( getClientName(thePlayer) .. " exit DM-zone", getRootElement(), 241, 166, 10 )
       takeWeapon ( thePlayer, 38 )
   end
 end
end
addEventHandler ( "onColShapeLeave", DMArea, DM_exit )

and when somone can help me with the kill/respawn problem he could help me a lot!

I must say making a good MTA:DM Games, Stunt, DM, Freeroam server is not easy... BUT i found a lot help here THX for that!

Link to comment

Try to make it like this, possible this will help you.

local DMArea = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
local DMRadar = createRadarArea ( 1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
local entered = nil
 
function DM_enter (thePlayer, matchingDimension )
if (getElementType(thePlayer) == "player") and (entered == nil) then
   entered = true
outputChatBox( getClientName(thePlayer) .. " entered DM-zone", getRootElement(), 241, 166, 10 )
takeAllWeapons ( thePlayer  )
giveWeapon (thePlayer, 38, 9999 )
end
end
addEventHandler ( "onColShapeHit", DMArea, DM_enter )
 
function DM_exit (thePlayer, matchingDimension )
if (getElementType(thePlayer) == "player") then
if (isPlayerDead (thePlayer ) ~= true) and (entered == true) then
      entered = nil
outputChatBox( getClientName(thePlayer) .. " exit DM-zone", getRootElement(), 241, 166, 10 )
takeWeapon ( thePlayer, 38 )
end
end
end
addEventHandler ( "onColShapeLeave", DMArea, DM_exit )

Link to comment
Try to make it like this, possible this will help you.
local DMArea = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
local DMRadar = createRadarArea ( 1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
local entered = nil
 
function DM_enter (thePlayer, matchingDimension )
if (getElementType(thePlayer) == "player") and (entered == nil) then
   entered = true
outputChatBox( getClientName(thePlayer) .. " entered DM-zone", getRootElement(), 241, 166, 10 )
takeAllWeapons ( thePlayer  )
giveWeapon (thePlayer, 38, 9999 )
end
end
addEventHandler ( "onColShapeHit", DMArea, DM_enter )
 
function DM_exit (thePlayer, matchingDimension )
if (getElementType(thePlayer) == "player") then
if (isPlayerDead (thePlayer ) ~= true) and (entered == true) then
      entered = nil
outputChatBox( getClientName(thePlayer) .. " exit DM-zone", getRootElement(), 241, 166, 10 )
takeWeapon ( thePlayer, 38 )
end
end
end
addEventHandler ( "onColShapeLeave", DMArea, DM_exit )

When you have 1 variable which is true or false (or nil) it's not going to work when there is more than 1 player. You should use setElementData and getElementData or a table which I wouldn't recommend for beginners.

Link to comment

You have right when i play with a friend, the "entered" idea not working :?

local DMArea = createColCuboid ( 1442.970, -1718.917, -14, 73.66 , 113.233 , 500 )
local DMRadar = createRadarArea ( 1475.358, -1668.3005 , 78 , 118, 255, 0, 0, 175 )
local entered = nil
 
function DM_enter (thePlayer, matchingDimension )
if (getElementType(thePlayer) == "player") and (entered == nil) then
   entered = true
outputChatBox( getClientName(thePlayer) .. " you are now in the Minigun DM! Dont leave this Area or you DIE after 10 Secounds!!", thePlayer, 0, 255, 0 )
takeAllWeapons ( thePlayer  )
giveWeapon (thePlayer, 38, 9999 )
     timers = getTimers ( 9789 )
for timerKey, timerValue in ipairs(timers) do
killTimer ( timerValue )
end
end
end
addEventHandler ( "onColShapeHit", DMArea, DM_enter )
 
 
 
function DM_deathcheck ( thePlayer, matchingDimension )
if entered == true then
            entered = nil
outputChatBox ( "Bad luck you die in the Deathmatch.", thePlayer, 0, 255, 0 )           
end
end
 
addEventHandler ( "onPlayerWasted", getRootElement(), DM_deathcheck )
 
 
function DM_exit (thePlayer, matchingDimension )
if (getElementType(thePlayer) == "player") then
if (isPlayerDead (thePlayer ) ~= true) and (entered == true) then
      entered = nil
outputChatBox( getClientName(thePlayer) .. " go back in the DM Area or you DIE in 10 Secounds!!", thePlayer, 255, 0, 0 )
takeAllWeapons ( thePlayer  )
setTimer ( killPlayer, 9789, 1, thePlayer, thePlayer )
end
end
end
addEventHandler ( "onColShapeLeave", DMArea, DM_exit )

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