Jump to content

[QUESTION] Why not working this script?


Tokio

Recommended Posts

Posted
local titles = { "AdminSegéd", "Moderátor", "SzuperModerátor", "Admin", "FőAdmin", "Tulajdonos", "Fejlesztő" }
function getPlayerAdminTitle()
local text = titles
    if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Admin")) then
	text = "Tulajdonos"
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("FoAdmin")) then
	text = "FőAdmin"
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Adminseged")) then
	text = "AdminSegéd"
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("KisAdmin")) then
	text = "Admin"
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Fejleszto")) then
	text = "Fejlesztő"
    elseif isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(source)), aclGetGroup("Moderator")) then
	text = "Moderátor"
end
end

function getFixedName(player)
if isElement(player) then
local hisName = getPlayerName(player)
if hisName then
 result = string.gsub(hisName, '#%x%x%x%x%x%x', '')
 if result then
 return result
 end
end
end
end

function adminuzi(thePlayer, commandName, ...)
	if isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Admin")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("FoAdmin")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Adminseged")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("KisAdmin")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Fejleszto")) or isObjectInACLGroup("user." .. getAccountName(getPlayerAccount(thePlayer)), aclGetGroup("Moderator")) then
		if not (...) then
			outputChatBox("#00FF7F[Használat]:#FFFFFF /".. commandName .." [üzenet]", thePlayer, 0, 206, 209,true)
		else
			local adminrang = getPlayerAdminTitle(thePlayer)
			message = table.concat({...}, " ")
			local playerName = getFixedName ( thePlayer )
			outputChatBox("#0088FF[SUPERFUN-Admin]#d8001f  "..playerName..": "..message,getRootElement(),0,0,0,true)
		end
	end
end
addCommandHandler("asay", adminuzi, false, false)

i have this script, and i get this warnings/error:

How to fix this?

Posted

I highly recommend you to use setElementData, getElementData for administrator system! 

 

If you want, you can use feel free :), and if you need more help you can PM me!

--< Belépéskor >--
addEventHandler("onPlayerLogin", getRootElement(),function(_, account)
    tonumber(setElementData(source, "acc.admin", tonumber(getAccountData(account, "acc.admin"))) or 0)
end)


--< Mentés >--
addEventHandler('onPlayerQuit',root,function( account )
local account = eventName == 'onPlayerLogout' and account or getPlayerAccount(source)
	if (account) and (not isGuestAccount(account)) then
		setAccountData(account,'acc.admin',getElementData(source,'acc.admin') or 0)
	end
end)

 

Posted
8 minutes ago, TheMOG said:

I highly recommend you to use setElementData, getElementData for administrator system! 

 

If you want, you can use feel free :), and if you need more help you can PM me!


--< Belépéskor >--
addEventHandler("onPlayerLogin", getRootElement(),function(_, account)
    tonumber(setElementData(source, "acc.admin", tonumber(getAccountData(account, "acc.admin"))) or 0)
end)


--< Mentés >--
addEventHandler('onPlayerQuit',root,function( account )
local account = eventName == 'onPlayerLogout' and account or getPlayerAccount(source)
	if (account) and (not isGuestAccount(account)) then
		setAccountData(account,'acc.admin',getElementData(source,'acc.admin') or 0)
	end
end)

 

i just want, when i type "/asay xy" output in chatbox the player's rank and for example instead of admin show "Tulajdonos"

sorry for my very bad english :/ 

Posted (edited)
local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}
local players = {}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(aclGroupList()) do
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer), v) then
			if aclGroupGetName(v) == "Everyone" then return end
			players[thePlayer] = aclGroupGetName(v)
		end
	end
	local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..players[thePlayer].."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

 

Edited by kikos500
  • Like 1
Posted (edited)

Thank you:D

3 hours ago, kikos500 said:

local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}
local players = {}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(aclGroupList()) do
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer), v) then
			if aclGroupGetName(v) == "Everyone" then return end
			players[thePlayer] = aclGroupGetName(v)
		end
	end
	local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..players[thePlayer].."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

 

i got new warnings/error:

how to fix?

Edited by 50cent
fixed the problem
Posted (edited)
local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}
local players = {}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(aclGroupList()) do
        if isGuestAccount( getPlayerAccount( v ) ) then return end
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer), aclGetGroup( v )) then
			players[thePlayer] = aclGroupGetName(v)
		end
	end
	local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..players[thePlayer].."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

 

