Jump to content

Bad argument


CaptainCarroll

Recommended Posts

Posted (edited)

I have 3 errors

[2020-12-20 02:50:47] WARNING: Admin\server.lua:1576: Bad argument @ 'getResourceRootElement' [Expected resource-data at argument 1] [string "?"]
[2020-12-20 02:50:47] WARNING: Admin\server.lua:1576: Bad argument @ 'getElementData' [Expected element at argument 1, got nil]
[2020-12-20 02:50:47] ERROR: Admin\server.lua:1576: attempt to compare nil with number

I've tried to fix it but it's still not working.

How to fix this?

Here's the code:

function civil(thePlayer)
	if tonumber(getElementData(accSys:getPlayerAcc(thePlayer), "pAdmin")) < 2 then
		outputChatBox("No", thePlayer, 255, 0, 89, true)
		return false
	end
	local theVehicle = getPedOccupiedVehicle ( thePlayer )
	if isPedInVehicle (thePlayer) then
		setElementPosition ( theVehicle, 2164.05540625, 1678.5283203125, 10.8203125)
		setElementInterior( theVehicle, 0)
		setElementDimension( theVehicle, 0)
	else
		setElementPosition ( thePlayer, 2164.05540625, 1678.5283203125, 10.8203125)
		setElementInterior( thePlayer, 0)
		setElementDimension( thePlayer, 0)
	end
		outputChatBox("You Have Been Teleported To Civilian", thePlayer, 255, 255, 255, true)
end
addCommandHandler("gotocivi", civil)

 

Edited by CaptainCarroll
  • Moderators
Posted

Thread has been moved to the Scripting section. Scripting Tutorials is for Moderator-approved tutorials aimed to teach coding related skills.

Posted

I can't see the function getResourceRootElement within the code you provided, please check and give the exact line that shows this error code, also you may try the global variable resourceRoot that returns the root of the self resource.

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