Jump to content

Weird error


anumaz

Recommended Posts

Posted
function serverfire (thePlayer) 
    for k, v in ipairs ( getPlayersInTeam ( getTeamFromName( "Los Santos Fire Department" ) ) ) do 
        outputChatBox("[RADIO] This is dispatch, We've got a report from a fire at " .. randomfire[4] .. " via the emergency line, over.", v, 245, 40, 135) 
        outputChatBox("[RADIO] Please report there NOW.", v, 245, 40, 135) 
    end 
    if exports.global:isPlayerAdmin(thePlayer)  then 
        triggerClientEvent( "burnbabyburn", getRootElement(), jevifire ) 
        triggerClientEvent( "ringTheBell", root, fdbell ) 
        outputChatBox("Fiiiire!", thePlayer) 
    end 
end 
addCommandHandler ( "jevifire" , serverfire ) 
  

I'm getting this error:

Line #11: bad argument #1 to 'ipairs' (table expected, got nil)

I really don't know how to fix it.

  • Moderators
Posted
function serverfire (thePlayer) 
    local team = getTeamFromName( "Los Santos Fire Department" ) 
    if team then 
        for k, v in ipairs ( getPlayersInTeam (team) ) do 
            outputChatBox("[RADIO] This is dispatch, We've got a report from a fire at " .. randomfire[4] .. " via the emergency line, over.", v, 245, 40, 135) 
            outputChatBox("[RADIO] Please report there NOW.", v, 245, 40, 135) 
        end 
    else 
        outputChatBox("ERROR: team doesn't exist.",thePlayer) 
    end 
    if exports.global:isPlayerAdmin(thePlayer)  then 
        triggerClientEvent( "burnbabyburn", getRootElement(), jevifire ) 
        triggerClientEvent( "ringTheBell", root, fdbell ) 
        outputChatBox("Fiiiire!", thePlayer) 
    end 
end 
addCommandHandler ( "jevifire" , serverfire ) 
  

Posted
function serverfire (thePlayer) 
    local team = getTeamFromName( "Los Santos Fire Department" ) 
    if team then 
        for k, v in ipairs ( getPlayersInTeam (team) ) do 
            outputChatBox("[RADIO] This is dispatch, We've got a report from a fire at " .. randomfire[4] .. " via the emergency line, over.", v, 245, 40, 135) 
            outputChatBox("[RADIO] Please report there NOW.", v, 245, 40, 135) 
        end 
    else 
        outputChatBox("ERROR: team doesn't exist.",thePlayer) 
    end 
    if exports.global:isPlayerAdmin(thePlayer)  then 
        triggerClientEvent( "burnbabyburn", getRootElement(), jevifire ) 
        triggerClientEvent( "ringTheBell", root, fdbell ) 
        outputChatBox("Fiiiire!", thePlayer) 
    end 
end 
addCommandHandler ( "jevifire" , serverfire ) 
  

I'm getting the same error. :/

Posted
So you're sure that you created a team called like that and are in that team ?

Yes, I did:

crun for k, v in ipairs ( getPlayersInTeam ( getTeamFromName( "Los Santos Fire Department" ) ) ) do outputChatBox ( "Hello", v ) end

and it returned me 'Hello'!

Posted
randomfire where's it defined in ?

That's not really the issue as I commented out that line to see if it was the problem, and it was not.

Posted
randomfire where's it defined in ?

That's not really the issue as I commented out that line to see if it was the problem, and it was not.

Try this one, don't forget to put on your debugscript so you see if it's going wrong. :)

addCommandHandler ( "jevifire",  
    function ( thePlayer ) 
        if ( getTeamFromName ( "Los Santos Fire department" ) ) then 
            for i, p in ipairs ( getPlayersInTeam ( getTeamFromName ( "Los Santos Fire Department" ) ) ) do 
                outputChatBox ( "[RADIO] This is dispatch, ew've got a report from a fire at  via the emergency line, over.", p, 245, 40, 135 ); 
                outputChatBox ( "[RADIO] Please report there now.", p, 2450, 40, 135 ); 
            end 
             
            if ( exports.global:isPlayerAdmin ( thePlayer ) ) then 
                triggerClientEvent ( "burnbabyburn", getRootElement(), jevifire ); 
                triggerClientEvent ( "ringTheBell", root, fdbell ); 
                outputChatBox ("Fiiiire!", thePlayer ); 
            end 
        else 
            outputDebugString ( "Missing the team" ); 
        end 
    end 
); 

Posted

It outputs 'Missing the team'...

I did: crun for k, v in ipairs ( getPlayersInTeam ( getTeamFromName( "Los Santos Fire Department" ) ) ) do outputChatBox ( "Hello", v ) end

And it returns Hello... it's weird.

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