Maybe this is what you are looking for:
addCommandHandler ( "cash",
function ( player, command, dude )
if dude then
local temp = getPlayerFromName(dude)
if temp then
outputChatBox("The player "..dude.." has $"..tostring(getPlayerMoney(temp)),player,0,255,0)
else
outputChatBox("Player "..dude.." not found",player,0,255,0)
end
else
outputChatBox("The player "..getPlayerName(player).." has $"..tostring(getPlayerMoney(player)), getRootElement(),0,255,0)
end
end
)