wesleywillems17 Posted December 23, 2016 Share Posted December 23, 2016 Hi, I have a problem with my car spawn script. Everything worked but when a player isn't in a team it says "Expected team at argument 1, got boolean". I know that it has something to do because i'm not in a team. What do i need to add to remove this bug/report? local vehicleTable = {} function SpawnRandomCopCar () team = getPlayerTeam(source) if (getTeamName(team) == "Police officer") then local CopCar = vehicleTable[source] if CopCar then if isElement( CopCar ) then destroyElement( CopCar ) end vehicleTable[source]= nil end x, y, z = SpawnCopCar () local CopCar = createVehicle ( 596, x, y, z, 0, 0, 180 ) warpPedIntoVehicle ( source, CopCar ) vehicleTable[source]= CopCar else outputChatBox ( "You must be a police officer to get a police car!", source, 255, 0, 0, true ) end end addEvent( "GiveCopCarFree", true ) addEventHandler( "GiveCopCarFree", root, SpawnRandomCopCar ) Link to comment
Mega9 Posted December 23, 2016 Share Posted December 23, 2016 When play isn't in a team getPlayerTeam returns false, so a simple if team check will solve the issue. Link to comment
..:D&G:.. Posted December 23, 2016 Share Posted December 23, 2016 local vehicleTable = {} function SpawnRandomCopCar () local team = getPlayerTeam(source) if (team) then if (getTeamName(team) == "Police officer") then local CopCar = vehicleTable[source] if CopCar then if isElement( CopCar ) then destroyElement( CopCar ) end vehicleTable[source]= nil end x, y, z = SpawnCopCar () local CopCar = createVehicle ( 596, x, y, z, 0, 0, 180 ) warpPedIntoVehicle ( source, CopCar ) vehicleTable[source]= CopCar else outputChatBox ( "You must be a police officer to get a police car!", source, 255, 0, 0, true ) end else outputChatBox ( "You must be a police officer to get a police car!", source, 255, 0, 0, true ) end end addEvent( "GiveCopCarFree", true ) addEventHandler( "GiveCopCarFree", root, SpawnRandomCopCar ) Link to comment
wesleywillems17 Posted December 23, 2016 Author Share Posted December 23, 2016 Ok thx! 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