Jump to content

Need help [script editing]


Parazitas

Recommended Posts

Hello guys! :D i need edit one script but.. im a bad scripter.. :? I need make this: cuz this pvp toogle

automatically start working then player join the sevise team delete all on/off functions and chatbox messages.

Im sorry for my bad English.. :cry:

  
timepvp=15000 
pvpkey="3" 
vehprotect=true 
keyunbind=false 
  
pvptime=timepvp/1000 
  
  
addEventHandler ("onClientPlayerDamage",getRootElement(),function(attacker,weapon,bodypart) 
if attacker then 
if getElementData (attacker,"antidm") ==true or getElementData(source,"antidm")==true then 
cancelEvent() 
end 
end 
end) 
  
  
addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()),function() 
bindKey (pvpkey,"down",function() 
if not getElementData(localPlayer,"antidm") then 
if getElementData (localPlayer,"waiting") then 
outputChatBox ("PvP mode is already being disabled, just wait!",255,0,0) 
return end 
outputChatBox ("Disabling PvP mode, wait#ff0000 "..pvptime.."#ffffff seconds!",255,255,255,true) 
setElementData (localPlayer,"waiting",true) 
setTimer (function() 
if keyunbind then 
toggleControl ("fire",false) 
end 
setElementData (localPlayer,"waiting",false) 
setElementData(localPlayer,"antidm",true) 
outputChatBox ("PvP mode successfully disabled!",0,255,0) 
end,timepvp,1) 
else 
toggleControl ("fire",true) 
setElementData (localPlayer,"antidm",false) 
outputChatBox ("PvP mode enabled!",0,100,255) 
end 
end) 
  
end) 
  
addEventHandler ("onClientVehicleDamage",getRootElement(),function(theAttacker,theWeapon)  
if vehprotect then 
if theAttacker then 
if getVehicleOccupant (source,0) then 
if getElementData (theAttacker,"antidm") or getElementData (getVehicleOccupant(source,0),"antidm") then 
cancelEvent() 
end 
end 
end 
end 
end) 
  

Link to comment

Well, this should work. Try it:

function isPlayerInTeam(player, team) 
    assert(isElement(player) and getElementType(player) == "player", "Bad argument 1 @ isPlayerInTeam [player expected, got " .. tostring(player) .. "]") 
    assert((not team) or type(team) == "string" or (isElement(team) and getElementType(team) == "team"), "Bad argument 2 @ isPlayerInTeam [nil/string/team expected, got " .. tostring(team) .. "]") 
    return getPlayerTeam(player) == (type(team) == "string" and getTeamFromName(team) or (type(team) == "userdata" and team or (getPlayerTeam(player) or true))) 
end 
  
  
addCommandHandler ( "onService", 
    function ( player, commandName, mode ) 
        if isPlayerInTeam ( player ) == "[service]" then 
            if mode == "true" then 
                setElementData ( player, "onService", true ) 
                outputChatBox ( "Now you are on service.", player, 0, 255, 0 ) 
                toggleControl ( player, "fire", false ) 
            elseif mode == "false" then 
                setElementData ( player, "onService", false ) 
                outputChatBox ( "Now you are out of service.", player, 0, 255, 0 ) 
                toggleAllControls ( player, true ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onPlayerDamage", getRootElement ( ), 
    function ( attacker, _, _, _ ) 
        if getElementData ( attacker, "onService" ) == true or getElementData ( source, "onService" ) == true then 
            cancelEvent ( ) 
        end 
    end 
) 
  
addEventHandler ( "onVehicleDamage", getRootElement ( ), 
    function ( loss ) 
        local player = getVehicleOccupant ( source ) 
        if player and getElementData ( player, "onService" ) == true then 
            cancelEvent ( ) 
        end 
    end 
) 

Link to comment
Is [service], not Service...

if isPlayerInTeam ( player ) == "[service]" then

I changed but still same Sh*t maybe edit this script just add function when player in team service when...

function rewardOnWasted ( ammo, killer, killerweapon, bodypart ) 
    if ( killer ) and ( killer ~= source ) then  
        setElementHealth (killer, 0) 
    end 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), rewardOnWasted ) 

Link to comment

Damn, im so stupid, sorry. Change the event onPlayerDamage for this:

addEventHandler ( "onClientPlayerDamage", getLocalPlayer ( ), 
    function ( attacker, _, _ ) 
        if getElementData ( source, "onService" ) == true or getElementData ( attacker, "onService" ) == true then 
            cancelEvent ( ) 
        end 
    end 
) 

PD: Sorry again, my mistake...

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