xbenny2506x Posted July 22, 2009 Share Posted July 22, 2009 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
50p Posted July 22, 2009 Share Posted July 22, 2009 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 Posted July 22, 2009 Share Posted July 22, 2009 You can try to add an string like entered = nil. If a player enters the colshape just set it to entered = "yes". After spawn you just need to check the string with if ( entered == "yes" ) then. That should help also. Link to comment
robhol Posted July 22, 2009 Share Posted July 22, 2009 (edited) 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 July 22, 2009 by Guest Link to comment
XetaQuake Posted July 22, 2009 Share Posted July 22, 2009 Oh, thanks, good to know - i will change it on my script i'm working on Link to comment
xbenny2506x Posted July 22, 2009 Author Share Posted July 22, 2009 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 This is a cool DM script, and i have many DM areas only i need this nice script I hope someone can help me! BIG BIG THX !!!!! Link to comment
xbenny2506x Posted July 23, 2009 Author Share Posted July 23, 2009 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
XetaQuake Posted July 23, 2009 Share Posted July 23, 2009 Have you read what 50p and i have posted? Link to comment
xbenny2506x Posted July 23, 2009 Author Share Posted July 23, 2009 Yes i have read everything what the people say here... But i am not good in the script things... sorry... I give up... 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
XetaQuake Posted July 23, 2009 Share Posted July 23, 2009 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
xbenny2506x Posted July 24, 2009 Author Share Posted July 24, 2009 BIG BIG THX for the Help XetaQuake and 50p With "local entered = nil" is this now so easy And now i understand what 50p means I work now with onPlayerWasted and entered The player die not more when he respawn BIG THX Link to comment
50p Posted July 24, 2009 Share Posted July 24, 2009 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
xbenny2506x Posted July 24, 2009 Author Share Posted July 24, 2009 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
XetaQuake Posted July 24, 2009 Share Posted July 24, 2009 You could make the relevant part clientside. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now