anumaz Posted March 28, 2014 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.
Karuzo Posted March 28, 2014 Posted March 28, 2014 That means he can't get the table from getPlayersInTeam.
Moderators IIYAMA Posted March 28, 2014 Moderators 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 )
anumaz Posted March 28, 2014 Author 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.
iPrestege Posted March 28, 2014 Posted March 28, 2014 Are you sure that part you posted has the problem?
anumaz Posted March 28, 2014 Author Posted March 28, 2014 I showed the whole server-side script. Still giving me the same error as explained in post 1.
Karuzo Posted March 28, 2014 Posted March 28, 2014 So you're sure that you created a team called like that and are in that team ?
anumaz Posted March 28, 2014 Author 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'!
anumaz Posted March 30, 2014 Author 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.
tosfera Posted March 30, 2014 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 );
anumaz Posted March 31, 2014 Author 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.
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