bosslorenz Posted January 10, 2015 Share Posted January 10, 2015 For example Team 1 Team 2 How to make an area only available to team 1 and if you are team 2 and you entered the area it will kill you Link to comment
Mizudori Posted January 10, 2015 Share Posted January 10, 2015 https://wiki.multitheftauto.com/wiki/Ele ... sion_shape onColShapeHit() onClientColShapeHit() Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 safeZone = createColRectangle ( 1837.4000244141, 1283.0999755859, 195, 165) safeArea = createRadarArea ( 1837.4000244141, 1283.0999755859, 195, 165, 0, 255, 0, 150) setElementData (safeArea,"zombieProof",true) function safeZoneEnter ( thePlayer, matchingDimension ) if getElementType( thePlayer ) ~= "player" then return end outputChatBox ( "* You Have Entered The *LV MAFIA* Base! *", thePlayer, 200, 0, 100 ) toggleControl ( thePlayer, "fire", false ) toggleControl ( thePlayer, "next_weapon", true ) toggleControl ( thePlayer, "previous_weapon", true ) setPedWeaponSlot ( thePlayer, 0 ) toggleControl ( thePlayer, "aim_weapon", false ) toggleControl ( thePlayer, "vehicle_fire", false ) toggleControl ( thePlayer, "vehicle_secondary_fire", false ) end addEventHandler ( "onColShapeHit", safeZone, safeZoneEnter ) function safeZoneExit ( thePlayer, matchingDimension ) if getElementType( thePlayer ) ~= "player" then return end outputChatBox ( "* You Have Left The *LV MAFIA* Base! *", thePlayer, 200, 0, 100 ) toggleControl ( thePlayer, "fire", true ) toggleControl ( thePlayer, "next_weapon", true ) toggleControl ( thePlayer, "previous_weapon", true ) toggleControl ( thePlayer, "aim_weapon", true ) toggleControl ( thePlayer, "vehicle_fire", true ) toggleControl ( thePlayer, "vehicle_secondary_fire", true ) end addEventHandler ( "onColShapeLeave", safeZone, safeZoneExit ) addEventHandler ( "onColShapeHit", safeZone, function ( hitElement ) if getElementType( hitElement ) == "ped" then setRadarAreaFlashing(safeArea, false) setElementData (safeZone,"zombieProof", true) killPed(hitElement) end end ) function killP(hitElement) local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if teamName == "LV MAFIA" then return end if not teamName =="LV MAFIA" then killPed(hitElement) end end addEventHandler("onColShapeHit", safeZone, killP) says lua:42 :bad argument @ 'getPlayerTeam' expected player at argument 1, got Ped Link to comment
Mizudori Posted January 10, 2015 Share Posted January 10, 2015 function killP(hitElement) local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if teamName == "LV MAFIA" then return end if not teamName =="LV MAFIA" then if(getElementType(hitElement)=="ped")then destroyElement (hitElement) elseif(getElementType(hitElement)=="player")then killPed(hitElement) end end end addEventHandler("onColShapeHit", safeZone, killP) Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 safeZone = createColRectangle ( 1837.4000244141, 1283.0999755859, 195, 165) safeArea = createRadarArea ( 1837.4000244141, 1283.0999755859, 195, 165, 0, 255, 0, 150) setElementData (safeArea,"zombieProof",true) function safeZoneEnter ( thePlayer, matchingDimension ) if getElementType( thePlayer ) ~= "player" then return end outputChatBox ( "* You Have Entered The *LV MAFIA* Base! *", thePlayer, 200, 0, 100 ) toggleControl ( thePlayer, "fire", false ) toggleControl ( thePlayer, "next_weapon", true ) toggleControl ( thePlayer, "previous_weapon", true ) setPedWeaponSlot ( thePlayer, 0 ) toggleControl ( thePlayer, "aim_weapon", false ) toggleControl ( thePlayer, "vehicle_fire", false ) toggleControl ( thePlayer, "vehicle_secondary_fire", false ) end addEventHandler ( "onColShapeHit", safeZone, safeZoneEnter ) function safeZoneExit ( thePlayer, matchingDimension ) if getElementType( thePlayer ) ~= "player" then return end outputChatBox ( "* You Have Left The *LV MAFIA* Base! *", thePlayer, 200, 0, 100 ) toggleControl ( thePlayer, "fire", true ) toggleControl ( thePlayer, "next_weapon", true ) toggleControl ( thePlayer, "previous_weapon", true ) toggleControl ( thePlayer, "aim_weapon", true ) toggleControl ( thePlayer, "vehicle_fire", true ) toggleControl ( thePlayer, "vehicle_secondary_fire", true ) end addEventHandler ( "onColShapeLeave", safeZone, safeZoneExit ) addEventHandler ( "onColShapeHit", safeZone, function ( hitElement ) if getElementType( hitElement ) == "ped" then setRadarAreaFlashing(safeArea, false) setElementData (safeZone,"zombieProof", true) killPed(hitElement) end end ) function killP(hitElement) local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if teamName == "LV MAFIA" then return end if not teamName =="LV MAFIA" then if(getElementType(hitElement)=="ped")then destroyElement (hitElement) elseif(getElementType(hitElement)=="player")then killPed(hitElement) end end end addEventHandler("onColShapeHit", safeZone, killP) 42: bad argument @'getPlayerTeam' Expected player at argument 1, got ped Link to comment
Mizudori Posted January 10, 2015 Share Posted January 10, 2015 Oh yeak it's to late for me.. I am sitting on phone so I am not able to edit code. You need to chech hitelement on start of KillP function. With getElementType if element is ped jusy destroyElement(hitElement) else if it is player you just roll with your function. killP(hitElement) if(getElementType(hitElement)=="ped")then destroyElement(hitElement) -- or killPed(hifElement) should work too elseif(getElementType(hitElement)=="player")then -- yours code end end something like this Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 function killP(hitElement) if(getElementType(hitElement)=="ped")then destroyElement(hitElement) elseif(getElementType(hitElement)=="player")then local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if teamName == "LV MAFIA" then return end if not teamName =="LV MAFIA" then killPed(hitElement) end end end addEventHandler("onColShapeHit", safeZone, killP) What`s still wrong about this? No error on mtaserver.exe but in game doesnt kill player that is not on team LV MAFIA Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 function killP( hitElement ) if(getElementType(hitElement)=="player")then local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if not ( teamName == "LV MAFIA")then killPed(hitElement) outputChatBox("You will be killed in 5 seconds if you don`t get out from LV MAFIA base.", hitElement) end end end addEventHandler("onColShapeHit", safeZone, killP) add setTimer(killPed,5000,0) ? outputChatBox will give him warning and if still on zone in 5 secs kill Ped Link to comment
Enargy, Posted January 10, 2015 Share Posted January 10, 2015 function killP(hitElement) if (getElementType(hitElement)=="ped") then destroyElement(hitElement) elseif (getElementType(hitElement)=="player") then local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if not ( teamName == "LV MAFIA")then killPed(hitElement) --outputChatBox("You're not part of LV MAFIA Clan", hitElement) end end end addEventHandler("onColShapeHit", safeZone, killP) Link to comment
bosslorenz Posted January 10, 2015 Author Share Posted January 10, 2015 setting timer for killPed so that player not on team gets warning before killed ? Link to comment
LaCosTa Posted January 10, 2015 Share Posted January 10, 2015 try this one EDIT : i added if the player leaves the colshape didn't get killed after 5 secondes safeZone = createColRectangle ( 1837.4000244141, 1283.0999755859, 195, 165) safeArea = createRadarArea ( 1837.4000244141, 1283.0999755859, 195, 165, 0, 255, 0, 150) function killP(hitElement) if (getElementType(hitElement)=="ped") then destroyElement(hitElement) elseif (getElementType(hitElement)=="player") then local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if not ( teamName == "LV MAFIA")then outputChatBox("You're not part of LV MAFIA Clan You'll be killed after 5 secondes", hitElement) timer = setTimer(function() killPed(hitElement) end,5000,1) end end end addEventHandler("onColShapeHit", safeZone, killP) function stopKillP(hitElement) if (getElementType(hitElement) == "player") then if isTimer(timer) then killTimer(timer) end end end addEventHandler("onColShapeLeave",safeZone,stopKillP) Link to comment
xeon17 Posted January 10, 2015 Share Posted January 10, 2015 function killPlayer(hitElement) local playerTeam = getPlayerTeam ( hitElement ) local teamName = ( playerTeam and getTeamName ( playerTeam ) or "" ) if not ( teamName == "LV MAFIA")then outputChatBox("You're not part of LV MAFIA Clan You'll be killed after 5 secondes", hitElement) setTimer(killPed,5000,1,hitElement) end end addEventHandler("onColShapeHit", safeZone, killPlayer) 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