Sup guys, so before I get into the actual question, I'd like to tell you that I haven't scripted in almost a year and I just started like a week ago again.
So what i'm asking is, I have this code here (Below) from a script I made 3 days ago, what I'd like to know is, how do I turn it into OOP? And throw a metatable in it, plus making use of it. And why is OOP useful and how? (If you'd like to help explaining, mind not linking me to different pages? explain using your own words please, that'd be easier for me to understand. )
Once I know why it's useful and how to use it, I'ma start using both OOP and metatables in future scripts of mine
Code:
function stopEvent( thePlayer )
local groupName = "EventManager"
local zzz= getPlayerAccount( thePlayer )
if ( zzz) then
local accName = getAccountName( zzz)
if ( isObjectInACLGroup ( "user."..accName, aclGetGroup ( groupName ) ) ) then
-- for k, thePlayer in pairs( getElementsByType( 'player' ) ) doe
removeEventHandler( "onFreezFight", resourceRoot, freezHandlar )
removeEventHandler( "onFightStart", resourceRoot, spawnHandlre )
for _, thePlzzayer in pairs( getElementsByType( 'player' ) ) do
takeAllWeapons( thePlzzayer )
setElementFrozen( thePlzzayer, false )
toggleControl ( thePlzzayer, "fire", true )
spawnPlayer ( thePlzzayer, xw, yw, zw )
end
-- end
outputChatBox( '[Event] Event has stopped.', localPlayer, 255, 0, 0, true )
end
end
end
addCommandHandler( 'stopit', stopEvent )
Thank you.