Skip to content
Dawi edited this page Jan 24, 2014 · 1 revision

Description

With bind you can bind an eventHandler to an element from your class.

Syntax

bind(Classname.function,element)

Example

CCarhouse = {}


function CCarhouse:constructor(ID,Model,X,Y,Z,RX,RY,RZ,Price)

	self.ID = ID
	self.Model = Model
	self.X = X
	self.Y = Y
	self.Z = Z
	self.RX = RX
	self.RY = RY
	self.RZ = RZ
	self.Price = Price
	self.Name = getVehicleNameFromModel(self.Model)
	
	self.eOnClck = bind(CCarhouse.onClick, self)
	addEventHandler("onElementClicked",self, self.eOnClick)
	
end

function CCarhouse:onClick(button,state,player)
	if button == "left" and state == "down" then
		outputChatBox("Clicked on "..self.Name,player,255,255,255)
	end
end
Clone this wiki locally