Jump to content

[SOLVED] Bad Argument @ setFriendlyFire


Alxspiker

Recommended Posts

Posted (edited)

I have 3 lua scripts with the same issue so ill give you one.

The problem is at line 2. I'm a newb so I cant see the issue.

  
setTeamFriendlyFire( teampolice, false ) 
  
teampolice = createTeam ( "Police", 0, 0, 255 ) 
  
teamswat = createTeam ( "S.W.A.T.", 0, 0, 255 ) 
  
--politie arest 
function PoliceCuff (attacker, attackerweapon, bodypart, loss) 
  if (attackerweapon == 3) and (loss > 2 ) then 
  setElementPosition (source, 1585.0130615234,-1677.2056884766,5.8971366882324, true) 
  takePlayerMoney (source, 500) 
  givePlayerMoney (attacker, 1000) 
  end 
end 
addEventHandler ("onPlayerDamage", getRootElement(), PoliceCuff) 
  
  
--alleen voor politie autos 
policeVehicles = { [598]=true,[596]=true,[597]=true,[599]=true, [528]=true, [523]=true, [497]=true } 
policeSkins = { [280]=true,[288]=true,[284]=true } 
  
function policeenterVehicle ( player, seat, jacked ) --when a player enters a vehicle 
    if ( policeVehicles[getElementModel ( source )] ) and ( not policeSkins[getElementModel ( player )] ) and ( seat == 0 ) then --if the vehicle is one of 4 police cars, and the skin is not a police skin 
        removePedFromVehicle ( player )--force the player out of the vehicle 
        outputChatBox ( "You are not cop you can't enter this car.", player ) --and tell the player why 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), policeenterVehicle ) 

I also have 1 script with bad argument @ addcommandhandler @ line 16 (Expected function in argument 2 got nil)

And another setFriendlyFire error at line 3.

  
  
setTeamFriendlyFire(teamtaxi, false) 
  
teamtaxi = createTeam ( "Taxi Drivers", 255, 255, 0 ) 
  
  
--Taxicommand 
function taxiCommand ( thePlayer, command ) 
  destroyElement ( taxiOphaalBlip ) 
  taxiOphaalBlip = createBlipAttachedTo ( thePlayer, 48, 1, 255, 0, 0, 0, 0, 99999.0, getRootElement() ) 
  outputChatBox ("Car on the road, stay put!", thePlayer, 255, 190, 0, false ) 
  outputChatBox ("Someone called taxi!", getRootElement(), 255, 190, 0, false ) 
end 
  
addCommandHandler ( "call taxi", llamartaxiCommand ) 
  
function taxiCancelCommand ( thePlayer, command ) 
  outputChatBox ("Remember to turn off.", thePlayer, 255, 190, 0, false ) 
  outputChatBox ("as taxi job done!", getRootElement(), 255, 190, 0, false ) 
  destroyElement ( taxiOphaalBlip ) 
end 
addCommandHandler ( "taxi cancel", taxiCancelCommand ) 
  
--alleen voor taxi autos 
taxiVehicles = { [420]=true } 
taxiSkins = { [7]=true } 
  
function taxienterVehicle ( player, seat, jacked ) 
    if ( taxiVehicles[getElementModel ( source )] ) and ( not taxiSkins[getElementModel ( player )] ) and ( seat == 0 ) then 
        removePedFromVehicle ( player )--force the player out of the vehicle 
        outputChatBox ( "You are not a taxi driver, you can not prowdzic this vehicle.", player ) --and tell the player why 
    end 
end 
addEventHandler ( "onVehicleEnter", getRootElement(), taxienterVehicle ) 

Thanks

Edited by Guest
Posted
you need to set friendly fire, after the team is created. Otherwise, teamtaxi/teampolice are nil and not defined yet.

Problem solved with command handler, the function name and the argument didn't match!

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