rusztamas Posted March 30, 2017 Share Posted March 30, 2017 function kirugas(admin, parancs, jatekos, indok) if not getElementData(admin, "gm", true) then outputChatBox ("#A1D490[King of the Kill]#FFFFFF Nincs jogod a parancs használatához.", admin, 255, 255, 255, true) end if not jatekos and getElementData(admin, "gm", true) then outputChatBox ("#A1D490[King of the Kill] #FFFFFFHibás szintaxis. Helyes: #A1D490/"..parancs.." #86B5DB[játékosnév] [opcionális indok]", admin, 255, 255, 255, true) end if jatekos and not indok and getElementData(admin, "gm", true) then local jatekos = getPlayerFromName(jatekos) kickPlayer (jatekos, admin, "Ismeretlen indok.") if indok and getElementData(admin, "gm", true) then kickPlayer (jatekos, admin, indok) end end end addCommandHandler ("kirugas", kirugas) It wont kick the player, with the reason. It kicks the player without reason, but when i add reason it is not working. Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 Which line doesn't kick? Line nr. 10 or 12? Nvm, give me a minute, gonna fix it. function kirugas(admin, parancs, jatekos, indok) if not getElementData(admin, "gm", true) then outputChatBox ("#A1D490[King of the Kill]#FFFFFF Nincs jogod a parancs használatához.", admin, 255, 255, 255, true) end if not jatekos and getElementData(admin, "gm", true) then outputChatBox ("#A1D490[King of the Kill] #FFFFFFHibás szintaxis. Helyes: #A1D490/"..parancs.." #86B5DB[játékosnév] [opcionális indok]", admin, 255, 255, 255, true) end local jatekos = getPlayerFromName(jatekos) if jatekos and not indok and getElementData(admin, "gm", true) then kickPlayer (jatekos, admin, "Ismeretlen indok.") elseif indok and jatekos and getElementData(admin, "gm", true) then kickPlayer (jatekos, admin, indok) end end addCommandHandler ("kirugas", kirugas) This one should work. 1 Link to comment
rusztamas Posted March 30, 2017 Author Share Posted March 30, 2017 This is working, thanks, but what if the kick reason is more than a word? How can i do that? And what was the problem with the mine? Link to comment
itHyperoX Posted March 30, 2017 Share Posted March 30, 2017 function kirugas(admin, parancs, jatekos, ...) local indok = table.concat({ ... }, " ") if not getElementData(admin, "gm", true) then outputChatBox ("#A1D490[King of the Kill]#FFFFFF Nincs jogod a parancs használatához.", admin, 255, 255, 255, true) end if not jatekos and getElementData(admin, "gm", true) then outputChatBox ("#A1D490[King of the Kill] #FFFFFFHibás szintaxis. Helyes: #A1D490/"..parancs.." #86B5DB[játékosnév] [opcionális indok]", admin, 255, 255, 255, true) end local jatekos = getPlayerFromName(jatekos) if jatekos and not indok and getElementData(admin, "gm", true) then kickPlayer (jatekos, admin, "Ismeretlen indok.") elseif indok and jatekos and getElementData(admin, "gm", true) then kickPlayer (jatekos, admin, indok) end end addCommandHandler ("kirugas", kirugas) 1 Link to comment
itHyperoX Posted March 30, 2017 Share Posted March 30, 2017 btw with this, you dont need to enter the player full name better to use this one for getting player name: In your script : local jatekos = getPlayerFromName(jatekos) with this you can use local jatekos = getPlayerFromPartialName(jatekos) function getPlayerFromPartialName(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 1 Link to comment
NeXuS™ Posted March 30, 2017 Share Posted March 30, 2017 (edited) Your problem in your code was a huge mistake. if jatekos and not indok and getElementData(admin, "gm", true) then local jatekos = getPlayerFromName(jatekos) kickPlayer (jatekos, admin, "Ismeretlen indok.") if indok and getElementData(admin, "gm", true) then kickPlayer (jatekos, admin, indok) end end First it checks, if you wrote anything in the "jatekos" arg. If yes, it goes by, and check if there is no "indok" set before, if there is nothing set to indok, it goes by. After it, checks for admin priviliges (I suppose), if you have, again, it goes by. After it's in the true part, it checks for the palyer by just name, and tries to kick him. (Which could lead to an error, if there is no one up on the server with that name. After the player got kicked, it checks for the "indok" arg, which CANNOT BE SET, because you checked at your first line if the "indok" arg doesn't exist. Which leads to that the if statements true part won't be triggered because it will be if false and true then -> if false then (false and true equals false, for the AND operator, you need two TRUE args to be passed to return TRUE.) And btw, if the script actually got somehow into that part (but it'll never), the player would be already kicked, and there is no way to kick a player who is not online. Edited March 30, 2017 by NeXuS™ 1 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