-
Notifications
You must be signed in to change notification settings - Fork 77
Character
Chessnut edited this page Dec 19, 2014
·
12 revisions
The character object is the most important object in the NutScript framework. Every character has a character object. The character object stores inventories and general role-play information that is needed to play correctly.
The character object can be accessed using client:getChar() where client is the desired player. The method is shared so using LocalPlayer():getChar() client-side shall work too.
id- This is the numeric key for the character in the database. This is unique for each character and is shared.
vars- A table for all character variables set up by
nut.char.registerVar
character:getID()- Returns the
idproperty. character:save([callback])- Server-side method that saves all the character information to the database. This does nothing for a bot's character. Once the save is complete, a callback if provided will be called.
character:sync([receiver])- Synchronizes the character's information to the receiver. If the receiver is nil, then everyone will receive the character's information. If a player is provided, only that player will receive the information. If the receiver is any other value, then only public variables are sent.
character:setup(noNetworking)- The character's owner will have their model, character, and faction set. If noNetworking is true, then the character will not be synchronized for everyone.
character:getPlayer()- Returns the player who owns the character.
character:setName(name)- Sets the name of the character to the provided string.
character:setDesc(description)- Sets the character's description to the description provided.
character:setModel(model)- Sets the character owner's model to the model provided.
character:setClass(classID)- Is similar to setting the team, but with a class.
character:setFaction(factionID)- Changes the character owner's team to the faction provided.
character:setAttribs(attributes)- Attributes is the table that controls all attribute values.
character:setMoney(amount)- Sets the character's money to the numeric amount provided.
character:giveMoney(amount)- Adds the numeric amount provided to the character's money.
character:takeMoney(amount)- Takes the absolute value of the numeric amount provided then subtracts that value from the character's current money.
character:setData(key, value)- Sets a networked variable for the character that is also stored in the database.
character:setVar(key, value)- Similar to setting data, but the value is not saved to the database.
character:getName()- Returns the character's name as a string.
character:getDesc()- Returns the character's description as a string.
character:getModel([default])- Returns the character's set model as a string or falls back on the default if provided.
character:getClass([default])- Returns the character's set class as a number or falls back on the default if provided.
character:getFaction()- Returns the character's set faction as a number or falls back to 0 if nil.
character:getAttribs([default])- Returns the character's attributes table or falls back on the default if provided.
character:getMoney()- Returns the character's money as a number.
character:getData(key[, default])- Returns a set data value from the key, but if the value is nil then the default will be returned if provided.
character:getVar(key[, default])- Returns a set variable from the key, but if the value is nil then the default will be returned if provided.