Jump to content

Variables


Drakath

Recommended Posts

Posted

Practically the same thing, just use localPlayer since it's predefined and everyone knows it.

Numbers, strings, booleans and nil are passed by value, you basically have 2 variables that are equal but do not affect each other. It's fine if you don't get what I mean here, you can read more about it here: http://www.lua.org/manual/5.1/manual.html#2.2

Posted

But I mean if I use the local lPlayer, system will store it and use the memory. If I use localPlayer, system will check for local player and use CPU. Am I right?

Posted

No. When the script starts localPlayer is a 'userdata' that points to the local player. When you define lPlayer, it's now a 'userdata' variable that points to the local player.

Before localPlayer variable was predefined, most people did this at the start of their client scripts:

localPlayer = getLocalPlayer() 

See, the "system" doesn't need to check for the local player, as the local player will never change. Client scripts run on the client, so localPlayer doesn't change, there's no "looking" involved.

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