Jump to content

[QUESTION] Why not working this script?


Tokio

Recommended Posts

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?

Link to comment

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)

 

Link to comment
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 :/ 

Link to comment
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
Link to comment

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
Link to comment
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
Link to comment
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 :/ 

 

Link to comment
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
Link to comment
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)

 

 

Link to comment
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
Link to comment
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

 

Link to comment

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
Link to comment
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

Link to comment
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
Link to comment
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)

 

 

Link to comment
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
Link to comment
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

Link to comment
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 

Link to comment

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...