Jump to content

Litte Radio Script


Diverti

Recommended Posts

Hi everyone! I have a radio script, but it not works, i got this error message:

attempt to call local 'thePlayer' (a userdata value)

  
function kozosradio(thePlayer, commandName, ...) 
    local theFrakcio = getPlayerTeam(thePlayer) 
     
    if (theFrakcio) then 
        local frakcioID = tonumber(getElementData(theFrakcio, "id")) 
  
        if (frakcioID==1 or frakcioID==2 or frakcioID==3 or frakcioID == 4 or frakcioID == 5 or frakcioID == 6) then 
            if (...) then 
                local message = trunklateText( thePlayer, table.concat({...}, " ") ) 
                local PDFrakcio = getPlayersInTeam(thePlayer("Rendőrség")) 
                local OMSZFrakcio = getPlayersInTeam(getTeamFromName("Országos Mentő Szolgálat")) 
                local NNIFrakcio = getPlayersInTeam(getTeamFromName("Nemzeti Nyomozó Iroda")) 
                local GOVFrakcio = getPlayersInTeam(getTeamFromName("Önkormányzat")) 
                local NAVFrakcio = getPlayersInTeam(getTeamFromName("Nemzeti Adó Vámhivatal")) 
                local playerName = getPlayerName(thePlayer) 
                 
                for key, value in ipairs(PDFrakcio) do 
                outputChatBox("[#PD] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                 
                for key, value in ipairs(OMSZFrakcio) do 
                outputChatBox("[#OMSZ] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                 
                for key, value in ipairs(NNIFrakcio) do 
                outputChatBox("[#NNI] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                 
                for key, value in ipairs(GOVFrakcio) do 
                outputChatBox("[#GOV] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                 
                for key, value in ipairs(NAVFrakcio) do 
                outputChatBox("[#NAV] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
            end 
        end 
    end 
end 
addCommandHandler("d", kozosradio, false, false) 
  

I hope, someone can help me :)

Link to comment

I don't see a error in this part, it must be the trunkslate function:

  
function kozosradio(thePlayer, commandName, ...) 
    local theFrakcio = getPlayerTeam(thePlayer) 
    
    if (theFrakcio) then 
        local frakcioID = tonumber(getElementData(theFrakcio, "id")) 
  
        if (frakcioID==1 or frakcioID==2 or frakcioID==3 or frakcioID == 4 or frakcioID == 5 or frakcioID == 6) then 
            if (...) then 
                local message = table.concat({...}) 
                local PDFrakcio = getPlayersInTeam(thePlayer("Rendorség")) 
                local OMSZFrakcio = getPlayersInTeam(getTeamFromName("Országos Mento Szolgálat")) 
                local NNIFrakcio = getPlayersInTeam(getTeamFromName("Nemzeti Nyomozó Iroda")) 
                local GOVFrakcio = getPlayersInTeam(getTeamFromName("Önkormányzat")) 
                local NAVFrakcio = getPlayersInTeam(getTeamFromName("Nemzeti Adó Vámhivatal")) 
                local playerName = getPlayerName(thePlayer) 
                
                for key, value in ipairs(PDFrakcio) do 
                outputChatBox("[#PD] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                
                for key, value in ipairs(OMSZFrakcio) do 
                outputChatBox("[#OMSZ] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                
                for key, value in ipairs(NNIFrakcio) do 
                outputChatBox("[#NNI] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                
                for key, value in ipairs(GOVFrakcio) do 
                outputChatBox("[#GOV] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
                
                for key, value in ipairs(NAVFrakcio) do 
                outputChatBox("[#NAV] " .. playerName .. " mondja: " .. message, value, 0, 102, 255) 
                end 
            end 
        end 
    end 
end 
addCommandHandler("d", kozosradio, false, false) 
  

Link to comment

This is your problem;

local PDFrakcio = getPlayersInTeam(thePlayer("Rendorség")) 

If you want to take all the players out of the team, you've to say which team you want. Right now you've used thePlayer as a function or something like that. Try this;

local PDFrakcio = getPlayersInTeam ( getPlayerTeam ( thePlayer ) ); 

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