Jump to content

attachElements


TheMaysTRo

Recommended Posts

local attachedmarker = createMarker (0,0,0,"cylinder",1.2,0,255,255,180) 
         attachElements ( attachedmarker, car, 0, 3, -1 ) 

function fixandpay(player) 
 setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) 
     outputChatBox (".............",player,255,0,0,false) 
end 
  
function commandon (player) 
 if hitElement and isElement (hitElement) and getElementType (hitElement) == "player" and not isPedInVehicle (hitElement) then 
    if source == attachedmarker then 
     outputChatBox (".................",player,255,0,0,false) 
addCommandHandler ( "fix", fixandpay ) 
  
end 
end 
end 
addEventHandler ("onMarkerHit",getRootElement(),commandon) 
  
function commandoff(player) 
   if source == attachedmarker then 
 removeCommandHandler ( "fix" ) 
  
  
end 
end 
  
  
  
addEventHandler ("onMarkerHit",getRootElement(),commandoff) 
  

Link to comment
No Idea. ?

Delete your second code and replace it with:

  
function fixandpay(player) 
    setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) 
    outputChatBox (".............",player,255,0,0,false) 
end 
  
function commandon (player) 
    if (player and isElement (player) and getElementType (player) == "player") and (not isPedInVehicle (player)) then 
        if (source == attachedmarker) then 
            if (isElementWithinMarker(player)) then 
                outputChatBox (".................",player,255,0,0,false) 
                fixandpay() 
            else 
                return 
            end 
        end 
    end 
end 
addCommandHandler ( "fix", commandon ) 
  

Then tell me your response.

Basically what I've did is, cleared up the code a bit as yours was kinda messy, replaced 'hitElement' with player, as player was defined in your function, removed those useless command/event handlers and added a function to check whether the player is within the marker or not.

What you did, you created a marker attached to a vehicle and added an event handler that when you enter the marker a command handler is initiated and then removed, which makes no sense. You've used an un-defined definition, 'hitElement' and most of your code was useless :3

I've left scripting and MTA for a while due to exams, so I'm sorry if my code didn't help..

Link to comment
No Idea. ?

Delete your second code and replace it with:

  
function fixandpay(player) 
    setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) 
    outputChatBox (".............",player,255,0,0,false) 
end 
  
function commandon (player) 
    if (player and isElement (player) and getElementType (player) == "player") and (not isPedInVehicle (player)) then 
        if (source == attachedmarker) then 
            if (isElementWithinMarker(player)) then 
                outputChatBox (".................",player,255,0,0,false) 
                fixandpay() 
            else 
                return 
            end 
        end 
    end 
end 
addCommandHandler ( "fix", commandon ) 
  

Then tell me your response.

Basically what I've did is, cleared up the code a bit as yours was kinda messy, replaced 'hitElement' with player, as player was defined in your function, removed those useless command/event handlers and added a function to check whether the player is within the marker or not.

What you did, you created a marker attached to a vehicle and added an event handler that when you enter the marker a command handler is initiated and then removed, which makes no sense. You've used an un-defined definition, 'hitElement' and most of your code was useless :3

I've left scripting and MTA for a while due to exams, so I'm sorry if my code didn't help..

thanks for trying to help me

you have fault

if (isElementWithinMarker(player,attachedmarker)) then 

but i got an error says "Expected marker at argument 2 got nill."

Link to comment
No Idea. ?

Delete your second code and replace it with:

  
function fixandpay(player) 
    setPedAnimation( player, "BD_FIRE", "wash_up ",-1,false,false,nil,false) 
    outputChatBox (".............",player,255,0,0,false) 
end 
  
function commandon (player) 
    if (player and isElement (player) and getElementType (player) == "player") and (not isPedInVehicle (player)) then 
        if (source == attachedmarker) then 
            if (isElementWithinMarker(player)) then 
                outputChatBox (".................",player,255,0,0,false) 
                fixandpay() 
            else 
                return 
            end 
        end 
    end 
end 
addCommandHandler ( "fix", commandon ) 
  

Then tell me your response.

Basically what I've did is, cleared up the code a bit as yours was kinda messy, replaced 'hitElement' with player, as player was defined in your function, removed those useless command/event handlers and added a function to check whether the player is within the marker or not.

What you did, you created a marker attached to a vehicle and added an event handler that when you enter the marker a command handler is initiated and then removed, which makes no sense. You've used an un-defined definition, 'hitElement' and most of your code was useless :3

I've left scripting and MTA for a while due to exams, so I'm sorry if my code didn't help..

thanks for trying to help me

you have fault

if (isElementWithinMarker(player,attachedmarker)) then 

but i got an error says "Expected marker at argument 2 got nill."

You did include your marker part did you?

  
local attachedmarker = createMarker (0,0,0,"cylinder",1.2,0,255,255,180) 
         attachElements ( attachedmarker, car, 0, 3, -1 ) 
  

?

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