Andres99907

My script doesn't work :(

Recommended Posts

Posted (edited)

This is the script:

function check ( player, seat, jacked )
if getElementData(source, "privado") then
if getElementData(source, "dueño") == getAccountName(getPlayerAccount(player)) then
else
cancelEvent()
outputChatBox("Este vehículo no es tuyo.", player)
end
end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), check )

function adueñar(playerSource, player, cmd, who)
local who = getPlayerName(playerSource), playerSource(who)
local co = getPedOccupiedVehicle(who)
setElementData(co, "privado", true)
setElementData(co, "dueño", getPlayerName(who))
outputChatBox("Este auto ahora es de:"..getPlayerName(who), player)
end

addEventHandler ( "onVehicleEnter", getRootElement(), adueñar )

 

the script makes that when a player gets into a car it is saved in his account so no other can use it, the script needs to get the player's name, but I think that in a server-type script it is impossible :(, I have tried everything and nothing has worked...

Help :C 

the script works when you change "addEventHandler" to "addCommandHandler" but, i want everything to be automatic. 

Edited by Andres99907

Share this post


Link to post
function check ( player, seat, jacked )
	if getElementData(source, "privado") then
		if getElementData(source, "owner") ~= getAccountName(getPlayerAccount(player)) then
			cancelEvent()
			outputChatBox("Este vehículo no es tuyo.", player)
		end
	end
end
addEventHandler ( "onVehicleStartEnter", getRootElement(), check )

function aduenar(thePlayer, seat, jacket)
	local playerName = getPlayerName(thePlayer)
	local playerAccount = getAccountName(getPlayerAccount(thePlayer)) or false
	if playerAccount then
		setElementData(source,"privado",true)
		setElementData(source,"owner",playerAccount)
		outputChatBox("Este auto ahora es de: "..playerName, thePlayer)
	end
end
addEventHandler ( "onVehicleEnter", getRootElement(), aduenar )

Not tested. Anyways you should avoid using Ñ. Might it drops you an error while players are not logged (Guest)

No lo he testeado, tal vez te salte un error en el check con un jugador q no este logeado.

  • Like 1

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

  • Recently Browsing   0 members

    No registered users viewing this page.