Gallagher Posted February 8, 2014 Share Posted February 8, 2014 when I type /sc I have this animation setPedAnimation (source, "scratching", "sclng_r", nil, true, false) and if I type /ve got this setPedAnimation (source, "VENDING", "VEND_Drink2_P", nil, false, false, nil, false) . How can I make an animation to block when another is running? example: If I type / sc want the animation to run for 10 seconds and if I type / ve during animation / sc it not to run. Link to comment
tosfera Posted February 8, 2014 Share Posted February 8, 2014 You can use getPedAnimation and see if the player is doing an animation. Link to comment
Ab-47 Posted February 8, 2014 Share Posted February 8, 2014 local anim = false function yourFunc() if (anim == false) then --add your arguments/functions here anim = true setTimer(function ( ) anim = false end, 10000, 1) else outputChatBox("Please wait 10 seconds before you can use this command again.", localPlayer, 255, 0, 0) end end addCommandHandler("ve", yourFunc) That's a way you can prevent someone using the same command under 10 seconds if that's what you need.. Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 You can stop an animation with: setPedAnimation (source,false) But as far as I know, when you set another animation it will overwrite the other one. Is that what you mean? Because your question is very unclear, to everybody. Link to comment
Gallagher Posted February 10, 2014 Author Share Posted February 10, 2014 You can stop an animation with: setPedAnimation (source,false) But as far as I know, when you set another animation it will overwrite the other one. Is that what you mean? Because your question is very unclear, to everybody. I want to make an animation for 20 seconds, and if I try to do another animation during those 20 seconds it will not work. Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 and why not? Show your code. Link to comment
Gallagher Posted February 10, 2014 Author Share Posted February 10, 2014 and why not?Show your code. when I'm repairing my car, makes this animation, and animçao should stay until end car repair. function repairVehicle(veh) if repairTimer[veh] then triggerClientEvent(source, "displayClientInfo", source, "Vehicle", getVehicleName(veh) .. " is currently being repaired!", 255, 22, 0) return end local health = math.floor(getElementHealth(veh)) repairTimer[veh] = setTimer(fixVehicleDayZ, (1000 - health) * 120, 1, veh, source) setElementFrozen(veh, true) setElementData(veh, "repairer", source) setElementData(source, "repairingvehicle", veh) setPedAnimation(source, "SCRATCHING", "sclng_r", nil, true, false) triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "You started to repair " .. getVehicleName(veh), 22, 255, 0) end addEvent("repairVehicle", true) addEventHandler("repairVehicle", getRootElement(), repairVehicle) function fixVehicleDayZ(veh, player) setElementHealth(veh, 1000) fixVehicle(veh) setPedAnimation(player, false) setElementFrozen(veh, false) repairTimer[veh] = nil setElementData(veh, "repairer", nil) setElementData(player, "repairingvehicle", nil) triggerClientEvent(player, "displayClientInfo", player, "Vehicle", "You finished repairing " .. getVehicleName(veh), 22, 255, 0) end But also have these animations, and if I press ", 'or'. 'The animation of the car repair is canceled. then as I lock animations when an already running? function funcBindSit ( player, key, keyState ) if siting then setPedAnimation (player,false) siting = false else if isPedInVehicle (player) then return end setPedAnimation (player,"SHOP","SHP_Rob_HandsUp",nil,true,true,false,false) siting = true end end -- NEW ANIMATION: PRONE function funcBindLie ( player, key, keyState ) if lying then setPedAnimation (player,false) lying = false else if isPedInVehicle (player) then return end setPedAnimation (player,"WUZI","CS_Dead_Guy",nil,true,false,false,true) lying = true function setVisibility() value = 0 end end end function bindTheKeys () bindKey(source,",","down",funcBindHandsup) bindKey(source,".","down",funcBindSit) bindKey(source,"l","down",funcBindLie) end English translator google Link to comment
Moderators IIYAMA Posted February 10, 2014 Moderators Share Posted February 10, 2014 local repairTime = (1000 - health)* 120 if repairTime >= 50 then -- timers can't start with time lower then 50 ms repairTimer[veh] = setTimer(fixVehicleDayZ, repairTime, 1, veh, source) setPedAnimation(source, "SCRATCHING", "sclng_r", repairTime, true, false)-- doing an animation for the required time else fixVehicleDayZ(veh, source) end addEvent("repairVehicle", true) addEventHandler("repairVehicle", getRootElement(), repairVehicle) function fixVehicleDayZ(veh, player) if isElement(veh) and isElement(player) then -- important to prevent errors. (players can leave during the game and vehicles can be destroyed during the game. Which will cause errors when you put delays(timers) between functions. removeElementData(veh,"repairer") -- better then set to nil removeElementData(player,"repairingvehicle") For the second part: The variables: siting and lying are globals which means that all players that execute this script are using them, which will cause problems since they share them. The function: function setVisibility() value = 0 end Has never been called and should not be there in the first place. Link to comment
Gallagher Posted February 11, 2014 Author Share Posted February 11, 2014 local repairTime = (1000 - health)* 120 if repairTime >= 50 then -- timers can't start with time lower then 50 ms repairTimer[veh] = setTimer(fixVehicleDayZ, repairTime, 1, veh, source) setPedAnimation(source, "SCRATCHING", "sclng_r", repairTime, true, false)-- doing an animation for the required time else fixVehicleDayZ(veh, source) end addEvent("repairVehicle", true) addEventHandler("repairVehicle", getRootElement(), repairVehicle) function fixVehicleDayZ(veh, player) if isElement(veh) and isElement(player) then -- important to prevent errors. (players can leave during the game and vehicles can be destroyed during the game. Which will cause errors when you put delays(timers) between functions. removeElementData(veh,"repairer") -- better then set to nil removeElementData(player,"repairingvehicle") For the second part: The variables: siting and lying are globals which means that all players that execute this script are using them, which will cause problems since they share them. The function: function setVisibility() value = 0 end Has never been called and should not be there in the first place. Should I replace? Link to comment
Moderators IIYAMA Posted February 11, 2014 Moderators Share Posted February 11, 2014 Yes some things and learn from those changes. and if it isn't working as you want, you should explain better. 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