Annas Posted August 22, 2015 Share Posted August 22, 2015 Hello community members, Just i need something , when a player in ACL group Name , it setElementData "something" , i tried to make this: SERVER SIDE function hitdbs(player) accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL1" )) then setElementData (player, "CSThit", "DL1") end if isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL2" )) then setElementData (player, "CSThit", "DL2") end if isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL3" )) then setElementData (player, "CSThit", "DL3") else setElementData (player, "CSThit", "None") end end end When a player in DL1 Acl group , i need this element data setted to him ("CSThit", "DL1") , and when a player DL2 ("CSThit", "DL2") and DL3 ("CSThit", "DL3") , but not work , please help me , i can explain more.. , and i need it if you enter exemple to acl DL1 , it added that element data ("CSThit", "DL1") and when i leave it it back to 0 ("CSThit", "None") Sorry for my bad english Link to comment
JR10 Posted August 22, 2015 Share Posted August 22, 2015 You should use elseif not just if. You have an extra end as well. function hitdbs(player) accName = getAccountName(getPlayerAccount(player)) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL1" )) then setElementData (player, "CSThit", "DL1") elseif isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL2" )) then setElementData (player, "CSThit", "DL2") elseif isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL3" )) then setElementData (player, "CSThit", "DL3") else setElementData (player, "CSThit", "None") end end Link to comment
Annas Posted August 22, 2015 Author Share Posted August 22, 2015 it's not work .. there is no "if Resource Start" ? , i mean , if i start the script so it make this all .. Link to comment
JR10 Posted August 22, 2015 Share Posted August 22, 2015 I thought this was part of your code. If this is the full code then you need to use it with onPlayerLogin. function hitdbs(old, new) local accName = getAccountName(new) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL1" )) then setElementData (source, "CSThit", "DL1") elseif isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL2" )) then setElementData (source, "CSThit", "DL2") elseif isObjectInACLGroup ("user."..accName, aclGetGroup ( "DL3" )) then setElementData (source, "CSThit", "DL3") else setElementData (source, "CSThit", "None") end end addEventHandler('onPlayerLogin', root, hitdbs) Link to comment
Walid Posted August 22, 2015 Share Posted August 22, 2015 You don't need to do all fo this simply it can be like this. local dlGroups = { "DL1", "DL2", "DL3"}; addEventHandler ( "onPlayerLogin", root, function ( _, theAccount ) for a, g in ipairs (dlGroup) do if ( isObjectInACLGroup ( "user."..getAccountName(theAccount) , aclGetGroup (g))) then setElementData (source, "CSThit", "DL"..a) return; end end end ); Link to comment
JR10 Posted August 22, 2015 Share Posted August 22, 2015 Most of the times it's better to edit the given code rather than provide an unnecessary changed one. This way, the user can understand his problems better. 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