-
Notifications
You must be signed in to change notification settings - Fork 77
Character
rebel1324 edited this page Dec 23, 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
id
property. 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, isServerVar, recipientFilter)
- Sets a networked variable for the character that is also stored in the database. **WARNING: ** This function is LOCAL. Which means the var will be networked only for the owner of character. To make this var networked public, you need to put "player.getAll()" on recipentFilter.
character:setVar(key, value, isServerVar, recipientFilter)
- Similar to setting data, but the value is not saved to the database.
**WARNING: ** This function is LOCAL. Which means the var will be networked only for the owner of character. To make this var networked public, you need to put "player.getAll()" on recipentFilter. - `character:getAttrib(key[, default])
- Returns a set attribute value or the default value if nil.
character:updateAttrib(key, value)
- A server-side only function to add a value to the current attribute value.
character:setAttrib(key, value)
- A server-side function to set an attribute to a certain value.
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.
character:getInv()
- Returns an Inventory object that the character owns.