Coder Social home page Coder Social logo

npc-system's Introduction

NPC System

This is a very simple NPC system created for developers to use in whatever case they need it. It's still a WIP and I've really just put about 2 hours into this but the plan is to eventually have a UI system that people can utilize and probably need to add exports so that you can add NPC's through other resources.

But usage as of right now is as simple as making a new file in the npcs/ folder and follow the example.lua file.

I've always wanted to make resources to release publically and this'll be a step towards that. This resource shouldn't effect your FPS at all and uses "RegisterKeyMapping" and Raycasting to handle interactions. This was all created in FxDK.

local exampleNPC = {}
-- Name of the NPC
exampleNPC.name = "Mrs. Someone"
-- Description of the NPC
exampleNPC.desc = "I'm so descriptive"
-- Definitive location (Make sure you get the height right)
exampleNPC.location = vector3(1602.390, 6623.020, 14.835)
-- Heading of the NPC (Where it's facing)
exampleNPC.heading = 90
-- If set to true then it'll play a "Hello" from the NPC when you interact with it
exampleNPC.greetingSound = true
-- Model used for the NPC (https://docs.fivem.net/docs/game-references/ped-models/)
exampleNPC.model = "a_f_m_fatwhite_01"
-- Default animation the NPC is in. (List of animations: https://www.pastebin.com/6mrYTdQv)
exampleNPC.anim = "WORLD_HUMAN_GUARD_PATROL"

-- This function is called when the NPC is loaded and initialized.
exampleNPC.init = function(pEntity)

end

-- This function is called when the +st_npcInteraction bind is called when facing the NPC within 5 units. (Default Button is: E)
-- pEntity is the entity itself
-- pName is the name you set above
-- pDesc is the description you set above.
exampleNPC.onUse = function(pEntity, pName, pDesc)
    TriggerEvent('chat:addMessage', {
        color = {255, 50, 50},
        multiline = true,
        args = {pName, "Stop touching me.."}
    })

    -- Here you can do some interesting triggers.
end

NPCS:Register(exampleNPC)

npc-system's People

Contributors

stebbzor avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.