Mrzeerox Posted December 1, 2016 Share Posted December 1, 2016 Anyone can make me script, if player is around 100m from me, then he cant shoot? function giveblood ( thePlayer ) if isObjectInACLGroup ( "user." ..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup ( "Admin") ) then if not getElementData(thePlayer, "OnDuty") then outputChatBox ("#1AFF00 Admin "..getPlayerName(thePlayer).."#1AFF00 IS NOW - ON DUTY",root,0,0,255,true) setElementData(thePlayer, "blood",999999999) setElementData(thePlayer, "food",95) setElementData(thePlayer, "thirst",95) setElementData(thePlayer, "temperature",36.5) setElementData(thePlayer, "currentweapon_1",false) setElementData(thePlayer, "currentweapon_2",false) setElementData(thePlayer, "currentweapon_3",false) setElementData(thePlayer, "bleeding",false) setElementData(thePlayer, "brokenbone",false) setElementData(thePlayer, "pain",false) setElementData(thePlayer, "cold",false) setElementData(thePlayer, "bandit",false) setElementData(thePlayer, "humanity",2500) setElementData(thePlayer, "skin",210) setElementData(thePlayer, "OnDuty",true) end end end addCommandHandler("duty", giveblood) function bloodback(thePlayer) local account = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup("user." .. account, aclGetGroup("Admin,Moderator,Owner")) then end outputChatBox ("#FF0000 Admin "..getPlayerName(thePlayer).."#FF0000 IS NOW - OFF DUTY",root,255,255,255,true) setElementData(thePlayer, "blood",12000) setElementData(thePlayer, "OnDuty",false) end addCommandHandler("offduty", bloodback) Link to comment
SheriFF Posted December 1, 2016 Share Posted December 1, 2016 (edited) Please try to explain better your problem/request EDIT : Not tested (Client-Sided script) function playerOnDamage( attacker, weapon, bodyPart, loss ) if ( getElementType( attacker ) == "player" ) then local pX, pY, pZ = getElementPosition( source ) local aX, aY, aZ = getElementPosition( attacker ) local distance = getDistanceBetweenPoints3D( pX, pY, pZ, aX, aY, aZ ) if ( distance < 50 ) then cancelEvent( ) end end end addEventHandler( "onClientPlayerDamage", getRootElement( ), playerOnDamage ) Edited December 1, 2016 by *BeaT* Understood the request Link to comment
Mrzeerox Posted December 1, 2016 Author Share Posted December 1, 2016 if im typing /duty then 100m around me then no one can shoot. And i wtire /offduty then anyone can shoot again Link to comment
SheriFF Posted December 1, 2016 Share Posted December 1, 2016 (edited) Server function giveBlood( playerSource, inputCommand ) if ( isObjectInACLGroup ( "user." ..getAccountName( getPlayerAccount( thePlayer ) ), aclGetGroup ( "Admin") ) ) then if ( getElementData( playerSource, "OnDuty" ) == true ) then outputChatBox( "You are already On-Duty!", playerSource, 255, 0, 0 ) else setElementData( playerSource, "OnDuty", true ) setElementData( playerSource, "food", 95, true ) setElementData( playerSource, "thirst", 95, true ) setElementData( playerSource, "temperature", 36.5, true ) setElementData( playerSource, "currentweapon_1", false, true ) setElementData( playerSource, "currentweapon_2", false, true ) setElementData( playerSource, "currentweapon_3", false, true ) setElementData( playerSource, "bleeding", false, true ) setElementData( playerSource, "brokenbone", false, true ) setElementData( playerSource, "pain", false, true ) setElementData( playerSource, "cold", false, true ) setElementData( playerSource, "bandit", false, true ) setElementData( playerSource, "humanity", 2500, true ) setElementData( playerSource, "skin", 210, true ) end else end end addCommandHandler( "duty", giveBlood ) function bloodBack( playerSource, inputCommand ) if ( isObjectInACLGroup ( "user." ..getAccountName( getPlayerAccount( playerSource ) ), aclGetGroup ( "Admin") ) ) then setElementData( playerSource, "blood", 12000, true ) setElementData( playerSource, "OnDuty", false, true ) else --output something end end addCommandHandler( "offduty", bloodBack ) Client function playerOnDamage( attacker, weapon, bodyPart, loss ) if ( getElementType( attacker ) == "player" and getElementData( source, "OnDuty" ) == true ) then local pX, pY, pZ = getElementPosition( source ) local aX, aY, aZ = getElementPosition( attacker ) local distance = getDistanceBetweenPoints3D( pX, pY, pZ, aX, aY, aZ ) if ( distance < 50 ) then -- change the distance if you need cancelEvent( ) end end end addEventHandler( "onClientPlayerDamage", getRootElement( ), playerOnDamage ) Not tested! Edited December 1, 2016 by *BeaT* Code mistake 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