Jump to content

Client-side command doesn't work


Bebras

Recommended Posts

Posted

Okay, i'm a complete beginner(like this is my 2nd command code..), and i was trying to create a client-side command with the code:

  
  
function displayPosition() 
    local x,y,z = getEelementPosition(localPlayer); 
    outputChatbox("X:"..x.."Y:"..y.."Z:"..z,0,255,0); 
end 
addCommandHandler("pos",displayPosition); 

I added this line to my meta file:

<script src="clientCommand.lua" type="client" /> 

What is wrong, because it doesn't work?

Again, i'm a beginner and any feedback will be appreciated :)

Posted (edited)
function displayPosition() 
    local x,y,z = getElementPosition(getLocalPlayer()) 
    outputChatBox("X:"..x.."Y:"..y.."Z:"..z,0,255,0) 
end 
addCommandHandler("pos",displayPosition) 
  

P.S : you dont need to put ";" in LUA , like in C++ indicating that is end of the line.

Edited by Guest
Posted

Great, thanks !

Why did you change it to "getLocalPlayer"? Isn't it predefined and asigned to variable "localPlayer"

And just because i have an open topic: a command that spawns a vehicle should be server-sided right? For the vehicle to be synced?

Posted

getLocalPlayer and localPlayer is both same thing.

And, if you create a vehicle client side, you won't be able to drive it, and it won't be synced.

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