Saml1er Posted March 22, 2014 Posted March 22, 2014 Fix it for me! Learn to say the magic word "please". Such an attitude ain't kewl, you know?
Stranger Posted March 22, 2014 Posted March 22, 2014 addCommandHandler ("warn", function (player, cmd, playername) if playername then who = getPlayerFromName(playername) outputChatBox ("WARN: You have been warned", who, 255, 0, 0) else outputChatBox ("info: write - warn playername in f8", player, 255, 255, 0) end end)
zzx Posted March 22, 2014 Author Posted March 22, 2014 (edited) solved Edited March 22, 2014 by Guest
Saml1er Posted March 22, 2014 Posted March 22, 2014 Stop this Sam.I don't even know who you are. Learn to respect others, I was going to help you but my opinions changed. I didn't start anything which I should stop but you don't know how to respect others. Saying things like "Fix it for me", this shows that you are commanding us and I'm not a kind of person who would say "OK boss, I fixed it. No problem".
Dealman Posted March 22, 2014 Posted March 22, 2014 I highly suggest you read a few tutorials about how scripting works. You have a ton of errors in your code. This should work; function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function warnPlayer_CMD(thePlayer, theCMD, theTarget, ...) if(theTarget ~= nil) then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("[WARN]: "..getPlayerName(thePlayer).."#FF0000 has warned "..getPlayerName(theTargetElement).."#FF0000!", getRootElement(), 255, 0, 0, true) outputChatBox("[WARN]: Reason: #FF2626("..tostring(theReason)..")", getRootElement(), 255, 0, 0, true) else outputChatBox("[WARN]: Invalid target! Syntax: /warn [Player] [Reason]", thePlayer, 255, 0, 0, true) end end end addCommandHandler("warn", warnPlayer_CMD, false)
zzx Posted March 22, 2014 Author Posted March 22, 2014 How to make the accessible to the command only for staff, moderators, admins, supermoderators and consoles guys?
Weii. Posted March 22, 2014 Posted March 22, 2014 How to make the accessible to the command only for staff, moderators, admins, supermoderators and consoles guys? You can either check for every group with this if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "admin" ) ) then or you can simply use if (hasObjectPermissionTo(source, "function.kickPlayer", false)) then
Saml1er Posted March 22, 2014 Posted March 22, 2014 (edited) I'm very sorry Sam. If someone is ready to apologize then I've nothing against him anymore. I apologize for getting little bit harsh there. Use: function getPlayerFromNamePart(name) local name = name and name:gsub("#%x%x%x%x%x%x", ""):lower() or nil if name then for _, player in ipairs(getElementsByType("player")) do local name_ = getPlayerName(player):gsub("#%x%x%x%x%x%x", ""):lower() if name_:find(name, 1, true) then return player end end end end function warnPlayer_CMD(thePlayer, theCMD, theTarget, ...) local accN = getAccountName ( getPlayerAccount (thePlayer) ) local groupName = "Admin" or "Moderator" or "SuperModerator" -- you can add more if groupName then if theTarget ~= nil and isObjectInACLGroup ("user."..accN,aclGetGroup (groupName) then local theTargetElement = getPlayerFromNamePart(theTarget) if(getElementType(theTargetElement) == "player") then local allArgs = {...} local theReason = table.concat(allArgs, " ") outputChatBox("[WARN]: "..getPlayerName(thePlayer).."#FF0000 has warned "..getPlayerName(theTargetElement).."#FF0000!", getRootElement(), 255, 0, 0, true) outputChatBox("[WARN]: Reason: #FF2626("..tostring(theReason)..")", getRootElement(), 255, 0, 0, true) else outputChatBox("[WARN]: Invalid target! Syntax: /warn [Player] [Reason]", thePlayer, 255, 0, 0, true) end end end end addCommandHandler("warn", warnPlayer_CMD, false) Edited March 22, 2014 by Guest
Saml1er Posted March 22, 2014 Posted March 22, 2014 I did a type there at line 30. Just replace line 30 with this if theTarget ~= nil and isObjectInACLGroup ("user."..accN,aclGetGroup (groupName) ) then -- missing bracket
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