Jump to content

Run for all players


Zcraks

Recommended Posts

The script performs for all players, how to fix it?
client.Lua

function work (element)
	if element == localPlayer and isElement(marker) then

   		triggerServerEvent("setAnim", root)

end
addEventHandler("onClientMarkerHit",root, work)

server.Lua
 

function getAnim (player)
		setPedAnimation(player, ...)

				obj =  createObject ( id, x, y, z, 0, 0, 0 )
				exports.bone_attach:attachElementToBone( obj, player, 4, 0, 0.4, - 0.6, -90, 0, 0 );

end
addEvent("setAnim", true)
addEventHandler("setAnim", resourceRoot, getAnim)

 

Edited by Zcraks
Link to comment
25 minutes ago, Zcraks said:
  • end
  •  
function work (element)
	if  element == localPlayer and isElement(marker) and source==marker then
   		triggerServerEvent("setAnim", localPlayer)
	end
end
addEventHandler("onClientMarkerHit",root, work)

server

function getAnim ()
		setPedAnimation(source, ...)

				obj =  createObject ( id, x, y, z, 0, 0, 0 )
				exports.bone_attach:attachElementToBone( obj, source, 4, 0, 0.4, - 0.6, -90, 0, 0 );

end
addEvent("setAnim", true)
addEventHandler("setAnim", resourceRoot, getAnim)

 

Edited by Master_MTA
Link to comment
1 hour ago, Zcraks said:
  1. function work (element)
  2. if element == localPlayer and isElement(marker) then
  3.  
  4. triggerServerEvent("setAnim", localPlayer , localPlayer)
  5.  
  6. end
  7. addEventHandler("onClientMarkerHit",root, work)

 

44 minutes ago, Master_MTA said:
  1. function getAnim (player)
  2. setPedAnimation(player, ...)
  3.  
  4. obj = createObject ( id, x, y, z, 0, 0, 0 )
  5. exports.bone_attach:attachElementToBone( obj, player, 4, 0, 0.4, - 0.6, -90, 0, 0 );
  6.  
  7. end
  8. addEvent("setAnim", true)
  9. addEventHandler("setAnim", resourceRoot, getAnim)

 

Edited by Felix5k
Link to comment
2 hours ago, Zcraks said:

Dont working server trigger 


triggerServerEvent ("setAnim",localPlayer, localPlayer)

but this works for all players


triggerServerEvent ("setAnim", root, localPlayer)

 

i don't inderstand what you want to do, to trigger just localPlayer or all?

Link to comment
3 minutes ago, Felix5k said:

i don't inderstand what you want to do, to trigger just localPlayer or all?

localPlayer. This variant dont working 

triggerServerEvent ("setAnim",localPlayer, localPlayer)

The fucntion on server side "setAnim" Event dont started

Link to comment
3 minutes ago, Zcraks said:

localPlayer. This variant dont working 


triggerServerEvent ("setAnim",localPlayer, localPlayer)

The fucntion on server side "setAnim" Event dont started

try to write a outputChatBox to check if is make the function

Link to comment
Just now, Zcraks said:

outputChatBox dont workin on server side

wait , i'am testing now on my server

 

client-side

function work (element)
if element == localPlayer and isElement(marker) then
triggerServerEvent("setAnim", localPlayer,localPlayer)
 end
end
addEventHandler("onClientMarkerHit",root, work)

server-side


function setAnim(thePlayer)
outputChatBox("Hi", thePlayer, 100,255,100)
setPedAnimation(thePlayer, ...)
obj = createObject ( id, x, y, z, 0, 0, 0 )
exports.bone_attach:attachElementToBone( obj, thePlayer, 4, 0, 0.4, - 0.6, -90, 0, 0 )
end
addEvent("setAnim", true)
addEventHandler("setAnim", root, setAnim)

 

8 minutes ago, Felix5k said:

wait , i'am testing now on my server

 


client-side

function work (element)
if element == localPlayer and isElement(marker) then
triggerServerEvent("setAnim", localPlayer,localPlayer)
 end
end
addEventHandler("onClientMarkerHit",root, work)


server-side


function setAnim(thePlayer)
outputChatBox("Hi", thePlayer, 100,255,100)
setPedAnimation(thePlayer, ...)
obj = createObject ( id, x, y, z, 0, 0, 0 )
exports.bone_attach:attachElementToBone( obj, thePlayer, 4, 0, 0.4, - 0.6, -90, 0, 0 )
end
addEvent("setAnim", true)
addEventHandler("setAnim", root, setAnim)

 

it should work now.

  • Thanks 1
Link to comment
45 minutes ago, Felix5k said:

wait , i'am testing now on my server

 


client-side

function work (element)
if element == localPlayer and isElement(marker) then
triggerServerEvent("setAnim", localPlayer,localPlayer)
 end
end
addEventHandler("onClientMarkerHit",root, work)


server-side


function setAnim(thePlayer)
outputChatBox("Hi", thePlayer, 100,255,100)
setPedAnimation(thePlayer, ...)
obj = createObject ( id, x, y, z, 0, 0, 0 )
exports.bone_attach:attachElementToBone( obj, thePlayer, 4, 0, 0.4, - 0.6, -90, 0, 0 )
end
addEvent("setAnim", true)
addEventHandler("setAnim", root, setAnim)

 

it should work now.

Thank u

  • Like 1
Link to comment
53 minutes ago, Felix5k said:

client-side

function work (element)
if element == localPlayer and isElement(marker) then
triggerServerEvent("setAnim", localPlayer,localPlayer)
 end
end
addEventHandler("onClientMarkerHit",root, work)

server-side


function setAnim(thePlayer)
outputChatBox("Hi", thePlayer, 100,255,100)
setPedAnimation(thePlayer, ...)
obj = createObject ( id, x, y, z, 0, 0, 0 )
exports.bone_attach:attachElementToBone( obj, thePlayer, 4, 0, 0.4, - 0.6, -90, 0, 0 )
end
addEvent("setAnim", true)
addEventHandler("setAnim", root, setAnim)

The event will be triggered for all server markers and not just for 'marker'.

Here's an version indented and more cleaner:

function work( element )
	if element == localPlayer then
		triggerServerEvent( "setAnim", localPlayer )
	end
end
addEventHandler( "onClientMarkerHit", marker, work )

server

function setAnim()

	setPedAnimation( client, ... )
	local obj = createObject ( id, x, y, z, 0, 0, 0 )
	exports.bone_attach:attachElementToBone( obj, client, 4, 0, 0.4, - 0.6, -90, 0, 0 )
end
addEvent("setAnim", true)
addEventHandler("setAnim", root, setAnim)

 

  • Sad 1
Link to comment

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.
×
×
  • Create New...