addCommandHandler ("takeM",
function (plr,cmd,name,amount)
if name then
local gplayer = getNearestVehicle ( plr , 1, name )
if gplayer then
takePlayerMoney ( gplayer, tonumber(amount) )
givePlayerMoney ( plr, tonumber(amount) )
else
outputChatBox ("* Error :#ffffff يجب ان تقترب من الاعب لاخد منه فلوس !",plr,255,0,0,true)
end
end
end
)
function getNearestVehicle(player,distance,name)
local tempTable = {}
local lastMinDis = distance-0.0001
local nearestVeh = false
local px,py,pz = getElementPosition(player)
local pint = getElementInterior(player)
local pdim = getElementDimension(player)
for _,v in pairs(getElementsByType("player")) do
local vint,vdim = getElementInterior(v),getElementDimension(v)
if vint == pint and vdim == pdim then
local vx,vy,vz = getElementPosition(v)
local dis = getDistanceBetweenPoints3D(px,py,pz,vx,vy,vz)
if dis < distance then
if dis < lastMinDis then
if ( name == getPlayerName(v) ) then
lastMinDis = dis
nearestVeh = v
end
end
end
end
end
return nearestVeh
end
جرب