King12 Posted September 18, 2014 Share Posted September 18, 2014 (edited) Hello there, I wanted to merge 2 scripts together and It worked fine but there is 2 problems. the first one is the play button ain't starting the anim which is selected from the grid list and secondly, in the first lines of my gridlist there is a flase things, dunno how to fix them because I'm not that good on xml functions. :\ My problem : My codes : -- Client side local AnimPlayButton = guiCreateButton(0.33, 0.92, 0.34, 0.08,"Play",true,AnimAllTab) function zas() addEventHandler("onClientGUIClick", AnimPlayButton, PLAY, false ) end function PLAY ( button ) if ( button == "left" ) then if not ( guiGetText( guiGetSelectedTab( AnimAllTab ) ) == "All" ) then valittu = guiGridListGetSelectedItem( AnimBestGrid ) if ( valittu ) then local animi = guiGridListGetItemText(AnimBestGrid, valittu, AnimBestNameCol ) local block = guiGridListGetItemText(AnimBestGrid, valittu, AnimBestBlockCol ) local anim = guiGridListGetItemText(AnimBestGrid, valittu, AnimBestAnimCol ) triggerServerEvent("animaatio", getLocalPlayer(), getLocalPlayer(), tostring( block ),tostring( anim )) end else valittu = guiGridListGetSelectedItem( AnimBestGrid ) if ( valittu ) then local animi = guiGridListGetItemText(AnimBestGrid, valittu, AnimBestNameCol ) local block = guiGridListGetItemText(AnimBestGrid, valittu, AnimBestBlockCol ) local anim = guiGridListGetItemText(AnimBestGrid, valittu, AnimBestAnimCol ) triggerServerEvent("animaatio", getLocalPlayer(), getLocalPlayer(), tostring( block ),tostring( anim )) end end end end -- Server Side function anim ( thePlayer, block, anim ) setPedAnimation ( thePlayer, block, anim, 0, true, true, true ) end addEvent("animaatio", true ) addEventHandler("animaatio",getRootElement(), anim) .. Edit #1: The xml problem is fixed. ( Check this reply https://forum.multitheftauto.com/viewtopic.php?f=91&t=80851&p=738486#p738657 ) Edited September 19, 2014 by Guest Link to comment
Et-win Posted September 18, 2014 Share Posted September 18, 2014 Maybe tell us which line sets stuff which in this case is 'false'. Link to comment
King12 Posted September 18, 2014 Author Share Posted September 18, 2014 Maybe tell us which line sets stuff which in this case is 'false'. I actually have no idea about how this is happening, it most a bugged anims in the anim.xml file or smth. Link to comment
Et-win Posted September 18, 2014 Share Posted September 18, 2014 It's because you are using this: local block = xmlNodeGetAttribute( group, "name" ) To get: <anim nimi="Wank" block="PAULNMAC" anim="Wank_loop" /> <anim nimi="Dance " block="DANCING" anim="dance_loop" /> <anim nimi="Piss " block="PAULNMAC" anim="Piss_loop" /> <anim nimi="Sleep " block="CRACK" anim="crckidle2" /> <anim nimi="Sit" block="INT_OFFICE" anim="OFF_Sit_Idle_Loop" /> <anim nimi="Dance" block="DANCING" anim="dnce_M_d" /> <anim nimi="Sunbathing" block="BEACH" anim="SitnWait_loop_W" /> <anim nimi="Handstand" block="DAM_JUMP" anim="DAM_Dive_Loop" /> <anim nimi="Scratchballs" block="misc" anim="Scratchballs_01" /> <anim nimi="Hitchhiking Left" block="misc" anim="Hiker_Pose_L" /> <anim nimi="Hitchhiking Right" block="misc" anim="Hiker_Pose" /> <anim nimi="Bitchslap" block="misc" anim="bitchslap" /> <anim nimi="Strip" block="STRIP" anim="STR_A2B" /> <anim nimi="Strip2" block="STRIP" anim="STR_B2C" /> <anim nimi="Strip3" block="STRIP" anim="STR_C2" /> <anim nimi="HandsUp" block="ROB_BANK" anim="SHP_HandsUp_Scr" /> <anim nimi="Cower" block="ped" anim="DUCK_cower" /> <anim nimi="Walk Drunk" block="ped" anim="WALK_drunk" /> <anim nimi="Gunstand" block="ped" anim="gang_gunstand" /> <anim nimi="Spin" block="ped" anim="turn_180" /> <anim nimi="Unknown" block="ROB_BANK" anim="CAT_Safe_Open_O" /> <anim nimi="Surprised" block="ped" anim="facsurp" /> <anim nimi="Gum eat" block="ped" anim="facgum" /> <anim nimi="Fuku" block="RIOT" anim="RIOT_FUKU" /> <anim nimi="Swim" block="SWIM" anim="Swim_Breast" /> <anim nimi="ASD" block="SKATE" anim="skate_sprint" /> <anim nimi="ASD2" block="SKATE" anim="skate_run" /> There is no 'name' attribute, so it wasn't found. The other groups do have it, so they will be found. Link to comment
King12 Posted September 19, 2014 Author Share Posted September 19, 2014 It's because you are using this: local block = xmlNodeGetAttribute( group, "name" ) To get: <anim nimi="Wank" block="PAULNMAC" anim="Wank_loop" /> <anim nimi="Dance " block="DANCING" anim="dance_loop" /> <anim nimi="Piss " block="PAULNMAC" anim="Piss_loop" /> <anim nimi="Sleep " block="CRACK" anim="crckidle2" /> <anim nimi="Sit" block="INT_OFFICE" anim="OFF_Sit_Idle_Loop" /> <anim nimi="Dance" block="DANCING" anim="dnce_M_d" /> <anim nimi="Sunbathing" block="BEACH" anim="SitnWait_loop_W" /> <anim nimi="Handstand" block="DAM_JUMP" anim="DAM_Dive_Loop" /> <anim nimi="Scratchballs" block="misc" anim="Scratchballs_01" /> <anim nimi="Hitchhiking Left" block="misc" anim="Hiker_Pose_L" /> <anim nimi="Hitchhiking Right" block="misc" anim="Hiker_Pose" /> <anim nimi="Bitchslap" block="misc" anim="bitchslap" /> <anim nimi="Strip" block="STRIP" anim="STR_A2B" /> <anim nimi="Strip2" block="STRIP" anim="STR_B2C" /> <anim nimi="Strip3" block="STRIP" anim="STR_C2" /> <anim nimi="HandsUp" block="ROB_BANK" anim="SHP_HandsUp_Scr" /> <anim nimi="Cower" block="ped" anim="DUCK_cower" /> <anim nimi="Walk Drunk" block="ped" anim="WALK_drunk" /> <anim nimi="Gunstand" block="ped" anim="gang_gunstand" /> <anim nimi="Spin" block="ped" anim="turn_180" /> <anim nimi="Unknown" block="ROB_BANK" anim="CAT_Safe_Open_O" /> <anim nimi="Surprised" block="ped" anim="facsurp" /> <anim nimi="Gum eat" block="ped" anim="facgum" /> <anim nimi="Fuku" block="RIOT" anim="RIOT_FUKU" /> <anim nimi="Swim" block="SWIM" anim="Swim_Breast" /> <anim nimi="ASD" block="SKATE" anim="skate_sprint" /> <anim nimi="ASD2" block="SKATE" anim="skate_run" /> There is no 'name' attribute, so it wasn't found. The other groups do have it, so they will be found. Thanks alot but for some odd reasons, the category names ain't bold anymore like in the previous image f.e : BAR. Also, why whenever I click on play button it's not starting the anim? Link to comment
Et-win Posted September 19, 2014 Share Posted September 19, 2014 Go in-game, press t and typ: /debugscript 3 Or press F8 and then typ: debugscript 3 Restart the resource and it will show all errors and so on. But with merging two scripts together and there are alot of errors, I think I don't want to help, but will see. Link to comment
King12 Posted September 19, 2014 Author Share Posted September 19, 2014 I wish if there is any debugs but actually nothing is showing.. Link to comment
Mr_Moose Posted September 23, 2014 Share Posted September 23, 2014 If the animation doesn't work there may be a couple of reasons for that, first you may check if the play button actually passes the correct data to the server script, let it show if it get's the animation and the block by doing a temporary output, you should also avoid passing a player element to the server, in any other way than using the "client" variable. -- Server Side function anim ( thePlayer, block, anim ) outputChatBox("Block = "..block..", Anim = "..anim, client) setPedAnimation ( client, block, anim, 0, true, true, true ) -- Edit: 0? infinity is -1 so 0 will probably never start the animation. end addEvent("animaatio", true ) addEventHandler("animaatio",getRootElement(), anim) I assume you are trying to merge these resources right? https://github.com/albonius/gtw-rpg/tree/master/GTWanimations https://github.com/albonius/gtw-rpg/tree/master/GTWphone In the older versions of those there used to be similar issues like animations that failed to start, even if everything in the code was written correct, however the current version of the animation trigger looks like this: setPedAnimation(client,animationBlock,animationID,-1, true, false) And it works pretty well without any bad syncing or "lagging" animations, in your case that line should look like this: setPedAnimation(client, block, anim,-1, true, false) I'm not 100% sure about that 0 in your animation time argument, as far as I know you should use -1 for infinity while 0 probably means 0, which results in a animation that never starts. You may try to change that as well. Link to comment
Anubhav Posted September 23, 2014 Share Posted September 23, 2014 I tried debugging. It outputs fine. The GUI has too many false. The problem is it doesn't load the XML file and set the text properly. Link to comment
King12 Posted September 23, 2014 Author Share Posted September 23, 2014 This is the new error, I've replaced your function and still nothing, but now when I put mine back it outputs this.. ERROR: ac_phone\phone-s.lua:10: attempt to concatenate local 'anim' ( a nil value ) My code : -- Client local AnimAllTab = guiCreateTab("All",tabPanel) local AnimAllGrid = guiCreateGridList( 0, 0, 1, 0.9,true,AnimAllTab) guiGridListSetSelectionMode(AnimAllGrid,2) local AnimBestNameCol = guiGridListAddColumn(AnimAllGrid,"Name",0.2) local AnimBestBlockCol = guiGridListAddColumn(AnimAllGrid,"Block",0.2) local AnimBestAnimCol = guiGridListAddColumn(AnimAllGrid,"Anim",0.2) local AnimPlayButton = guiCreateButton(0.33, 0.92, 0.34, 0.08,"Play",true,AnimAllTab) local row1 = guiGridListAddRow(AnimAllGrid) addEventHandler("onClientGUIClick",root,function(button) if(button=="left")then if(source==AnimPlayButton)then PLAY() end end end,true) function PLAY ( button ) local valittu = guiGridListGetSelectedItem( AnimAllGrid ) if ( valittu ) then local animi = guiGridListGetItemText(AnimAllGrid, valittu, AnimBestNameCol ) local block = guiGridListGetItemText(AnimAllGrid, valittu, AnimBestBlockCol ) local anim = guiGridListGetItemText(AnimAllGrid, valittu, AnimBestAnimCol ) triggerServerEvent("animaatio", getLocalPlayer(), tostring( block ),tostring( anim )) end end -- end -- end [lua] -- Server function anim1 ( source, block, anim ) outputChatBox("Block = "..block..", Anim = "..anim, client) setPedAnimation ( client, block, anim, true, true ) end addEvent("animaatio", true ) addEventHandler("animaatio",getRootElement(), anim1) Link to comment
Mr_Moose Posted September 23, 2014 Share Posted September 23, 2014 In that case, something goes wrong when you send the info from the client to your server, resulting in a nil animation wich is equal to stopping it. You must also check the argument line in your server side function, replace this: function anim1 ( source, block, anim ) with this: function anim1( block, anim ) , otherwise "source" will contain the value of "block", "block" the value of "anim" and "anim" will be nil and useless. Link to comment
King12 Posted September 23, 2014 Author Share Posted September 23, 2014 In that case, something goes wrong when you send the info from the client to your server, resulting in a nil animation wich is equal to stopping it. You must also check the argument line in your server side function, replace this: function anim1 ( source, block, anim ) with this: function anim1( block, anim ) , otherwise "source" will contain the value of "block", "block" the value of "anim" and "anim" will be nil and useless. It's only triggering the block now, the anim isn't even outputting nil.. my chat: Link to comment
Mr_Moose Posted September 23, 2014 Share Posted September 23, 2014 nil is not a string so if the value was nil then outputChatBox would have failed too, obviously something is passed but it's empty. Keep that chatbox part until you are sure that the correct parameters are received on the server, you may also need to check the documentation for triggerServerEvent. In the example there it's used like this: triggerServerEvent ( "onGreeting", resourceRoot, "Hello World!" ) Which would make your client side part look like this: outputChatBox(tostring( block ).." "..tostring( anim )) -- Add this line to see how your arguments looks like before they are passed to the server. triggerServerEvent("animaatio", resourceRoot, tostring( block ), tostring( anim )) That should output block and anim before and after it reaches the server, in that way it's easier to find out where the problem is. Link to comment
King12 Posted September 23, 2014 Author Share Posted September 23, 2014 (edited) nil is not a string so if the value was nil then outputChatBox would have failed too, obviously something is passed but it's empty. Keep that chatbox part until you are sure that the correct parameters are received on the server, you may also need to check the documentation for triggerServerEvent. In the example there it's used like this: triggerServerEvent ( "onGreeting", resourceRoot, "Hello World!" ) Which would make your client side part look like this: outputChatBox(tostring( block ).." "..tostring( anim )) -- Add this line to see how your arguments looks like before they are passed to the server. triggerServerEvent("animaatio", resourceRoot, tostring( block ), tostring( anim )) That should output block and anim before and after it reaches the server, in that way it's easier to find out where the problem is. That's actually what I've done : function anim1 ( block, anim ) if isPedInVehicle ( client ) then outputChatBox("You are in the vehicle, get out to set your animation",client,255,0,0,true) return end outputChatBox("Block = "..tostring(block)..", Anim = "..tostring(anim), client) setPedAnimation ( client, tostring(block), tostring(anim), true, false ) end addEvent("animaatio", true ) addEventHandler("animaatio",getRootElement(), anim1) Also this is my trigger function : addEventHandler("onClientGUIClick",root, function ( ) local valittu = guiGridListGetSelectedItem( AnimAllGrid ) if ( valittu ) then local block = guiGridListGetItemText(AnimAllGrid, valittu, AnimBestBlockCol ) local anim = guiGridListGetItemText(AnimAllGrid, valittu, AnimBestAnimCol ) if ( source == AnimPlayButton ) then triggerServerEvent("animaatio", localPlayer, block, anim) end end end ) Even your code outputs the same.. Edited September 27, 2014 by Guest 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