Jump to content

Question about OOP


Banex

Recommended Posts

Posted
object:method(arg1, arg2, ...) 

Is the same as

object.method(object, arg1, arg2, ...) 

Therefore

player:setMuted(muted) 

Is the same as

setPlayerMuted(player, muted) 

-

Posted

I do not understand how to use the variable, the two functions have the same variable, so if I use the variable of isPlayerMuted function, player.muted() without putting any argument as to whether the player is muted or not, I'll have a warning message in debugscript not to use the obligatory argument setPlayerMuted function?

jIcd9sc.png

Not worry about the future. Very soon it will come.

  • MTA Team
Posted

It should work like this (not sure)

  
local player = Player.getRandom() 
  
-- Mute the player 
player:setMuted(true) 
player.muted = true 
setPlayerMuted(player, true) 
  
-- Unmute the player 
player:setMuted(false) 
player.muted = false 
setPlayerMuted(player, false) 
  
-- Is the player muted? 
if player.muted then --[[ ... ]] end 
if player:isMuted() then --[[ ... ]] end 
if isPlayerMuted(player) then --[[ ... ]] end 
  

Posted

I did a test, and now I understand if I do not give any value to function then it will work as the pair function. Thanks to all

jIcd9sc.png

Not worry about the future. Very soon it will come.

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