anumaz Posted March 28, 2014 Share Posted March 28, 2014 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. Link to comment
Karuzo Posted March 28, 2014 Share Posted March 28, 2014 That means he can't get the table from getPlayersInTeam. Link to comment
Moderators IIYAMA Posted March 28, 2014 Moderators Share Posted March 28, 2014 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 ) Link to comment
anumaz Posted March 28, 2014 Author Share Posted March 28, 2014 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. Link to comment
iPrestege Posted March 28, 2014 Share Posted March 28, 2014 Are you sure that part you posted has the problem? Link to comment
anumaz Posted March 28, 2014 Author Share Posted March 28, 2014 I showed the whole server-side script. Still giving me the same error as explained in post 1. Link to comment
Karuzo Posted March 28, 2014 Share Posted March 28, 2014 So you're sure that you created a team called like that and are in that team ? Link to comment
anumaz Posted March 28, 2014 Author Share Posted March 28, 2014 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'! Link to comment
iPrestege Posted March 29, 2014 Share Posted March 29, 2014 randomfire where's it defined in ? Link to comment
anumaz Posted March 30, 2014 Author Share Posted March 30, 2014 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. Link to comment
tosfera Posted March 30, 2014 Share Posted March 30, 2014 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 ); Link to comment
anumaz Posted March 31, 2014 Author Share Posted March 31, 2014 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. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now