DarkBeautyDZ Posted April 15, 2019 Share Posted April 15, 2019 (edited) Phone Animation Explanation Hi there i need HELP COMPLETING this Script for phone animation the Idea is replacing the camera with a phone and when ever i chose camera/phone 1st animation start for 2 sec bringing the "phone out" then triggering client event changing walking style to 137ID (modefied to phone walking style) and ofcourse the phone main page with it then when changing to other weapon or activating the "phone command again returning walking style to default and playing 2nd animation "phone in " and closing phone main page with it : well almost like this this is me making the script work but not exactly as i want : --------------------------The Script : for now it only activate walking style 137 by command(i want to make him chose weapon 43id by that command) i want to disactivate it too by the same command Client Side function togglephone() setPedWalkingStyle (localPlayer ,137) end addEvent("togglephone",true) addEventHandler("togglephone",root, togglephone) function replaceModel() txd = engineLoadTXD("cellphone.txd", 367 ) engineImportTXD(txd, 367) dff = engineLoadDFF("cellphone.dff", 367 ) engineReplaceModel(dff, 367) end addEventHandler ( "onClientResourceStart", getResourceRootElement(getThisResource()), replaceModel) Server Side function togglephone ( playerSource ) giveWeapon ( source, 43, 200 ) triggerClientEvent(root, "togglephone", root) end addCommandHandler ( "phone", togglephone ) 2. i need to add the two animaions "phone_out " from ped.ifp block that i modified for 1.2 sec then "phone_in" played when phone is disabled how to mix them both in one script function togglephone(thePlayer) if not getElementData(thePlayer, "phoning") then giveWeapon ( thePlayer, 43, 200 ) --- this give weap but also how chosing it will trigger the animation thing setPedAnimation(thePlayer, "ped", "phone_out", -1, false, false, false, false) setElementData(thePlayer, "phoning", true) else -- If you use again this command will play phone in animation need timer in both animations setPedAnimation(thePlayer, "ped", "phone_in", -1, false, false, false, false) removeElementData(thePlayer, "phoning") end end addCommandHandler("phone", togglephone) Edited April 15, 2019 by DarkBeautyDZ Link to comment
Dzsozi (h03) Posted April 15, 2019 Share Posted April 15, 2019 Why don't you just use bone attach and attach a phone object to the player's hand? Link to comment
Ab-47 Posted April 16, 2019 Share Posted April 16, 2019 To answer your question, just use "takeWeapon" at the else. Also, it'd be more convenient using tables for these sorts of things. Element data is not the wisest choice. For example: local using_phone = {} function togglePhone(player) if (not using_phone[player]) then using_phone[player] = true --You could also add giveWeapon here (to continue your script) --Animation here else using_phone[player] = false --And here you could add takeWeapon here. --End animation here end end addCommandHandler("phone", togglePhone) Furthermore, I suggest you rethink your code, it doesn't look that great and you'll encounter issues in the future. For example, calling root to set a walking style.. First of, there's no need for the walking style as when the phone is enabled I assume you have a cursor enabled too, so the player couldn't move either way (unless you're using it as an idling position). Secondly, you're calling the root element of everything, not really efficient. You have "playerSource" defined, so just call it for "playerSource". Personal advice, remove that whole server function and client trigger for walking style. In addition to all this, I would add a triggerClientEvent to toggle the phone from this function and change the commandHandler to a bindKey. Drop a message if you need any help, we'll be of assistance. Good-luck. Link to comment
DarkBeautyDZ Posted April 17, 2019 Author Share Posted April 17, 2019 12 hours ago, Ab-47 said: To answer your question, just use "takeWeapon" at the else. Also, it'd be more convenient using tables for these sorts of things. Element data is not the wisest choice. For example: local using_phone = {} function togglePhone(player) if (not using_phone[player]) then using_phone[player] = true --You could also add giveWeapon here (to continue your script) --Animation here else using_phone[player] = false --And here you could add takeWeapon here. --End animation here end end addCommandHandler("phone", togglePhone) Furthermore, I suggest you rethink your code, it doesn't look that great and you'll encounter issues in the future. For example, calling root to set a walking style.. First of, there's no need for the walking style as when the phone is enabled I assume you have a cursor enabled too, so the player couldn't move either way (unless you're using it as an idling position). Secondly, you're calling the root element of everything, not really efficient. You have "playerSource" defined, so just call it for "playerSource". Personal advice, remove that whole server function and client trigger for walking style. In addition to all this, I would add a triggerClientEvent to toggle the phone from this function and change the commandHandler to a bindKey. Drop a message if you need any help, we'll be of assistance. Good-luck. yes as you say Mr , changing command to bind is what i'm planning to do , but there is something alse about the animation the animation i want it to stop after 1.2 sec means timer after else is another animation 2nd one would be activated for another 1.2 sec (phone out - phone in ) , and about the cursor i got that covered so don't worry Link to comment
DarkBeautyDZ Posted April 17, 2019 Author Share Posted April 17, 2019 On 15/04/2019 at 22:37, Dzsozi (h03) said: Why don't you just use bone attach and attach a phone object to the player's hand? i thought about that but like this it's more realistic and if you thought about it enough you would realize that 43ID weapon is Camera so it's fit for phone you would be able to take pics it's more realistic that way so changing to camera will trigger the whole thing animation the walking style and the phone main page 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