Jump to content

2 questions


MAB

Recommended Posts

According to this LUA....can i prevent other players from stealing the boat (line 19) by using this function?

function stop (thePlayer)

if source == boat and not isElementVisibleTo(blip,thePlayer) then

cancelEvent()

end

end

addEventHandler ("OnVehicleEnter,root,stop)

this is just the idea ^^^

question two....how to do a function when the fisher gets on the boat?

local fishmark = createMarker ( -2185.32202, 2416.38135, 4.5, "cylinder", 1.5, 255, 255, 0, 255 ) 
createBlipAttachedTo ( fishmark, 9 ) 
  
function outPut ( hitElement, matchingDimension ) 
if not isPedInVehicle ( hitElement ) and not (getElementData ( hitElement, "fisher" ) == true) then 
outputChatBox ( "Press E to start the job", hitElement, 255, 255, 0, true ) 
end 
if not isPedInVehicle ( hitElement ) and (getElementData ( hitElement, "fisher" ) == true) then 
outputChatBox ( "You have already started the job before", hitElement, 255, 255, 0, true ) 
end 
end 
addEventHandler( "onMarkerHit", fishmark, outPut ) 
  
function start ( hitElement, key, keyState ) 
local name = getPlayerName (hitElement) 
if not isPedInVehicle ( hitElement ) and not (getElementData ( hitElement, "fisher" ) == true) then 
if hitElement then 
setElementData ( hitElement, "fisher", true ) 
local boat = createVehicle ( 473, -2218.21387, 2419.93970, 1 ) 
local blip = createBlipAttachedTo ( boat, 56 ) 
setElementVisibleTo ( blip, root, false ) 
setElementData ( boat, "myboat", name ) 
setElementVisibleTo ( blip, hitElement, true ) 
outputChatBox ( "Your boat is in the water, find it and start your job", hitElement, 255, 255, 0, true ) 
unbindKey ( hitElement, "E", "down", start ) 
end 
end 
end 
  
function bind (hitElement, matchingDimension) 
bindKey ( hitElement, "E", "down", start ) 
end 
addEventHandler( "onMarkerHit", fishmark, bind ) 
  
function unbind ( hitElement, matchingDimension ) 
unbindKey ( hitElement, "E", "down", start ) 
end 
addEventHandler( "onMarkerLeave", fishmark, unbind ) 

Link to comment
According to this LUA....can i prevent other players from stealing the boat (line 19) by using this function?

function stop (thePlayer)

if source == boat and not isElementVisibleTo(blip,thePlayer) then

cancelEvent()

end

end

addEventHandler ("OnVehicleEnter,root,stop)

this is just the idea ^^^

question two....how to do a function when the fisher gets on the boat?

local fishmark = createMarker ( -2185.32202, 2416.38135, 4.5, "cylinder", 1.5, 255, 255, 0, 255 ) 
createBlipAttachedTo ( fishmark, 9 ) 
  
function outPut ( hitElement, matchingDimension ) 
if not isPedInVehicle ( hitElement ) and not (getElementData ( hitElement, "fisher" ) == true) then 
outputChatBox ( "Press E to start the job", hitElement, 255, 255, 0, true ) 
end 
if not isPedInVehicle ( hitElement ) and (getElementData ( hitElement, "fisher" ) == true) then 
outputChatBox ( "You have already started the job before", hitElement, 255, 255, 0, true ) 
end 
end 
addEventHandler( "onMarkerHit", fishmark, outPut ) 
  
function start ( hitElement, key, keyState ) 
local name = getPlayerName (hitElement) 
if not isPedInVehicle ( hitElement ) and not (getElementData ( hitElement, "fisher" ) == true) then 
if hitElement then 
setElementData ( hitElement, "fisher", true ) 
local boat = createVehicle ( 473, -2218.21387, 2419.93970, 1 ) 
local blip = createBlipAttachedTo ( boat, 56 ) 
setElementVisibleTo ( blip, root, false ) 
setElementData ( boat, "myboat", name ) 
setElementVisibleTo ( blip, hitElement, true ) 
outputChatBox ( "Your boat is in the water, find it and start your job", hitElement, 255, 255, 0, true ) 
unbindKey ( hitElement, "E", "down", start ) 
end 
end 
end 
  
function bind (hitElement, matchingDimension) 
bindKey ( hitElement, "E", "down", start ) 
end 
addEventHandler( "onMarkerHit", fishmark, bind ) 
  
function unbind ( hitElement, matchingDimension ) 
unbindKey ( hitElement, "E", "down", start ) 
end 
addEventHandler( "onMarkerLeave", fishmark, unbind ) 

Use this code in your lua:

function enterVehicle ( player, seat, jacked ) 
local owner = getPlayerName ( player ) 
    if not getElementData ( source, "myboat") == owner then 
        cancelEvent()        
    end 
end 
addEventHandler ( "onVehicleStartEnter", getRootElement(), enterVehicle ) 

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