GalloViking Posted March 27, 2015 Share Posted March 27, 2015 (edited) Hello there! My character is able to craft an item that is supposed to give a flat speed boost and an attack speed mulitiplier boost when used. It works perfectly if this is the server host that plays the character, but it doesn't work anymore if somebody else plays the character. The speed boost will not be given. I've been trying to fix it but I don't understand what's wrong with my item. If you are willing to help me, here is the prefab of the item: local assets ={ Asset("ANIM", "anim/adrenaline_shot.zip"), Asset( "IMAGE", "images/inventoryimages/adrenaline_shot.tex" ), Asset( "ATLAS", "images/inventoryimages/adrenaline_shot.xml" ),}local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("spider_gland_salve") inst.AnimState:SetBuild("adrenaline_shot") inst.AnimState:PlayAnimation("idle") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("inspectable") inst:AddComponent("stackable") inst.components.stackable.maxsize = TUNING.STACK_SIZE_SMALLITEM inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "adrenaline_shot" inst.components.inventoryitem.atlasname = "images/inventoryimages/adrenaline_shot.xml"inst:AddComponent("healer")local healer = inst.components.healerhealer.Heal = function(self, target) local locomotor = target and target.components.locomotor or nil local combat = target and target.components.combat or nil if locomotor then -- adds a flat boost to speed locomotor.bonusspeed = 5 if combat then -- adds a multiplier to attack period combat.min_attack_period = combat.min_attack_period*.5 end inst:DoTaskInTime(30, function() -- removes flat speed boost and restore attackspeed mulitiplier locomotor.bonusspeed = 0 if combat then combat.min_attack_period = combat.min_attack_period/.5 end inst:Remove() end) inst.components.stackable:Get():Remove() return true else return false endend MakeHauntableLaunch(inst) return instendreturn Prefab("common/inventory/adrenaline_shot", fn, assets) Thank you in advance for your help. Edited March 27, 2015 by GalloViking Link to comment Share on other sites More sharing options...
Kzisor Posted March 27, 2015 Share Posted March 27, 2015 @GalloViking, speed has to be set on both the client and the server. If it's not set on both the server will think you're "lagging" and it won't let you move the proper speed. If you only set it on the server then the client won't get that change properly and it will think you're running slower than you should be running. You can always make a netvar:int which will be called when you use the item on the server which automatically sets the speed on the client. Link to comment Share on other sites More sharing options...
GalloViking Posted March 27, 2015 Author Share Posted March 27, 2015 @GalloViking, speed has to be set on both the client and the server. If it's not set on both the server will think you're "lagging" and it won't let you move the proper speed. If you only set it on the server then the client won't get that change properly and it will think you're running slower than you should be running. You can always make a netvar:int which will be called when you use the item on the server which automatically sets the speed on the client. You're right, I thought it was a bug, but I was wrong. When a character uses this item, he begins to move weirdly, like if he was lagging. I will try your way, thank your for the answer. Link to comment Share on other sites More sharing options...
DarkXero Posted March 27, 2015 Share Posted March 27, 2015 You can also use:inst.components.locomotor:SetExternalSpeedMultiplier(inst, "Adrenaline", 2)to boost and:inst.components.locomotor:RemoveExternalSpeedMultiplier(inst, "Adrenaline")to unboost. Link to comment Share on other sites More sharing options...
rezecib Posted March 28, 2015 Share Posted March 28, 2015 To add to what DarkXero said, using SetExternalSpeedMultiplier gets it networked automatically, so you don't have to worry about setting it separately on the client and the server, you can just do it on the server. Link to comment Share on other sites More sharing options...
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