Jump to content

Help in Radio System !


Max+

Recommended Posts

Hi all i keep giting this error !

bad argument #1 to 'ipairs' ( table expected , got boolean)

iam Making it for teams

team 1 and team 2

it source == team 1 then radio for team 1 only

else if source == team 2 then radio for team 2 only

function radio ( x ) 
local r, g, b = getTeamColor(getPlayerTeam(source)) 
local team = getTeamFromName ( getTeamName(getPlayerTeam(source)) ) 
local players = getPlayersInTeam ( team ) 
for k,v in ipairs(players) do 
    if getTeamName(getPlayerTeam(source)) == "Team1" then 
        setElementVisibleTo (Team1, v, false) 
        setTimer (setElementVisibleTo, 500, 1, Team1, v, true) 
        setTimer (setElementVisibleTo, 1000, 1, Team1, v, false) 
        setTimer (setElementVisibleTo, 1500, 1, Team1, v, true) 
        setTimer (setElementVisibleTo, 2000, 1, Team1, v, false) 
        setTimer (setElementVisibleTo, 2500, 1, Team1, v, true) 
    elseif getTeamName(getPlayerTeam(source)) == "Team2" then 
        setElementVisibleTo (Team2[source], v, false) 
        setTimer (setElementVisibleTo, 500, 1, Team2[source], v, true) 
        setTimer (setElementVisibleTo, 1000, 1, Team2[source], v, false) 
        setTimer (setElementVisibleTo, 1500, 1, Team2[source], v, true) 
        setTimer (setElementVisibleTo, 2000, 1, Team2[source], v, false) 
        setTimer (setElementVisibleTo, 2500, 1, Team2[source], v, true) 
    end 
    if ( x == 5) then 
        outputChatBox (""..getPlayerName(source)..": Taking Fire! Need Assistance!", v, r, g, b) 
    elseif ( x == 1 ) then 
        outputChatBox (""..getPlayerName(source)..": Attack the Enemys Team !", v, r, g, b) 
    elseif ( x == 2 ) then 
        outputChatBox (""..getPlayerName(source)..": Defend our Team!", v, r, g, b) 
    elseif ( x == 3 ) then 
        outputChatBox (""..getPlayerName(source)..": Its ours", v, r, g, b) 
    elseif ( x == 4 ) then 
        outputChatBox (""..getPlayerName(source)..": I Cant Help !", v, r, g, b) 
    elseif ( x == 6 ) then 
        outputChatBox (""..getPlayerName(source)..": Requesting backup!!!", v, r, g, b) 
    elseif ( x == 11 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy spotted!!", v, r, g, b) 
    elseif ( x == 12 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy Vehicle spotted!!", v, r, g, b) 
    elseif ( x == 13 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy Airplane spotted!!", v, r, g, b) 
    elseif ( x == 16 ) then 
        outputChatBox (""..getPlayerName(source)..": Roger that!", v, r, g, b) 
    elseif ( x == 17 ) then 
        outputChatBox (""..getPlayerName(source)..": Negative!", v, r, g, b) 
    elseif ( x == 18 ) then 
        outputChatBox (""..getPlayerName(source)..": I got one!", v, r, g, b) 
    end 
end 
end 
addEvent ("radio", true) 
addEventHandler ("radio", getRootElement(), radio) 

Link to comment
function radio ( x ) 
    local team = getPlayerTeam ( source ) 
    if ( not team ) then 
        return outputChatBox ( "You are not in a team.", source, 255, 0, 0 ) 
    end 
  
    local r, g, b = getTeamColor ( team ) 
    local players = getPlayersInTeam ( team ) 
    for k,v in ipairs(players) do 
    if getTeamName(getPlayerTeam(source)) == "Team1" then 
        setElementVisibleTo (Team1, v, false) 
        setTimer (setElementVisibleTo, 500, 1, Team1, v, true) 
        setTimer (setElementVisibleTo, 1000, 1, Team1, v, false) 
        setTimer (setElementVisibleTo, 1500, 1, Team1, v, true) 
        setTimer (setElementVisibleTo, 2000, 1, Team1, v, false) 
        setTimer (setElementVisibleTo, 2500, 1, Team1, v, true) 
    elseif getTeamName(getPlayerTeam(source)) == "Team2" then 
        setElementVisibleTo (Team2[source], v, false) 
        setTimer (setElementVisibleTo, 500, 1, Team2[source], v, true) 
        setTimer (setElementVisibleTo, 1000, 1, Team2[source], v, false) 
        setTimer (setElementVisibleTo, 1500, 1, Team2[source], v, true) 
        setTimer (setElementVisibleTo, 2000, 1, Team2[source], v, false) 
        setTimer (setElementVisibleTo, 2500, 1, Team2[source], v, true) 
    end 
    if ( x == 5) then 
        outputChatBox (""..getPlayerName(source)..": Taking Fire! Need Assistance!", v, r, g, b) 
    elseif ( x == 1 ) then 
        outputChatBox (""..getPlayerName(source)..": Attack the Enemys Team !", v, r, g, b) 
    elseif ( x == 2 ) then 
        outputChatBox (""..getPlayerName(source)..": Defend our Team!", v, r, g, b) 
    elseif ( x == 3 ) then 
        outputChatBox (""..getPlayerName(source)..": Its ours", v, r, g, b) 
    elseif ( x == 4 ) then 
        outputChatBox (""..getPlayerName(source)..": I Cant Help !", v, r, g, b) 
    elseif ( x == 6 ) then 
        outputChatBox (""..getPlayerName(source)..": Requesting backup!!!", v, r, g, b) 
    elseif ( x == 11 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy spotted!!", v, r, g, b) 
    elseif ( x == 12 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy Vehicle spotted!!", v, r, g, b) 
    elseif ( x == 13 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy Airplane spotted!!", v, r, g, b) 
    elseif ( x == 16 ) then 
        outputChatBox (""..getPlayerName(source)..": Roger that!", v, r, g, b) 
    elseif ( x == 17 ) then 
        outputChatBox (""..getPlayerName(source)..": Negative!", v, r, g, b) 
    elseif ( x == 18 ) then 
        outputChatBox (""..getPlayerName(source)..": I got one!", v, r, g, b) 
    end 
end 
end 
addEvent ("radio", true) 
addEventHandler ("radio", getRootElement(), radio) 

Link to comment

I didn't understand what is this for:

if getTeamName(getPlayerTeam(source)) == "Team1" then 
        setElementVisibleTo (Team1, v, false) 
        setTimer (setElementVisibleTo, 500, 1, Team1, v, true) 
        setTimer (setElementVisibleTo, 1000, 1, Team1, v, false) 
        setTimer (setElementVisibleTo, 1500, 1, Team1, v, true) 
        setTimer (setElementVisibleTo, 2000, 1, Team1, v, false) 
        setTimer (setElementVisibleTo, 2500, 1, Team1, v, true) 
    elseif getTeamName(getPlayerTeam(source)) == "Team2" then 
        setElementVisibleTo (Team2[source], v, false) 
        setTimer (setElementVisibleTo, 500, 1, Team2[source], v, true) 
        setTimer (setElementVisibleTo, 1000, 1, Team2[source], v, false) 
        setTimer (setElementVisibleTo, 1500, 1, Team2[source], v, true) 
        setTimer (setElementVisibleTo, 2000, 1, Team2[source], v, false) 
        setTimer (setElementVisibleTo, 2500, 1, Team2[source], v, true) 
    end 

Link to comment

so it well be like this ?

function radio ( x ) 
    local team = getPlayerTeam ( source ) 
    if ( not team ) then 
        return outputChatBox ( "You are not in a team!", source, 255, 0, 0 ) 
    end 
    local r, g, b = getTeamColor ( team ) 
    local players = getPlayersInTeam ( team ) 
    for k,v in ipairs(players) do 
    if getTeamName(getPlayerTeam(source)) == "Team1" then 
    elseif getTeamName(getPlayerTeam(source)) == "Team2" then 
    end 
    if ( x == 5) then 
        outputChatBox (""..getPlayerName(source)..": Taking Fire! Need Assistance!", v, r, g, b) 
    elseif ( x == 1 ) then 
        outputChatBox (""..getPlayerName(source)..": Attack the Enemys Team !", v, r, g, b) 
    elseif ( x == 2 ) then 
        outputChatBox (""..getPlayerName(source)..": Defend our Team!", v, r, g, b) 
    elseif ( x == 3 ) then 
        outputChatBox (""..getPlayerName(source)..": Its ours", v, r, g, b) 
    elseif ( x == 4 ) then 
        outputChatBox (""..getPlayerName(source)..": I Cant Help !", v, r, g, b) 
    elseif ( x == 6 ) then 
        outputChatBox (""..getPlayerName(source)..": Requesting backup!!!", v, r, g, b) 
    elseif ( x == 11 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy spotted!!", v, r, g, b) 
    elseif ( x == 12 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy Vehicle spotted!!", v, r, g, b) 
    elseif ( x == 13 ) then 
        outputChatBox (""..getPlayerName(source)..": Enemy Airplane spotted!!", v, r, g, b) 
    elseif ( x == 16 ) then 
        outputChatBox (""..getPlayerName(source)..": Roger that!", v, r, g, b) 
    elseif ( x == 17 ) then 
        outputChatBox (""..getPlayerName(source)..": Negative!", v, r, g, b) 
    elseif ( x == 18 ) then 
        outputChatBox (""..getPlayerName(source)..": I got one!", v, r, g, b) 
    end 
end 
end 
addEvent ("radio", true) 
addEventHandler ("radio", getRootElement(), radio) 

Link to comment
function radio ( x ) 
    local team = getPlayerTeam ( source ) 
    if ( not team ) then 
        return outputChatBox ( "You are not in a team!", source, 255, 0, 0 ) 
    end 
  
    local r, g, b = getTeamColor ( team ) 
    local players = getPlayersInTeam ( team ) 
    for _, v in ipairs ( players ) do 
        if ( x == 5) then 
            outputChatBox (""..getPlayerName(source)..": Taking Fire! Need Assistance!", v, r, g, b) 
        elseif ( x == 1 ) then 
            outputChatBox (""..getPlayerName(source)..": Attack the Enemys Team !", v, r, g, b) 
        elseif ( x == 2 ) then 
            outputChatBox (""..getPlayerName(source)..": Defend our Team!", v, r, g, b) 
        elseif ( x == 3 ) then 
            outputChatBox (""..getPlayerName(source)..": Its ours", v, r, g, b) 
        elseif ( x == 4 ) then 
            outputChatBox (""..getPlayerName(source)..": I Cant Help !", v, r, g, b) 
        elseif ( x == 6 ) then 
            outputChatBox (""..getPlayerName(source)..": Requesting backup!!!", v, r, g, b) 
        elseif ( x == 11 ) then 
            outputChatBox (""..getPlayerName(source)..": Enemy spotted!!", v, r, g, b) 
        elseif ( x == 12 ) then 
            outputChatBox (""..getPlayerName(source)..": Enemy Vehicle spotted!!", v, r, g, b) 
        elseif ( x == 13 ) then 
            outputChatBox (""..getPlayerName(source)..": Enemy Airplane spotted!!", v, r, g, b) 
        elseif ( x == 16 ) then 
            outputChatBox (""..getPlayerName(source)..": Roger that!", v, r, g, b) 
        elseif ( x == 17 ) then 
            outputChatBox (""..getPlayerName(source)..": Negative!", v, r, g, b) 
        elseif ( x == 18 ) then 
            outputChatBox (""..getPlayerName(source)..": I got one!", v, r, g, b) 
        end 
    end 
end 
addEvent ("radio", true) 
addEventHandler ("radio", getRootElement(), radio) 

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