Jump to content

Companion script help.


jayhud91

Recommended Posts

So it goes without saying im new to scripting any pointers or a point in the right direction would be greatly appreciated

.Ok I've been at this for roughly 4-5 days and I'm still coming up with nada I know there are some talented people in here that will get a laugh out of this but uhh......trying to spawn Kaylee (ig_kaylee hash: 0xA7810923) as a bodygaurd that follows you around. and so far i've spawned her once  in  my garage (thought i had succeeded) , crashed more times then i care to mention. I haven't quite figured out the menu toggle quite yet or how to add different models to select (will try to workout later)

so  far ive come up with this.

 

local Companion = {}
Companion = menu.add_parent("Your Companion")


function Companion.tick()
    local playerPed = PLAYER.PLAYER_PED_ID()
    local player = PLAYER.GET_PLAYER_PED(playerPed)
    local playerExists = ENTITY.DOES_ENTITY_EXIST(playerPed)
    if(PLAYER.IS_PLAYER_ONLINE() and playerExists) then
        if(get_key_pressed(74)) then
            local veh = PED.GET_VEHICLE_PED_IS_IN(playerPed,true)
            local CompanionskinID = GAMEPLAY.GET_HASH_KEY("ig_kaylee")
            local coords = ENTITY.GET_OFFSET_FROM_ENTITY_IN_WORLD_COORDS(playerPed, 0.0, 5.0, 0.0);
            STREAMING.REQUEST_MODEL(CompanionskinID)
            local Company = PED.CREATE_PED( 26,CompanionskinID,coords.x, coords.y, coords.z,0,false,true)
            local group = PLAYER.GET_PLAYER_GROUP(PLAYER.PLAYER_ID());
            PED.SET_PED_AS_GROUP_MEMBER(Company, group);
            AI.TASK_COMBAT_HATED_TARGETS_AROUND_PED(Company, 5000, 0);
            PED.SET_PED_KEEP_TASK(Company, true);
            WEAPON.GIVE_DELAYED_WEAPON_TO_PED(Company, GAMEPLAY.GET_HASH_KEY("weapon_specialcarbine"), 5, true);
            ENTITY.SET_ENTITY_INVINCIBLE(Company, true);
            
        end
                
                
                
                
                
                
    end
end

return Companion

 

Not sure what im missing or if this is even close

Used the d2stcode snippets

DIS2RBED'S LUA Documentation & Minimal script.

 

Link to comment
Share on other sites

35 минут назад, jayhud91 сказал:

local player = PLAYER.GET_PLAYER_PED(playerPed)

Why do you need this line? it is not used, but it can break the script and for the fact that you called it "player"

And you definitely looked at D2 Api? "PLAYER.IS_PLAYER_ONLINE" is not in the documentation

Link to comment
Share on other sites

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
×
×
  • Create New...