SHOW:
|
|
- or go back to the newest paste.
| 1 | function preventDM(attacker) | |
| 2 | - | if (attacker and getElementType(attacker) == "player") then |
| 2 | + | if (attacker and attacker.type == "player" or attacker.type == "vehicle" and attacker ~= source) then |
| 3 | - | local attackerTeam = getTeamName(getPlayerTeam(attacker)) |
| 3 | + | if (attacker.dimension == 0 and source.dimension == 0) then |
| 4 | - | local sourceTeam = getTeamName(getPlayerTeam(source)) -- source is the player who got damaged |
| 4 | + | return false |
| 5 | - | if (getElementDimension(attacker) == 0 and getElementDimension(source) == 0) then |
| 5 | + | |
| 6 | - | if (attackerTeam == "Criminals") then |
| 6 | + | if (attacker.type == "vehicle") then |
| 7 | - | if (sourceTeam == "Criminals" or sourceTeam == "Civilian Workers") then |
| 7 | + | local driver = attacker.controller |
| 8 | - | return false |
| 8 | + | if (isElement(driver) and driver.type == "player" and driver ~= source) then |
| 9 | attacker = driver | |
| 10 | - | return true |
| 10 | + | |
| 11 | - | elseif (attackerTeam == "Civilian Workers") then |
| 11 | + | |
| 12 | - | if (sourceTeam == "Criminals" or sourceTeam == "Civilian Workers") then |
| 12 | + | if ((attacker.type == "player" and attacker.team.name == "Criminals" or attacker.team.name == "Civilian Workers") and exports.server:getPlayerChatZone(attacker) ~= "LV") then |
| 13 | - | return false |
| 13 | + | if ((source.team.name == "Criminals" or source.team.name == "Civilian Workers") and exports.server:getPlayerChatZone(source) ~= "LV") then |
| 14 | cancelEvent() | |
| 15 | - | return true |
| 15 | + | |
| 16 | end | |
| 17 | end | |
| 18 | end | |
| 19 | addEventHandler("onClientPlayerDamage", root, preventDM) |