Jump to content

[Help] Not sure with getLocalPlayer


AlexWo

Recommended Posts

Posted

Hi.

In my script I just want that if a player hit's the Marker he get teleported to Ammunation1.

I got mixed up with how to get the local Player.

I only have a client side.

Weaponshop1 = createMarker(1368, -1279.8, 12.7, "cylinder", 1.5, 255, 255, 255, 255) 
  
  
function warpinto1 (source) 
setElementInterior ( source, 1, 286, -40, 1001 ) 
end 
  
addEventHandler( "onPlayerMarkerHit", Weaponshop1, warpinto1) 
  

I'm not sure with the functions how to get the local Player who enters the Marker

Thank you for helping me :)

Posted

"onPlayerMarkerHit" is a server side event, and the way you add the event handler is wrong, change 'Weaponshop1' with 'root'.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Wiki quote:

root: This is at the very base of the tree - all elements are children (or descendants) of this element.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

I have to change now:

addEventHandler( "onPlayerMarkerHit", Weaponshop1, warpinto1) 

to..

addEventHandler( "onPlayerMarkerHit", root, warpinto1) 

or how because I'm not sure...

Posted

Yes, exactly, and the script must be set as server side on the meta.xml.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

That's because the first argument of "onPlayerMarkerHit" is the marker the player hit, not the player that hit the marker.

Weaponshop1 = createMarker ( 1368, -1279.8, 12.7, "cylinder", 1.5, 255, 255, 255, 255 ) 
  
function warpinto1 ( ) 
    setElementInterior ( source, 1, 286, -40, 1001 ) 
end 
addEventHandler ( "onPlayerMarkerHit", root, warpinto1 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

You're welcome.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

it will send you to interior at any marker because have root

addEventHandler ( "onPlayerMarkerHit", root, warpinto1 ) 

so use this better

Weaponshop1 = createMarker ( 1368, -1279.8, 12.7, "cylinder", 1.5, 255, 255, 255, 255 ) 
  
function warpinto1 ( player ) 
    if ( source == Weaponshop1 ) then 
        setElementInterior ( player, 1, 286, -40, 1001 ) 
    end 
end 
addEventHandler ( "onPlayerMarkerHit", root, warpinto1 ) 

Giving a Fuck? Nope, That isn't in My Skill Set

castie11.png

Posted

Well, that's correct, but your code is so wrong.

Weaponshop1 = createMarker ( 1368, -1279.8, 12.7, "cylinder", 1.5, 255, 255, 255, 255 ) 
  
function warpinto1 ( theMarker ) 
    if ( theMarker == Weaponshop1 ) then 
        setElementInterior ( source, 1, 286, -40, 1001 ) 
    end 
end 
addEventHandler ( "onPlayerMarkerHit", root, warpinto1 ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

  • Moderators
Posted

Skipper was probably confused with the event "onMarkerHit".

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

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