1. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

ChangeJob(How to make a script that changes your job)

Discussion in 'Tutorials' started by MilesDaDark♐♐♐, Jul 25, 2017.

  1. FIRST OFF


    I am very new to the lua scene and I am a beginner so dont expect me to whip out my lua dictionary on moments notice. I am doing this because people need to know how to do this and someone needs to help people save time learning how to do basic things like this:


    ply:changeTeam( TEAM_MAYOR,true)

    is an example of a function changing your job when the function is called from ply:

    ply is a variable defined in the function that is called when the function again is called

    Example:

    function NPC:eek:nIgnite(ply, client, seconds)

    ply:changeTeam( TEAM_MAYOR,true)

    ply:Spawn() ----respawns player

    end

    -------------------------------------

    P.S that goes in sv_init.lua or in the server side of your script

    I have a custom npc frame work that calls functions from cl_init to sv_init
    so you may have something different


    what you need to take away from this is

    changeTeam( TEAM_MAYOR,true)
    is the function/piece of code that goes in your server side of the script you make/edit to make the local player's job change now i guarantee you will run into some kind of issue because your code is different in that case be aware if you are writing a very simple script such as an npc that changes your job you need to define that your local player is the person whos job needs to change. Now like I said I am very stupid AT THE MOMENT when it comes to lua scripting so I suggest if you are also stupid like me you get yourself 4 dollas and head over to script fodder to buy chestnuts npc framework which is a simple little script with a bunch of functions you can experiment with. I personally shoved this function into the sv_init side under this OnIgnite function the guy added in there and removed the actual ignite effect itself so (duh i wont ignite when its called) So i'm still experimenting but nonetheless i continue to want to help this community learn properly and easily.



    I will be adding more onto this post to talk more about what I learn and what you can learn

    --this is mainly for that one gal/guy whos trying to learn to make a script that changes your job

    NEXT I WANNA LEARN MORE ABOUT DERMA

    https://www.gmodstore.com/scripts/view/1574/chessnuts-npc-framework

    the frame work i was talking about ^
     
  2. Pab14567

    Pab14567 Well-Known Member

  3. Sir Klutch

    Sir Klutch Active Member


    What? "NPC" "Ignite"? What function do you have this in? If it is just one you made up yourself, how are you even running it?
     
  4. I am still new to this like I said I used cheesenuts NPC framework which has its own custom functions sorta but I believe that function had something to do with

    http://wiki.garrysmod.com/page/NEXTBOT/OnIgnite
    --- Double Post Merged, Jul 25, 2017 ---


    actually how do i move this post to tutorials?
     
    Last edited: Jul 25, 2017
  5. Sir Klutch

    Sir Klutch Active Member

    I don't believe you can move your own posts.

    Well, it says NPC:SomethingIgnite meaning, it's 'most likely' used for NPCs when they're ignited, or to ignite. I can't really tell you. Never even looked at cheesenuts npc framework.
     

Share This Page