[b] Client
addEventHandler("onClientGUIClick", root,
function()
if ( source == b1 ) then
triggerServerEvent("car",getLocalPlayer())
end
end
)[/b]
[b]Server
vehicle = {}
addEvent("car", true)
addEventHandler("car", root,
function(amount)
if isElement(vehicle[source]) then destroyElement(vehicle[source]) end
local x, y, z = getElementPosition(source)
vehicle[source] = createVehicle(599, x, y, z)
warpPedIntoVehicle(source, vehicle[source])
local money = getPlayerMoney(source)
if money >= amount then
takePlayerMoney (source,amount)
outputChatBox ("لقد اشتريت سيارة",source,255,0,0,true)
else
outputChatBox ("لايوجد معك مال كافي ",source,255,0,0)
end
end)
end
)
addEventHandler("onPlayerQuit", root,
function()
if isElement(vehicle[source]) then
destroyElement(vehicle[source])
vehicle[source] = nil
end
end)
[/b]