Jump to content

Help getElementPosition (Player)


Brad96

Recommended Posts

Posted

Help, I'm new to making my own script, and I know that I explain how optener Player position with getRoolElement .. and tried several things but nothing .. I might say? thanks

function CrearCoche 
local x,y,z = getElementPosition( LocalPlayer ) 
Auto = createVehicle ( 411, x, y, z, 0, 0, 90, "BradFord" ) 
setVehicleColor (Auto, 255,0,0) 
end 
addEventHandler ("onResourceStart", getRootElement(), CrearCoche) 
  

Posted

The onResourceStart doens´t know a localPlayer. The localPlayer is a predefined variable in the client side scripting. You can give everyone a vehicle with the onResourceStart. Since you only want to receive a car, try this command;

addCommandHandler("giveMeVehicle", 
    function ( thePlayer, command ) 
        local x, y, z = getElementPosition( thePlayer ); 
        local v = createVehicle(411, x, y, z, 0, 0, 90, "BradFord"); 
        if ( v ) then 
            setVehicleColor(v, 255, 0, 0); 
            warpPedIntoVehicle(thePlayer, v); 
        end 
    end 
); 

Posted

lmao it doesn't? You're telling me that it doesn't work?xD Where did you add it, client or server side? Cause mine is server sided.

edit; just tested it and it works like a charm!

Posted

yes but I'm noob in this, donot exactly what vaen addCommandHandler

addCommandHandler("V",thePlayer () getRootElement ) 

This ? our what

Posted
work! I appreciate that, now can you tell me as to which line you got the player's position and that you gave?
       local x, y, z = getElementPosition( thePlayer ); 
      local v = createVehicle(411, x, y, z, 0, 0, 90, "BradFord"); 

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