Jump to content

Rhino Event help


Recommended Posts

Hello I wanted to ask for help with this script, can anyone help me?

* Allow command can only be used within AREA

WARNING: rhinos / rhinos.lua: 8 Bad argument @ "warpPedIntoVehicle" [Expected ped at argument 1, go string "tank"]

the Warp and for the Player that use the command!

local Radar = createRadarArea ( 95, 1700, 325, 450, 0, 0, 0, 170 )
local Area = createColRectangle ( 95, 1700, 325, 450 )

function scriptCreateTank ( thePlayer )
      local luckyBugger = getLocalPlayer() -- get the local player
      local x, y, z = getElementPosition ( luckyBugger ) -- retrive the player's position
      veh = createVehicle ( 432, x, y, z + 10 ) -- create the tank 10 units above them
	  warpPedIntoVehicle ( thePlayer,veh )  
      outputChatBox ( "You got Tank'd!", 255, 0, 0)
end
addCommandHandler ( "tank", scriptCreateTank)

function exitVeh (source)
	if (veh) and isElement(veh) then
		destroyElement (veh)
	else
end
end
addEventHandler ( "onVehicleExit", getRootElement(), exitVeh )

 

Link to comment
2 hours ago, Sha67 said:

Client with server in the same file!?

addCommandHandler doesn't have parameter for player in the client side, you should use localPlayer instead of that.

no he can not do that because the vehicle in the client side is not a true vehicle
the real player can not enter it and this code warpPedIntoVehicle will not work with the real player

 

 

6 hours ago, kevincouto6 said:

Hello I wanted to ask for help with this script, can anyone help me?


u can create it but inside server files only for the ped and the real player

try it .. i did not

 

local Radar = createRadarArea ( 95, 1700, 325, 450, 0, 0, 0, 170 )
local Area = createColRectangle ( 95, 1700, 325, 450 )

function create_vehicle ( player )
	if isElement( getElementData ( player, "tank" ) ) then
		destroyElement ( getElementData ( player, "tank" ) )
	end
	local x, y, z = getElementPosition ( player )
	local tank = createVehicle ( 432, x, y, z + 10 )
	warpPedIntoVehicle ( player, tank )
	setElementData ( player, "tank", tank )
	outputChatBox ( "You got Tank'd!", 255, 0, 0)
end
addCommandHandler ( "tank", create_vehicle )

function on_exit ( player )
	if isElement( getElementData ( player, "tank" ) ) then
		destroyElement ( getElementData ( player, "tank" ) )
	end
end
addEventHandler ( "onVehicleExit", root, on_exit )

 

Link to comment
4 hours ago, killerProject said:

no he can not do that because the vehicle in the client side is not a true vehicle
the real player can not enter it and this code warpPedIntoVehicle will not work with the real player

 

 


u can create it but inside server files only for the ped and the real player

try it .. i did not

 


local Radar = createRadarArea ( 95, 1700, 325, 450, 0, 0, 0, 170 )
local Area = createColRectangle ( 95, 1700, 325, 450 )

function create_vehicle ( player )
	if isElement( getElementData ( player, "tank" ) ) then
		destroyElement ( getElementData ( player, "tank" ) )
	end
	local x, y, z = getElementPosition ( player )
	local tank = createVehicle ( 432, x, y, z + 10 )
	warpPedIntoVehicle ( player, tank )
	setElementData ( player, "tank", tank )
	outputChatBox ( "You got Tank'd!", 255, 0, 0)
end
addCommandHandler ( "tank", create_vehicle )

function on_exit ( player )
	if isElement( getElementData ( player, "tank" ) ) then
		destroyElement ( getElementData ( player, "tank" ) )
	end
end
addEventHandler ( "onVehicleExit", root, on_exit )

 

thanks, but you could allow the command to work just inside createRadarArea

Link to comment
3 minutes ago, kevincouto6 said:

thanks, but you could allow the command to work just inside createRadarArea

-- isElementWithinColShape

local Radar = createRadarArea ( 95, 1700, 325, 450, 0, 0, 0, 170 )
local Area = createColRectangle ( 95, 1700, 325, 450 )

function create_vehicle ( player )
	if isElementWithinColShape ( player, Area ) then
		if isElement( getElementData ( player, "tank" ) ) then
			destroyElement ( getElementData ( player, "tank" ) )
		end
		local x, y, z = getElementPosition ( player )
		local tank = createVehicle ( 432, x, y, z + 10 )
		warpPedIntoVehicle ( player, tank )
		setElementData ( player, "tank", tank )
		outputChatBox ( "You got Tank'd!", 255, 0, 0)
	end
end
addCommandHandler ( "tank", create_vehicle )

function on_exit ( player )
	if isElement( getElementData ( player, "tank" ) ) then
		destroyElement ( getElementData ( player, "tank" ) )
	end
end
addEventHandler ( "onVehicleExit", root, on_exit )

 

Link to comment
19 minutes ago, killerProject said:

-- isElementWithinColShape

local Radar = createRadarArea ( 95, 1700, 325, 450, 0, 0, 0, 170 )
local Area = createColRectangle ( 95, 1700, 325, 450 )

function create_vehicle ( player )
	if isElementWithinColShape ( player, Area ) then
		if isElement( getElementData ( player, "tank" ) ) then
			destroyElement ( getElementData ( player, "tank" ) )
		end
		local x, y, z = getElementPosition ( player )
		local tank = createVehicle ( 432, x, y, z + 10 )
		warpPedIntoVehicle ( player, tank )
		setElementData ( player, "tank", tank )
		outputChatBox ( "You got Tank'd!", 255, 0, 0)
	end
end
addCommandHandler ( "tank", create_vehicle )

function on_exit ( player )
	if isElement( getElementData ( player, "tank" ) ) then
		destroyElement ( getElementData ( player, "tank" ) )
	end
end
addEventHandler ( "onVehicleExit", root, on_exit )

 

Thx, Love You

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