Tekken Posted March 17, 2015 Share Posted March 17, 2015 Hello guys, I have a custom Ban system and it work's like that /aban Name Reason, and it take player serial and put it on a ACL group named Baned like this user.PLAYERSERIAL and when player join check if that player serial is in that ACL group and if is it kick that player. My ask is if i can make it like that user.PlayerSerial.(PlayerName).(Reason) , it work but how to check when player join ? My script : function checkBlockedSerial() if isObjectInACLGroup("user."..getPlayerSerial(source), aclGetGroup("Banned")) then kickPlayer(source, "You are banned!") end end addEventHandler("onPlayerJoin", getRootElement(), checkBlockedSerial) Link to comment
TAPL Posted March 17, 2015 Share Posted March 17, 2015 You won't be able to use isObjectInACLGroup as you don't know the player name and the reason, therefore you must use aclGroupListObjects to get a list of all objects and do a loop and use gettok. Example: StR = "user.TheSerial.PlayerName.Reason" Serial = gettok(StR, 2, string.byte(".")) Name = gettok(StR, 3, string.byte(".")) Reason = gettok(StR, 4, string.byte(".")) outputChatBox(Serial) outputChatBox(Name) outputChatBox(Reason) PS: I'm not sure if you could use more than one dot in the object you might need to use other symbol. Link to comment
Tekken Posted March 17, 2015 Author Share Posted March 17, 2015 but if i do like this user.serial_Name|Reason ? Link to comment
TAPL Posted March 17, 2015 Share Posted March 17, 2015 Just use the example above, i have tested putting more than one dot and it acceptable. Link to comment
Tekken Posted March 17, 2015 Author Share Posted March 17, 2015 Will this work ? function checkBlockedSerial() object = aclGroupListObjects(aclGetGroup("Banat")) if object then PSerial = getPlayerSerial(source) Serial = gettok(object, 2, string.byte(".")) Name = gettok(object, 3, string.byte(".")) Reason = gettok(object, 4, string.byte(".")) if Serial == PSerial then kickPlayer(source, tostring(Reason)) end end end addEventHandler("onPlayerJoin", getRootElement(), checkBlockedSerial) Link to comment
TAPL Posted March 17, 2015 Share Posted March 17, 2015 No, you need to loop the table returned from aclGroupListObjects. Link to comment
Tekken Posted March 17, 2015 Author Share Posted March 17, 2015 then this ? function checkBlockedSerial() object = aclGroupListObjects(aclGetGroup("Banat")) for i, v in ipairs(object) do PSerial = getPlayerSerial(source) Serial = gettok(v, 2, string.byte(".")) Name = gettok(v, 3, string.byte(".")) Reason = gettok(v, 4, string.byte(".")) if Serial == PSerial then kickPlayer(source, tostring(Reason)) end end end addEventHandler("onPlayerJoin", getRootElement(), checkBlockedSerial) Link to comment
crismar Posted March 17, 2015 Share Posted March 17, 2015 Take PSerial outside the 'for' loop, you're not going to need to get the serial every time you loop. Doesn't have a large impact on perfomance, but it's better to learn to write optimised code directly. Link to comment
xXMADEXx Posted March 17, 2015 Share Posted March 17, 2015 This is a little bit off topic, but it would probably be a lot easier to just save the bans into an xml or sql file. 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