Sign in to follow this  
orcun99

export.admin and vehicle type

Recommended Posts

erorr code  : call: failed to call 'admin:outputAdminLog' [string "?"]
x = lua code : exports.admin:outputAdminLog(player, "xvehicles: Removed ownerid of vehicle"..getVehicleData( theVehicle, 'id' ))


this is firt erorr do not have export function admin script maybe ?  ( I found that code "x" in internet not my own code)

 

------ problem 2 for vehicle type--------

function getUserID(username)
	local ownerq = exports.RPGsql:query("saesrpg", "SELECT id FROM user_data WHERE username=?", username)
	if ownerq and #ownerq > 0 then return ownerq[1].id end
	return 0
end

function setVehicleOwner(player, _, username, clear)
	if not exports.sql:isPlayerInGroup(player, "subadmin") then
		return
	end
	
	if not username then return outputChatBox('You need to specify an username!', player, 255,0,0) end
	
	local theVehicle = getPedOccupiedVehicle(player)
	
	if not theVehicle then return outputChatBox('You need to be in a vehicle!', player, 255,0,0) end
	
	if clear then
		if not exports.sql:isPlayerInGroup(player, "saeshq") then return outputChatBox('You need to be SAES HQ to do this', player, 255,0,0) end
		exports.sql:exec("saesrpgslow", 'UPDATE vehicle_data SET ownerid=0 WHERE uid=?', getVehicleData( theVehicle, 'id' ))
		exports.admin:outputAdminLog(player, "vehicles: Removed ownerid of vehicle"..getVehicleData( theVehicle, 'id' ))
		return outputChatBox('Successfully removed ownerid of this vehicle',player,0,255,0)
	end
	
	if getVehicleData( theVehicle, 'type' ) ~= 'user' then return outputChatBox('You can not set the owner on a non "user" locked vehicle!', player, 255,0,0) end
	
	local groups = getVehicleData( theVehicle, 'groups', true )
	if not groups[ username ] then return outputChatBox('The user "'..username..'" needs to be locked on the vehicle!', player, 255,0,0) end
	
	local id = getVehicleData( theVehicle, 'id' )
	if not id then return outputChatBox('Weird, vehicle does not have an ID? Please contact Team Awesome', player, 255,0,0) end
	
	local userID = getUserID(username)
	
	if userID == 0 then return outputChatBox('Could not fetch the user id of: '..username, player, 255,0,0) end
	
	exports.sql:exec("database", 'UPDATE vehicle_data SET ownerid=? WHERE uid=?', userID, id)
	
	reloadVehicleFromDB(id)
	
	exports.admin:outputAdminLog(player, "vehicles: Set ownerid of vehicle"..id.." to '"..username.."' ("..userID..")")
	
	outputChatBox('All done, owner set to: '..username, player, 0,255,0)
end
addCommandHandler("setownerid", setVehicleOwner)


    

coomand in game  in vehicle:   /setownerid user ahmet33                         (ahmet33 is player username)

erorr message : successfully removed ownerid of this vehicle                    but already no owner

Share this post


Link to post

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.