Jump to content

[BUG] How to fix this interesting bug in this script?


Tokio

Recommended Posts

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)

Sometimes working the "asay xy" cmd, sometimes not working. :/ How to fix this bug? 

Link to comment
Just now, Gourmet. said:

Where is the table 'names' specified?

 

local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "Moderátor"
}

 

Link to comment
local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "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"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

@50cent

Not tested though.

Link to comment
4 minutes ago, Gourmet. said:

local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "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"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,getRootElement(),0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

@50cent

Not tested though.

Now when i type for example "/asay asd" output often instead of once

sorry for my bad english :c

Link to comment

 


local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "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"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Should work.

  • Like 1
Link to comment
4 minutes ago, Gourmet. said:

 


local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "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"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Should work.

Thank you! :D

Link to comment
13 hours ago, Gourmet. said:

 


local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "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"]
					outputChatBox("#0088FF["..groupName.."]#d8001f  "..getPlayerName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Should work.

Wait, lol! Yesterday was still good, but today it does not work at all the cmd. Wtf? O.o 

Link to comment
2 minutes ago, 50cent said:

Wait, lol! Yesterday was still good, but today it does not work at all the cmd. Wtf? O.o 

Man, are you sure that no one has access to your FTP and do you trust all admins?

It can't just stop working. Have you edited anything? Please post the current code, meta.xml and server log where the resource could been restarted or interfered with. Maybe you have changed ACL?

Link to comment
1 minute ago, Gourmet. said:

Man, are you sure that no one has access to your FTP and do you trust all admins?

It can't just stop working. Have you edited anything? Please post the current code, meta.xml and server log where the resource could been restarted or interfered with. Maybe you have changed ACL?

i sure that no one has access to my FTP! i just edited the output nothing else.

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

local names = {
	["Admin"] = "Tulajdonos",
	["LathatatlanAdmin"] = "Tulajdonos",
	["FoAdmin"] = "FőAdmin",
	["LFoAdmin"] = "FőAdmin",
	["Adminseged"] = "AdminSegéd",
	["LathatatlanAdminseged"] = "AdminSegéd",
	["KisAdmin"] = "Admin",
	["Fejleszto"] = "Fejlesztő",
	["Moderator"] = "Moderátor",
	["LathatatlanModi"] = "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]
					outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

this is the current code, 

<meta>
<script src="asay.lua" type="server"/>
</meta>

and this is meta

i does not change anything in ACL :/ 

Link to comment
function adminuzi(thePlayer, commandName, ...)
  	outputDebugString("function is working P1")
	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
        		outputDebugString("P2")
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then
          			outputDebugString("P3 - acl valid")
					message = table.concat({...}, " ")
					groupName = names[group]
					outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Try that and tell me what outputs in your /debugscript 3.

 

Maybe something shows up when the resource starts? at debugscript 3 )

Edited by Gourmet.
Link to comment
29 minutes ago, Gourmet. said:

function adminuzi(thePlayer, commandName, ...)
  	outputDebugString("function is working P1")
	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
        		outputDebugString("P2")
				if isObjectInACLGroup("user."..getAccountName(getPlayerAccount(thePlayer)), aclGetGroup( group )) then
          			outputDebugString("P3 - acl valid")
					message = table.concat({...}, " ")
					groupName = names[group]
					outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)
				end
			end
        end
	end
end
addCommandHandler("asay", adminuzi)

Try that and tell me what outputs in your /debugscript 3.

 

Maybe something shows up when the resource starts? at debugscript 3 )

output this in debugscript 3:

http://imgur.com/a/WTD1D

but the word does not output in chatbox ._.

No, nothing shows up when i start the script

Link to comment

Try with simple words like "hello", maybe you go over the character limit of outputChatBox

 

Edit: What is the purpose of this script? You do /asay and every single player sees the message, right? If so change this

outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)

To this:

outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,root,0,0,0,true)

And you don't need the for loop with players anyway..

Edited by pa3ck
Link to comment
34 minutes ago, pa3ck said:

Try with simple words like "hello", maybe you go over the character limit of outputChatBox

 

Edit: What is the purpose of this script? You do /asay and every single player sees the message, right? If so change this


outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,v,0,0,0,true)

To this:


outputChatBox("#0088FF[SUPERFUN-Rangos]#d8001f "..groupName.." "..getFixedName(thePlayer)..": "..message,root,0,0,0,true)

And you don't need the for loop with players anyway..

Yeah, but with 'root' flood again the message :S 

Edited by 50cent
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...