Jump to content

Problem in a simple script


TwicH

Recommended Posts

Posted

hey guys im trying to get into scripting and i have some problem with a simple script i put together

function MarkerHit ( hitPlayer, matchingDimension ) 
      setPedAnimation( player, "ped", "WOMAN_walknorm") 
end 
addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) 

here is the code can you explain to me whats wrong?

Posted
setPedAnimation( player, "ped", "WOMAN_walknorm") 

'player' isn't defined on this event. Use 'hitPlayer' instead.

BTW: Use [lua ] [ /lua] for highlighting.

Posted

I tried this but player dosent work

some friend told me to use this code:

function MarkerHit ( hitPlayer, matchingDimension ) 
 if hitPlayer == localPlayer then 
     setPedAnimation( hitPlayer, "ped", "WOMAN_walknorm") 
    end 
end 
addEventHandler ( "onClientMarkerHit", getRootElement(), MarkerHit ) 

it works but i dont know why..

Posted

localPlayer is global definied variable which means player who is using this script right now. After entering the marker you are checking if hit player is this 'localPlayer'. If so, it sets the animation.

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...