Samking Posted August 26, 2018 Posted August 26, 2018 how can I make a script like group commands which can only use by group members?
MIKI785 Posted August 26, 2018 Posted August 26, 2018 You could use ACL, see ACL functions on the wiki.. or if you mean teams then check for the team using getPayerTeam.
Samking Posted August 27, 2018 Author Posted August 27, 2018 9 hours ago, MIKI785 said: You could use ACL, see ACL functions on the wiki.. or if you mean teams then check for the team using getPayerTeam. Can you make one for me, please? I make but... I fail
Saml1er Posted August 27, 2018 Posted August 27, 2018 (edited) 7 minutes ago, Samking said: Can you make one for me, please? I make but... I fail Try to put some code together, when you do that, post it here, and we'll help. You'll need: isObjectInACLGroup Edited August 27, 2018 by Saml1er
Samking Posted August 27, 2018 Author Posted August 27, 2018 2 minutes ago, Saml1er said: Try to put some code together, when you do that, post it here, and we'll help. You'll need: isObjectInACLGroup Thanks I will try now
Samking Posted August 27, 2018 Author Posted August 27, 2018 2 hours ago, Saml1er said: Try to put some code together, when you do that, post it here, and we'll help. You'll need: isObjectInACLGroup I am shy to show ma script because a lot of mistakes I have done in it. Can you make one for me, please?
Samking Posted August 27, 2018 Author Posted August 27, 2018 2 hours ago, Saml1er said: Try to put some code together, when you do that, post it here, and we'll help. You'll need: isObjectInACLGroup local accName = getAccountName ( getPlayerAccount ( thePlayer ) ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( "VIP" ) ) then giveCash ( thePlayer ) end end ) function giveCash (player) givePlayerMoney(player,1000000) outputChatBox ("$-----------------------------------------------------------------------------------------------$",source,0, 255, 0,true) outputChatBox ("The player'"..getPlayerName(player).."' is rich now because he ",source,250, 255, 0,true) outputChatBox ("Has received 10m$ ",source,0, 255, 221,true) outputChatBox ("$-----------------------------------------------------------------------------------------------$",source,0, 255, 0,true) end addCommandHandler("givemecash",giveCash) function giveCash (player) givePlayerMoney(player,99999999) outputChatBox ("$---------------------------------------------------------------------------------------------$",source,0, 255, 0,true) outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",source,250, 255, 0,true) outputChatBox (" Has received 99m$ ",source,0, 255, 221,true) outputChatBox ("$---------------------------------------------------------------------------------------------$",source,0, 255, 0,true) end
Saml1er Posted August 27, 2018 Posted August 27, 2018 @Samking -- if you remove this line with "local" keyword, these -- functions will be visible to other files in the resource. -- Currently, you can only use them within this file only. local isPlayerInGroup, giveCash local function giveCashCommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You are not in the VIP group", player) end end addCommandHandler("givemecash", giveCashCommand) function giveCash (player) givePlayerMoney(player,99999999) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true) outputChatBox (" Has received 99m$ ", root,0, 255, 221,true) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) end function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( thePlayer ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then -- the player is in the group, return true return true end end -- the player is not in the group, return false return false end I haven't tested the code, but I quickly came up with this.
Samking Posted August 28, 2018 Author Posted August 28, 2018 thanks, I will try if the player in VIP group type /givemecash command this will visible to those who are in VIP group? or all?
Samking Posted August 28, 2018 Author Posted August 28, 2018 (edited) 23 hours ago, Saml1er said: @Samking -- if you remove this line with "local" keyword, these -- functions will be visible to other files in the resource. -- Currently, you can only use them within this file only. local isPlayerInGroup, giveCash local function giveCashCommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You are not in the VIP group", player) end end addCommandHandler("givemecash", giveCashCommand) function giveCash (player) givePlayerMoney(player,99999999) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true) outputChatBox (" Has received 99m$ ", root,0, 255, 221,true) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) end function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( thePlayer ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then -- the player is in the group, return true return true end end -- the player is not in the group, return false return false end I haven't tested the code, but I quickly came up with this. I 've got an error this gives Only Output that "You are not in the VIP group" I set my self in VIP group but still give output "You are not in the VIP group"/> And in console Warning: givecash/script.lua:22: Bad argument @ getPlayerAccount [Expected element at argument 1 got nil] Edited August 28, 2018 by Samking Mistake
Saml1er Posted August 28, 2018 Posted August 28, 2018 I made a mistake: function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( thePlayer ) TO function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player )
Dimos7 Posted August 28, 2018 Posted August 28, 2018 -- if you remove this line with "local" keyword, these -- functions will be visible to other files in the resource. -- Currently, you can only use them within this file only. local isPlayerInGroup, giveCash local function giveCashCommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You are not in the VIP group", player) end end addCommandHandler("givemecash", giveCashCommand) function giveCash (player) givePlayerMoney(player,99999999) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true) outputChatBox (" Has received 99m$ ", root,0, 255, 221,true) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) end function isPlayerInGroup (thePlayer, group) local playerAccount = getPlayerAccount ( thePlayer ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then -- the player is in the group, return true return true end end -- the player is not in the group, return false return false end
Samking Posted August 28, 2018 Author Posted August 28, 2018 20 minutes ago, Dimos7 said: -- if you remove this line with "local" keyword, these -- functions will be visible to other files in the resource. -- Currently, you can only use them within this file only. local isPlayerInGroup, giveCash local function giveCashCommand (player) if isPlayerInGroup (player, "VIP") then giveCash (player) else outputChatBox ("You are not in the VIP group", player) end end addCommandHandler("givemecash", giveCashCommand) function giveCash (player) givePlayerMoney(player,99999999) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) outputChatBox ("The player'"..getPlayerName(player).."' is extremely rich now because he ",root,250, 255, 0,true) outputChatBox (" Has received 99m$ ", root,0, 255, 221,true) outputChatBox ("$---------------------------------------------------------------------------------------------$",root,0, 255, 0,true) end function isPlayerInGroup (thePlayer, group) local playerAccount = getPlayerAccount ( thePlayer ) if playerAccount then local accName = getAccountName ( playerAccount ) if isObjectInACLGroup ("user."..accName, aclGetGroup ( group ) ) then -- the player is in the group, return true return true end end -- the player is not in the group, return false return false end is this code is correct? 30 minutes ago, Saml1er said: I made a mistake: function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( thePlayer ) TO function isPlayerInGroup (player, group) local playerAccount = getPlayerAccount ( player ) still the same.....
Saml1er Posted August 28, 2018 Posted August 28, 2018 1 hour ago, Samking said: still the same..... Did you restart the resource after fixing the problem? Check VIP group within acl in admin panel, see if your account name is there. If it still doesn't work, then copy-paste your acl.xml here.
Samking Posted August 28, 2018 Author Posted August 28, 2018 (edited) 11 minutes ago, Saml1er said: Did you restart the resource after fixing the problem? Check VIP group within acl in admin panel, see if your account name is there. If it still doesn't work, then copy-paste your acl.xml here. Thanks for helping me Edited August 28, 2018 by Samking
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