Lordkrypton Posted August 28, 2015 Posted August 28, 2015 Hi everyone I want to create a script who set a rank on every player : guest, player, vip, moderator, admin. I started to create something, but i have to reconnect everytime for test my script. Look exports.scoreboard:addScoreboardColumn('Rank') function rank() local aname = getAccountName(source) if isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Admin" ) ) then setElementData ( source , "Rank" , "Admin" ) else if isGuestAccount ( source ) then setElementData ( source , "Rank" , "Guest" ) else setElementData ( source, "Rank", "Player") end end end addEventHandler("onPlayerJoin",root,rank) If i want to set the element data everytime, not only when player connect, you know what i mean ? If someone is guest, and he register, i want him to be player without reconnect needed. Excuse my english Thank you
JR10 Posted August 28, 2015 Posted August 28, 2015 How will a player ever have an account when he joins? onPlayerJoin > "Guest" onPlayerLogin > "Player/Admin" onResourceStart, you can loop through all the players and check if they're logged in.
Lordkrypton Posted August 28, 2015 Author Posted August 28, 2015 thank you for fast answer ! exports.scoreboard:addScoreboardColumn('Rank') function onJoin() setElementData ( source, "Rank", "Guest" ) end addEventHandler("onPlayerJoin",root,onJoin) function onLogin() local aname = getAccountName(source) if isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Admin" ) ) then setElementData ( source, "Rank", "Admin" ) elseif isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Moderator" ) ) then setElementData ( source, "Rank", "Moderator" ) elseif isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Vip" ) ) then setElementData ( source, "Rank", "Vip" ) else setElementData ( source, "Rank", "Player" ) end end addEventHandler("onPlayerLogin",root,onJoin) I'm a guest on scoreboard, what i did wrong ? Thank you
JR10 Posted August 28, 2015 Posted August 28, 2015 getAccountName is used on an account not a player. function onLogin(_,acc) local aname = getAccountName(acc) ... end
Lordkrypton Posted August 28, 2015 Author Posted August 28, 2015 exports.scoreboard:addScoreboardColumn('Rank') function onJoin() setElementData ( source, "Rank", "Guest" ) end addEventHandler("onPlayerJoin",root,onJoin) function onLogin(_,acc) local aname = getAccountName(acc) if isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Admin" ) ) then setElementData ( source, "Rank", "Admin" ) elseif isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Moderator" ) ) then setElementData ( source, "Rank", "Moderator" ) elseif isObjectInACLGroup ( "user." .. aname, aclGetGroup ( "Vip" ) ) then setElementData ( source, "Rank", "Vip" ) else setElementData ( source, "Rank", "Player" ) end end addEventHandler("onPlayerLogin",root,onJoin) like that ?
Lordkrypton Posted August 28, 2015 Author Posted August 28, 2015 lol i'm stupid x) It's work so.. thank you a lot
Lordkrypton Posted August 28, 2015 Author Posted August 28, 2015 How to make "Admin", "VIP", "Moderator" in color. Like create a variable for exemple : local admin = text("Admin", 255, 0, 255) ? and after setElementData ( source, "Rank", admin ) Thank you
JR10 Posted August 28, 2015 Posted August 28, 2015 If you're drawing this client-side, you can check for the group and set the color based on it. local r, g, b if (rank == 'Admin') then r, g, b = 255, 0, 0 elseif (rank == 'Player') then r, g, b = 0, 255, 0 end
Lordkrypton Posted August 28, 2015 Author Posted August 28, 2015 I create new file client.lua and paste it local r, g, b if (rank == 'Admin') then r, g, b = 255, 0, 0 elseif (rank == 'Moderator') then r, g, b = 0, 255, 0 elseif (rank =='Vip') then r, g, b = 255, 215, 0 elseif (rank == 'Guest') then r, g, b = 224, 255, 255 end But it's didn't work, there is no way to do it server-side like the output chatbox function ? Thanks
JR10 Posted August 28, 2015 Posted August 28, 2015 It obviously depends on how you want to output it, if it's chat then yes you can do it server-side.
JR10 Posted August 28, 2015 Posted August 28, 2015 I don't think it's possible by default. You'll have to edit the scoreboard for that.
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