كيف استعمل هذا اليوزفل
function guiEditSetOnlyNumbers ( edit, boolean )
local function CheckNumbers ( )
local currText = guiGetText( source )
local newText = string.gsub( currText, '[^0-9]', '' )
if newText ~= currText then
guiSetText( source, newText )
end
end
if edit and boolean then
if getElementType ( edit ) == 'gui-edit' and type ( boolean ) == 'boolean' then
if boolean == true then
local CheckEventTrue = getEventHandlers( "onClientGUIChanged", edit )
for i, v in ipairs( CheckEventTrue ) do
if v == CheckNumbers then
removeEventHandler ( "onClientGUIChanged", edit, v )
break;
end
end
addEventHandler ( "onClientGUIChanged", edit, CheckNumbers )
return true;
else
local CheckEventFalse = getEventHandlers( "onClientGUIChanged", edit )
for i, v in ipairs( CheckEventFalse ) do
if v == CheckNumbers then
addEventHandler ( "onClientGUIChanged", edit, v )
break;
end
end
removeEventHandler ( "onClientGUIChanged", edit, CheckNumbers )
return true;
end
else
error ( "ERROR : bad argument ".. getElementType ( edit ) == 'gui-edit' and "2" or "1" .." excepted '".. getElementType ( edit ) == 'gui-edit' and "boolean" or "gui-edit" .."' got ".. getElementType ( edit ) == 'gui-edit' and type ( boolean ) or getElementType ( edit ) )
return false;
end
else
error ( "ERROR : bad argument ".. getElementType ( edit ) == 'gui-edit' and "2" or "1" .." excepted '".. getElementType ( edit ) == 'gui-edit' and "boolean" or "gui-edit" .."' got ".. getElementType ( edit ) == 'gui-edit' and type ( boolean ) or getElementType ( edit ) )
return false;
end
end