Edited by Gordon_G
Posted
4 minutes ago, Gordon_G said:

local names = {	["Admin"] = "Tulajdonos",	["Moderator"] = "Moderátor"}local players = {}function adminuzi(thePlayer, commandName, ...)	for i,v in pairs(aclGroupList()) do		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer), aclGetGroup( v )) then			players[thePlayer] = aclGroupGetName(v)		end	end	local message = table.concat({...}, " ")	outputChatBox("#0088FF["..players[thePlayer].."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)endaddCommandHandler("asay", adminuzi)

 

same problem :/ 

 

Posted (edited)
local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, _ in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer), aclGetGroup( group )) then
		    		local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..group.."]#d8001f  "..getPlayerName(v)..": "..message,getRootElement(),0,0,0,true)
		    end
        end
	end
end
addCommandHandler("asay", adminuzi)

 

Edited by Gordon_G
Posted
5 minutes ago, Gordon_G said:

local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}
local players = {}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(names) do
        if isGuestAccount( getPlayerAccount( v ) ) then return end
		if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer), aclGetGroup( v )) then
			players[thePlayer] = aclGroupGetName(v)
		end
	end
	local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..players[thePlayer].."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

 

 

Posted
local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, _ in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
		    		local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..group.."]#d8001f  "..getPlayerName(v)..": "..message,getRootElement(),0,0,0,true)
		    end
        end
	end
end
addCommandHandler("asay", adminuzi)

It should work now.

  • Like 1
Posted
2 minutes ago, Gordon_G said:

local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, _ in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
		    		local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..group.."]#d8001f  "..getPlayerName(v)..": "..message,getRootElement(),0,0,0,true)
		    end
        end
	end
end
addCommandHandler("asay", adminuzi)

It should work now.

working, but does not show "Tulajdonos" instead of admin

 

Posted

Oh, okey, i'll change that.

 

local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
		    		local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..serverGroupName.."]#d8001f  "..getPlayerName(v)..": "..message,getRootElement(),0,0,0,true)
		    end
        end
	end
end
addCommandHandler("asay", adminuzi)

 

  • Like 1
Posted
1 minute ago, Gordon_G said:

Oh, okey, i'll change that.

 


local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
		    		local message = table.concat({...}, " ")
	outputChatBox("#0088FF["..serverGroupName.."]#d8001f  "..getPlayerName(v)..": "..message,getRootElement(),0,0,0,true)
		    end
        end
	end
end
addCommandHandler("asay", adminuzi)

 

Thank you!! :D

Posted
9 minutes ago, Gordon_G said:

You're welcome.

Lol, i put this script in my server, and write in the name of everyone, how to fix this? O.o

Just i have admin rank O.o 

Posted (edited)
local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
		    	message = table.concat({...}, " ")
          		groupName = names["group"]
		    end
        end
	end
	outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

 

Edited by koragg
not sure about the groupName = names["group"] part
Posted
7 minutes ago, koragg said:

local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
		    if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
		    	message = table.concat({...}, " ")
		    end
        end
	end
	outputChatBox("#0088FF["..serverGroupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

 

 

Posted (edited)
local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
				end
			end
        end
	end
	outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

If this^ doesn't work try making it:

groupName = names[group]

or

groupName = names["'"..group.."'"]

 

Edited by koragg
  • Like 1
Posted
9 minutes ago, koragg said:

local names = {
	["Admin"] = "Tulajdonos",
	["Moderator"] = "Moderátor"
}


function adminuzi(thePlayer, commandName, ...)
	for i,v in pairs(getElementsByType( "player" )) do
        for group, serverGroupName in pairs( names ) do
            if isGuestAccount( getPlayerAccount( v ) ) then return end
			if group then
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group ) then
					message = table.concat({...}, " ")
					groupName = names["group"]
				end
			end
        end
	end
	outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
end
addCommandHandler("asay", adminuzi)

If this^ doens't work try making it:


groupName = names[group]

or


groupName = names["'"group"'"]

 

Thank you, now work fine! :D

Posted
2 hours ago, koragg said:

You're welcome :P

Lol, now i have a new problem. O.o The script working, but sometimes the /asay xy command does not working, wtf?! O.o When i restart the resource many times then working again, but just for a few minutes, and does not working again. Wtf, how to fix this problem? :o 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...