Jump to content

I have an error and idk how to fix it


nagugg

Recommended Posts

 

THE ERRORS ARE:

 

WARNING!:bad argument "isPedInVehicle" [Expected ped at argument 1, got string "repair"]

WARNING!:bad argument "outputChatBox" [Expected bool at argument 5, got number "0"]

 

and my script is this: (the chatbox are in spanish)

 

function mecanico ( thePlayer )
car= getPedOccupiedVehicle ( thePlayer )
      if isPedInVehicle( thePlayer ) then
      outputChatBox("reparaste el auto correctamente", thePlayer, 255, 255, 0)
fixVehicle( car )
      
      else
      outputChatBox("No estas en el vehiculo para reparar el coche", thePlayer, 255, 0, 0)

      
     end
end
addEventHandler("onPlayerVehicleEnter", getRootElement(), mecanico)
addCommandHandler("reparar", mecanico)

 

any solution please??

Link to comment
function mecanico ( thePlayer )
	local car= getPedOccupiedVehicle ( thePlayer )
	if isPedInVehicle( thePlayer ) then
		outputChatBox("reparaste el auto correctamente", thePlayer, 255, 255, 0)
		fixVehicle( car )
	else
		outputChatBox("No estas en el vehiculo para reparar el coche", thePlayer, 255, 0, 0)
	end
end
addEventHandler("onPlayerVehicleEnter", getRootElement(), mecanico)
addCommandHandler("reparar", mecanico)

You are getting the errors because you have the code on the client side, this is a server sided script.

Link to comment

There's something weird

car= getPedOccupiedVehicle ( thePlayer )
if isPedInVehicle( thePlayer ) then --this generates warning but getPedOccupiedVehicle don't???

are you sure this is the correct line?

Also:

Expected bool at argument 5

Copying pasting from wiki the 5th arg serverside is 

int b=176

so an integer.

The correct syntax (for your clientside script) is:

bool outputChatBox ( string text [, int r=231, int g=217, int b=176, bool colorCoded=false ] )
Link to comment

Why using two checks if only one can fulfill the need whether client or server

use this 

for Client-Sided 

function mecanico ( thePlayer )
	local car= getPedOccupiedVehicle ( thePlayer )
	if car then
		outputChatBox("reparaste el auto correctamente", 255, 255, 0)
		fixVehicle( car )
	else
		outputChatBox("No estas en el vehiculo para reparar el coche",255, 0, 0)
	end
end
addEventHandler("onPlayerVehicleEnter", getRootElement(), mecanico)
addCommandHandler("reparar", mecanico)

for server-sided

function mecanico ( thePlayer )
	local car= getPedOccupiedVehicle ( thePlayer )
	if car then
		outputChatBox("reparaste el auto correctamente",thePlayer, 255, 255, 0)
		fixVehicle( car )
	else
		outputChatBox("No estas en el vehiculo para reparar el coche",thePlayer,255, 0, 0)
	end
end
addEventHandler("onPlayerVehicleEnter", getRootElement(), mecanico)
addCommandHandler("reparar", mecanico)

 

Edited by Ayush Rathore
some spell mistakes
Link to comment

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