swag_k_dog Posted July 5, 2017 Share Posted July 5, 2017 local Me = getLocalPlayer() backpack = createObject(371,0,0,-111) hat = createObject(954, 0, 0, -111) exports.bone_attach:attachElementToBone(backpack,Me,3,0,-0.15,-0.0,0,0,0) exports.bone_attach:attachElementToBone(hat,Me,1,0,0.05,-0.56,0,0,0) the objects attached to the player are only visible to me, not my friend that is on the server. help? ( he sees them too but on his character) Link to comment
Infinity# Posted July 5, 2017 Share Posted July 5, 2017 Your file is on client side. Change it to server side. On your meta.xml change it to. <script src="server.lua" type="server"/> server.lua local backpack = {} local hat = {} function attachBackpackAndHatToPlayer(player) if isElement(player) and getElementType(player) == "player" then if isElement(backpack[player]) and isElement(hat[player]) then destroyElement(backpack[player]) backpack[player] = nil destroyElement(hat[player]) hat[player] = nil else local resource = getResourceFromName("bone_attach") -- returns the resource named bone_attach -- local state = getResourceState(resource) -- checks the resource status -- if tostring(state) == "running" then -- checks if the bone_attach resource is running to continue -- backpack[player] = createObject(371, 0, 0, -111) hat[player] = createObject(954, 0, 0, -111) exports.bone_attach:attachElementToBone(backpack[player], player, 3, 0, -0.15, -0.0, 0, 0, 0) exports.bone_attach:attachElementToBone(hat[player], player, 1, 0, 0.05, -0.56, 0, 0, 0) else outputChatBox("Ask an admin to start the 'bone_attach' resource to use this command.", player, 0, 255, 0, false) end end end end addCommandHandler("backpack", attachBackpackAndHatToPlayer) Link to comment
swag_k_dog Posted July 5, 2017 Author Share Posted July 5, 2017 2 minutes ago, SARSRPG said: Your file is on client side. Change it to server side. On your meta.xml change it to. <script src="server.lua" type="server"/> server.lua local backpack = {} local hat = {} function attachBackpackAndHatToPlayer(player) if isElement(player) and getElementType(player) == "player" then if isElement(backpack[player]) and isElement(hat[player]) then destroyElement(backpack[player]) backpack[player] = nil destroyElement(hat[player]) hat[player] = nil else local resource = getResourceFromName("bone_attach") -- returns the resource named bone_attach -- local state = getResourceState(resource) -- checks the resource status -- if tostring(state) == "running" then -- checks if the bone_attach resource is running to continue -- backpack[player] = createObject(371, 0, 0, -111) hat[player] = createObject(954, 0, 0, -111) exports.bone_attach:attachElementToBone(backpack[player], player, 3, 0, -0.15, -0.0, 0, 0, 0) exports.bone_attach:attachElementToBone(hat[player], player, 1, 0, 0.05, -0.56, 0, 0, 0) else outputChatBox("Ask an admin to start the 'bone_attach' resource to use this command.", player, 0, 255, 0, false) end end end end addCommandHandler("backpack", attachBackpackAndHatToPlayer) make it as simple as the script I sent Link to comment
Infinity# Posted July 5, 2017 Share Posted July 5, 2017 That is as simple as it can be. Its just that on client, all the tables aren't quite necessary because its only made for the client that is calling the function. On server, it calls for everyone, so you've to make it specifically for the player who called it. Hence the tables made, backpack[player] and hat[player], etc. Forgot to mention, try the script, I'm sure it'll work. Link to comment
swag_k_dog Posted July 5, 2017 Author Share Posted July 5, 2017 2 minutes ago, SARSRPG said: That is as simple as it can be. Its just that on client, all the tables aren't quite necessary because its only made for the client that is calling the function. On server, it calls for everyone, so you've to make it specifically for the player who called it. Hence the tables made, backpack[player] and hat[player], etc. Forgot to mention, try the script, I'm sure it'll work. works, ty Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now