GGR|Takashi

setPedAnimation stops after using shift /jump

Recommended Posts

Hello Guys. I have a problem and I tried many hours to fix it but I didn't get it...maybe u guys can help  me out?! As u can see I wanted to use an animation when a player is in front of a sprunk-o-mat.... I wanted to hold the player for 5 seconds to make the job done(repair it)...but players are currently able to stop the animation by pressing 'LShift' I tried "setElementFrozen" but it didn't work and toggleControls(player,"jump",false) wasn't  a solution as well. Any ideas? Thanks for your help!

		function moneymarker(hitPlayer, matchingDimension )

			if isElementWithinMarker(hitPlayer,markers2)then
			money2 = math.random(50,75)
				local player = getElementType(hitPlayer)
				setPedAnimation( hitPlayer, "rob_bank", "cat_safe_rob", 5000,  true,false,false,true)  
					function timer23()			
							setPedAnimation( hitPlayer, "rob_bank", "cat_safe_end", 1,  true, true, true, false )
							givePlayerMoney (hitPlayer,money2)
							 outputChatBox ( "#ffffffDu hast den Automat erfolgreich repariert! Hier hast du #00ff00" ..money2.. " $!", hitPlayer,255,255,255,true ) 
							 destroyElement(markers2)
							 destroyElement(blip2)
							
										local anzahl = getMarkerCount()	
											if anzahl<=0 then
													outputChatBox("Chef: Es sind keine Automaten mehr übrig. Sehr gut! Komme nun zurück zur Firma und du erhälst eine Belohnung! !",myPlayer,255,255,0)	
													blipziel=createBlip(1656.28, -1820.54, 13.58,0, 2, 255, 0, 0, 255, 0, 99999.0,myPlayer) 
													markerziel= createMarker(1656.28, -1820.54, 12.90, "cylinder", 2.0, 255,0,0,150,myPlayer)
														function endpay(hitPlayer, matchingDimension )

															if isElementWithinMarker(hitPlayer,markerziel)then										
																		outputChatBox("Hut ab für die enorme Ausdauer, die du gezeigt hast.Hier eine Belohnung von 3000 Gollar! Zeig dich weiter so fleißig und du wirst es weit bringen!",myPlayer,0,255,0)
																		destroyElement(jobcar)
																		destroyElement(markerziel)
																		destroyElement(blipziel)
																		givePlayerMoney(hitPlayer,moneyboni)	
															end	
														end
													addEventHandler("onMarkerHit", markerziel, endpay)
											end
												if anzahl==1 then
													outputChatBox("'Chef: Es ist noch ein Automat übrig!'",myPlayer,255,255,0)
												end											
												if anzahl==2 then
													outputChatBox("'Chef: Du bist fast fertig!'",myPlayer,255,255,0)
												end
												if anzahl >=3 then							
													outputChatBox("Die Auftragsliste gibt noch  "..anzahl.."  offene Aufträge für zu reparierende Automaten preis.",myPlayer,255,255,0)
												end
											
					end
			end				
				setTimer(timer23,5000,1)

		end	
		
		addEventHandler("onMarkerHit",markers2, moneymarker)

 

Share this post


Link to post
1 hour ago, Zorgman said:

Is freeroam running when you test this?

Thaaaank you so much...that was the solution! Freeroom was on...now I stopped freeroom andnow the animation is no more interruptable. :) one love brother. :D

Share this post


Link to post

Could you also help me with this one? I want to scale one of the sprunk-o-mat this is my current serversided code:

scaler=createObject(1775,1928.800	,	-1772.500	,	13.600	,	0,0,90)
function scalex()
if (scaler) then
	setObjectScale(scaler,1.1)
	setElementCollisionsEnabled(scaler,true)
end
end
addEventHandler("onClientResourceStart",getRootElement(),scalex)

Nothing changes Ingame...the Sprunk-o-mat still has its original size.

Share this post


Link to post

Your code is serversided, you say? In that case, "onClientResourceStart" won't work, as that's a clientsided event. Use "onResourceStart" instead. And while you're at it, don't use getRootElement(), as otherwise, the same object will be created whenever a resource is being started. Again, use "getResourceRootElement(getThisResource())" instead.

Share this post


Link to post
1 hour ago, Lawliet said:

Your code is serversided, you say? In that case, "onClientResourceStart" won't work, as that's a clientsided event. Use "onResourceStart" instead. And while you're at it, don't use getRootElement(), as otherwise, the same object will be created whenever a resource is being started. Again, use "getResourceRootElement(getThisResource())" instead.

Using predefined variables would dramatically decrease your code size. for getResourceRootElement() just use resourceRoot, its a predefined variable that is the resource root, and for getRootElement() just use root, which is a predefined variable for the root element.

--This
addEventHandler('onClientRender',getRootElement(),function()
	
end)

addEventHandler('onResourceStart',getResourceRoot(getThisResource()),function()
	
end)

-- vs this, what i'm talking about
addEventHandler('onClientRender',root,function()
    
end)

addEventHandler('onResourceStart',resourceRoot,function()
	
end)

 

  • Like 1

Share this post


Link to post
4 minutes ago, shay01 said:

Using predefined variables would dramatically decrease your code size. for getResourceRootElement() just use resourceRoot, its a predefined variable that is the resource root, and for getRootElement() just use root, which is a predefined variable for the root element.


--This
addEventHandler('onClientRender',getRootElement(),function()
	
end)

addEventHandler('onResourceStart',getResourceRoot(getThisResource()),function()
	
end)

-- vs this, what i'm talking about
addEventHandler('onClientRender',root,function()
    
end)

addEventHandler('onResourceStart',resourceRoot,function()
	
end)

 

 

Ah yes, I wasn't exactly sure if those are "interchangeable", so to speak. I myself like to use resourceRoot, anyway.

Share this post


Link to post

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.