s1mple Posted November 3, 2015 Share Posted November 3, 2015 function startgm() accountname = getAccountName(getPlayerAccount(thePlayer)) if isObjectInACLGroup("user." .. accountname, aclGetGroup("Admin")) then do if not getElementData(getLocalPlayer(), "onduty") then gmtimer = setTimer(gmforad, 200, 0) outputChatBox ("Admin is now: ON DUTY",150, 6, 8, 255,true) setElementData(getLocalPlayer(), "onduty", true) else killTimer (gmtimer) setElementData(getLocalPlayer(),"blood", 12000) outputChatBox ("Admin is now: OFF DUTY!",150, 6, 8, 255,true) setElementData(getLocalPlayer(), "onduty", false) end end addEvent("onPlayerOnDuty", true) addEventHandler("onPlayerOnDuty", thePlayer, startgm) function gmforad() if getElementData(getLocalPlayer(),"logedin") then setElementData(getLocalPlayer(),"blood", 500000) setElementData(getLocalPlayer(),"bleeding", 0) setElementData(getLocalPlayer(),"cold", false) setElementData(getLocalPlayer(),"temperature", 36.5) setElementData(getLocalPlayer(),"pain", false) setElementData(getLocalPlayer(),"brokenbone", false) setElementData(getLocalPlayer(),"thirst", 100) setElementData(getLocalPlayer(),"food", 100) end end Can u make? if player is 10 meters from me, then he can't shoot and aim Link to comment
Walid Posted November 3, 2015 Share Posted November 3, 2015 All what you need is : getElementPosition() getElementsByType() getDistanceBetweenPoints3D() Link to comment
s1mple Posted November 3, 2015 Author Share Posted November 3, 2015 Can u make it for me? Link to comment
Crossy101 Posted November 3, 2015 Share Posted November 3, 2015 A lot of people don't like making only showing you the functions on how it can be done I'll just give you an example on how it could be done. getElementPosition() - Will get the players position getElementsByType() - Will check if the player is a player if true then getDistanceBetweenPoints3D() - Will check where both elements are and you can make it so that if either elements are withing 10m or 10 units of a player then stop them from aiming or shooting!! LUA is probably one of the most basic languages out there it also has a lot of tutorials online on how you can code with LUA. Good Luck! Link to comment
AMARANT Posted November 3, 2015 Share Posted November 3, 2015 LUA is probably one of the most basic languages out there it also has a lot of tutorials online on how you can code with LUA. Just a remark. There's no such a language as "LUA". Link to comment
Tekken Posted November 4, 2015 Share Posted November 4, 2015 Just a remark. There's no such a language as "LUA". Yup, but is a common mistake, the language name is Lua not LUA! Link to comment
Dealman Posted November 4, 2015 Share Posted November 4, 2015 Is it really that important to go off-topic only to point out that it's Lua and not LUA? @S1mple: You'll need to try doing things yourself, or you'll never learn. You were already given the basic functions needed to accomplish this, all you need to do now is study these functions - and think of a logical solution. 1. You need to get the position between you and the other player(s). local allPlayers = getElementsByType("player") 2. Loop through all the players, and compare the distance between them and you. for i=1, #allPlayers do local pX, pY, pZ = getElementPosition(allPlayers[i]) local sX, sY, sZ = getElementPosition(localPlayer) local theDistance = getDistanceBetweenPoints3D(pX, pY, pZ, sX, sY, sZ) if(theDistance <= 10) then toggleControl("aim_weapon", false) toggleControl("fire", false) else toggleControl("aim_weapon", true) toggleControl("fire", true) -- We need to reset it to true if the check failed, otherwise they may get stuck with the control disabled. end end There you have something to start with, go from there. Link to comment
Walid Posted November 4, 2015 Share Posted November 4, 2015 Simply you can use something like : function functionName(player) local allPlayers = getElementsByType("player") for i,v in pairs(allPlayers) do local x,y,z = getElementPosition(player) local px,py,pz = getElementPosition(v) local distance = math.floor(getDistanceBetweenPoints3D(x, y, z, px, py, pz)) or 0 if (distance < 10 and player ~= v) then return true else return false end end end use it like an export function 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